[Dojo-interest] dojo.date.setIso8601() does not support space date/time separator

Aaron Evans aaronmevans at gmail.com
Thu Apr 27 07:29:09 MDT 2006


While we are on the subject of parsing dates, I would again like to
ask if there is any plans for adding the corresponding *parse* method
(to go with format) in dojo.date.

Basically, this method would take two arguments, a date string and a
date format string and attempt to parse the date string based on the
format string.

IMO, you kind of can't have one without the other.  It's like having a
get method but no set method.

Here is my particular use case:

I have a custom drop-down date picker, similar to Dylan's demo.  For
my widget, I provide the ability to override the default date format
string as well as provide an initial date value (as a string)  by
specifying these values in the div tag.

The initial date value is very important since you might have an edit
form where you are editing some existing data values.  Obviously, when
I click to bring up the date picker, I need the date picker to be set
to the initial date value, not the current date.

However, say, I have specified as my date format '%d/%m/%Y' and my
initial date value as '1/2/2006', I need a way of parsing this date
string into a date object according to the specified date format
string during the UI initialization in order to set the value of the
date picker.

Does this not sound like a reasonable and common use case?

I suppose I will resort to writing my own, but my JS skills kind of
suck, which is why I am using dojo in the first place. :)   So I would
really appreciate it if it were added to the code-base.

thx,
aaron

On 4/27/06, Shane O'Sullivan <shaneosullivan1 at gmail.com> wrote:
> Speaking of the Iso8601 support, I'm seeing a bug with the
> dojo.date.setIso8601Date method.  The code:
>
> dojo.date.fromIso8601Date('2006-03-13T22:42:42Z');
>
> returns false, even though I've passed it a valid ISO860 string.
>
> Also, it would be useful to have a method for turning a date object
> back into an ISO8601 string, without having to use Dojo's date format
> string.  Paul Sowden (a contributor to Dojo) has a good example at
> http://delete.me.uk/2005/03/iso8601.html
>
> Also, his "setISO8601" works perfectly.
> Would it be possible to get this code into Dojo?
>
> Thanks
>
> Shane
>
>
> On 23/04/06, Alex Russell <alex at dojotoolkit.org> wrote:
> > Actually, I merged a fix for the "split by space" issue, but the regexp
> > may well still be b0rken.
> >
> > On Thursday 20 April 2006 6:08 pm, Dylan Schiemann wrote:
> > > This looks like a valid bug.  Can you please file a ticket:
> > > http://trac.dojotoolkit.org/ , on the post 0.3 release as the
> > > milestone, 0.2 as the version.  It has a much greater chance of
> > > someone fixing the issue by seeing it in trac.
> > >
> > > Thanks,
> > > -Dylan
> > >
> > > Anonymous Coward wrote:
> > > > Hi,
> > > >
> > > > I see that the dojo.date.setIso8601() function splits the ISO
> > > > datetime string on a T character. However, ISO8601 also allows a
> > > > space to be used. So if that is added, Dojo would be able to parse
> > > > more ISO8601 compliant dates.
> > > >
> > > > [00:12] <pokernut> I think there's a big in the function as well.
> > > > [00:12] <pokernut> I'm trying to use it and it's not parsing it
> > > > correctly. [00:12] <pokernut> I think the regex in setIso8601Date()
> > > > is wrong
> > > >
> > > > I posted some improvements in the comments of this blog post:
> > > > http://delete.me.uk/2005/03/iso8601.html afaik, this is what
> > > > dojo.date was originally based on
> > > >
> > > > Additionally:
> > > >
> > > > When I do this:
> > > >
> > > > var date = new Date(d[1], 0, 1);
> > > > alert(date);
> > > > if (d[2]) { date.setUTCMonth(d[2] - 1); }
> > > > alert(date);
> > > >
> > > > I get this (in Firefox):
> > > >
> > > > Sun Jan 01 2006 00:00:00 GMT+0100
> > > > Wed Jun 01 2005 01:00:00 GMT+0200
> > > >
> > > > Note that by setting the month, the year changed. This probably
> > > > depends on the locale, as for someone in the US the year did not
> > > > change. Looks like by using setUTCMonth, Firefox triggers some kind
> > > > of UTC representation internally, but re-uses the same data
> > > > structure for that without converting it to the new representation.
> > > > Or something.
> > > >
> > > >
> > > > ~Grauw
> > > > -------------------------------------------------------------------
> > > >-- Posted via Jive Forums
> > > > http://forums.opensymphony.com/thread.jspa?threadID=26722&messageID
> > > >=52621#52621
> > > >
> > > > _______________________________________________
> > > > Dojo FAQ: http://dojo.jot.com/FAQ
> > > > Dojo-interest at dojotoolkit.org
> > > > http://dojotoolkit.org/mailman/listinfo/dojo-interest
> > >
> > > _______________________________________________
> > > Dojo FAQ: http://dojo.jot.com/FAQ
> > > Dojo-interest at dojotoolkit.org
> > > http://dojotoolkit.org/mailman/listinfo/dojo-interest
> >
> > --
> > Alex Russell
> > alex at jot.com
> > alex at dojotoolkit.org BE03 E88D EABB 2116 CC49 8259 CF78 E242 59C3 9723
> >
> >
> > _______________________________________________
> > Dojo FAQ: http://dojo.jot.com/FAQ
> > Dojo-interest at dojotoolkit.org
> > http://dojotoolkit.org/mailman/listinfo/dojo-interest
> >
> >
> >
> >
> _______________________________________________
> Dojo FAQ: http://dojo.jot.com/FAQ
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>


More information about the Dojo-interest mailing list