Date Format?

Adam Peller apeller at us.ibm.com
Thu Apr 17 20:46:42 PDT 2008


Garrett wrote:
>
> Properly formatting dates, solution (1), in ES is a lot of work.
>

Indeed it is.  A couple of Javascript toolkits have taken a crack at this
problem and provide pluggable, reusable solutions you may want to look at
(e.g. Dojo's dojo.date.format and datejs available from Google code)  There
are several facets to this problem.  First there is the parsing and
formatting logic, basically string and regexp operations which are not
unreasonable to delegate to a toolkit.  Another is maintaining the large
translation tables needed to provide this function (communities like the
one
in unicode.org/cldr have taken this on in open source -- there's no reason
why you should have to build your own translations).  Then there is the
mechanism to embed and load the appropriate resources.  Note that this is
essentially a package loading problem which is not unique to Dates, and
Dojo
leverages its package loader to load locale-sensitive information like
these
date formats.  I think this part is most challenging to provide in
Javascript, but appears to be outside the scope of ES4.

The current ES4 Date proposal provides unambiguous ISO formats which should
encourage better programming practices.  That seems like the right place to
start.  Hard-coding mm/dd/yyyy is just as bad as hard-coding English
strings.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.mozilla.org/pipermail/es-discuss/attachments/20080417/2ef1ce03/attachment-0002.html 


More information about the Es4-discuss mailing list