Calendar.parse

Martin Karlgren <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Message-ID <[email protected]>
Hi,

I’m trying to parse a (somewhat funny) date/time format I got from somewhere, but Calendar.parse fails:

> Calendar.parse("%D-%M-%YT%h:%m:%s", "03-05-2016T10:20:30.0");
(8) Result: 0

It works if I remove the “T” delimiter:

> Calendar.parse("%D-%M-%Y %h:%m:%s", "03-05-2016 10:20:30.0");
(9) Result: Second(Tue 3 May 2016 10:20:30 CEST)

Also, it works if I reverse the date format:

> Calendar.parse("%Y-%M-%DT%h:%m:%s", "2016-05-03T10:20:30.0");
(10) Result: Second(Tue 3 May 2016 10:20:30 CEST)

I believe the reason is that %Y is defined as ALNU (alphanumeric) rather than NUME (numeric) in Calendar.parse (YMD.pike). Is there a reason that %Y needs to be ALNU or can it be changed to NUME instead? Any compat issues? (or is %Y supposed to support “Twothousandandsixteen”? ;) )

/Marty
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.