Forum OpenACS Development: Output Format for showCalendar Function on core.js

I have made the changes to the function showCalendar defined on acs-subsite/www/resources/core.js ( I commited on oacs-5-2).

Right now you can specify the output format of the date on an ad_form element like this:

{start_date:text(text)
{label "Start Date"}
{html {id sel1}}
{after_html { < input type='reset' value=' ... ' onclick=\"return showCalendar('sel1', 'y-m-d');\"> \[y-m-d\]
}}

this will return the date like: '2005-09-24'

You can specify any combination of the letters y m d D M where D will return the name of the day (e.g. Mon, Fri, Sat, etc.) and M will return the name of the month (e.g. Oct, Sep, Dec, etc.)

For example

If the format is 'D, d M y' it will return 'Fri, 24 Sep 2005'.

If the fomat is 'd.m.y' it will return '29.09.2005' so you can also use different separators like "," or "." or "/" or "-".

Collapse
Posted by Miguel Marin on
Also if you don't provide the format then the default one will be: d-m-y
That's great Miguel, but it might make more sense to set the default to something that is less likely to confuse people (the format you picked is not very US friendly for example).

I feel the international standard date and time notation should be returned as the default if nothing is specified in ad_form.

yyyy-mm-dd

Here is a link that describes the standard:
http://www.cl.cam.ac.uk/~mgk25/iso-time.html

Also, after a quick search I noticed a difference in the notation of the output options (e.g. on that page they type YYYY-MM-DD). Are you using some tcl formating option for dates?

Collapse
Posted by Miguel Marin on
I will put the format output to y-mm-dd.

You can play with the formats for example:

If we take this date: 2005-09-08

Format: Output:
y-mm-dd 2005-09-08
yy-mm-dd 05-09-08
y-mm-d 2005-09-8
y-m-d 2005-9-8
y-mm-dd, D 2005-09-08, Thu
D M dd, y Thu Sep 08, 2005

So it depends of the format you specify since:

yyyy-mm-dd returns yyyy-09-08 not 2005-09-08 but this is because the way it was designed.

Collapse
Posted by Malte Sussdorff on
If we can set the format in the ad_form, why don't you use the format stored in acs-lang.localization-d_fmt. (or create a new string in acs-lang to make use of it). After all the display should be user specific and not site specific.
Collapse
Posted by Miguel Marin on
But if we let the user to specify the format to show in the input text of the ad_form then the code to deal with all the possible formats the user can specify will need to be also implemented or have in mind to manipulate the input data, I don't know if there is a procedure to do that already developed.
Collapse
Posted by Malte Sussdorff on
I pretty sure that calendar is able to work with data given in the user's locale. After all, in the lc_time_format we can use it both ways, can't we? Once when we display the widget and once when we convert the user input back. But maybe I don't see the stumbling block :).
Collapse
Posted by Miguel Marin on
Ok, I have made the modifications in core.js so now the calendar works with the format yyyy for full year, also when I was making this changes I realise that if you put 2 calendars in the same page it was always taking the format of the first calendar that you clicked on and no it's own format, this was because the calendar is an object that is created only one time and reuse for the other calendars in the page, so I also fixed that. This changes are for oacs-5-2 let me know if you want then in HEAD as well.