When formatting a cell which contains numbers in a Sheetnode module form is not posible to use dd/mm/yy date format like
4/1/06 and 04/01/2006 , more common in European countries.

Comments

infojunkie’s picture

Component: Views » SocialCalc
Category: task » feature

Thanks for the report. Yes, European-style dates should be supported.

infojunkie’s picture

Actually, you can format European dates by entering a custom number format such as dd/mm/yyyy.

What I want to fix is:
* Present dd/mm/yyyy and d/m/yy format presets
* Recognize input dates in the European format based on the Drupal locale settings

aoristos’s picture

Version: 6.x-1.7 » 6.x-1.8

The most appropriate (although makeshift) solution for me to let users enter dates in European date format is by 'hacking' the file 'socialcalc-3.js'
I have added 3 lines of code in 'socialcalc-3.js' to make Socialcalc accept date inputs in European format.
The code swaps the day and month values in the submitted date so that Socialcalc can further process the input as a genuine American formatted date.
The algorithm swaps 2 values without creating a additional temporary variable.

I inserted the additional 3 lines of code between the original lines nr. 5548 and nr. 5549 :

(original line 5548 : else if (matches=value.match(/^(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{1,4})\s*$/)) { // MM/DD/YYYY, MM/DD/YYYY)
matches[1] ^= matches[2]; // 1st code line added
matches[2] ^= matches[1]; // 2nd code line added
matches[1] ^= matches[2]; // 3th code line added
(origonal line 5549 : year = matches[3] - 0;)

//The values of matches[1] and matches[2] are swapped using the Bitwise Exclusive OR operator (so DD/MM/YYYY becomes MM/DD/YYYY).

-----------------
Drupal 6.27
Sheetnode 6.x-1.8
Socialcalc code from https://github.com/infojunkie/socialcalc.git
-----------------
Thanks to Infojunkie (and Dan Bricklin) for all the good work !

infojunkie’s picture

Version: 6.x-1.8 » 7.x-1.x-dev
Issue summary: View changes
Related issues: +#814818: Decimal and thousands separator - the European way

Moving to D7 queue.

hhigel’s picture

Enabled to input "German Style" date format DD.MM.YYYY by adding the following lines after original line 5560:

   else if (matches=value.match(/^(\d{1,2})\.(\d{1,2})\.(\d{1,4})\s*$/)) { // DD.MM.YYYY
      year = matches[3]-0;
      year = year < 1000 ? year + 2000 : year;
      value = SocialCalc.FormatNumber.convert_date_gregorian_to_julian(year, matches[2]-0, matches[1]-0)-2415019;
      type = "nd";
      }	

Thanks to Infojunkie & Co for this brillant module!

arx-e’s picture

@hhigel
I have pasted your code after line 5560 in socialcalc-3.js but it doesn't seem to work for me.
Cleared caches etc but the behaviour is still the wrong one: entering DD/MM/YYYY dates are interpreted as if they were entered as MM/DD/YYYY.
Any idea about something I might be missing?

willhallonline’s picture

Status: Active » Closed (works as designed)

This can be done by editing the formats in the library.