I actually like that, makes sense, since arrays are 0 based and people
often convert the value to the equivalent string name of the month from
an array.  So you could easily make an array of month names, ["January",
"February", "March"...etc] and then access the month name using the
monthUTC value without having to subtract 1.  Of course, to get the
numeric value, you have to add 1, but either way, not a big deal I
guess.


Jason Merrill 

Instructional Technology Architect
Bank of America   Global Learning 

Join the Bank of America Flash Platform Community  and visit our
Instructional Technology Design Blog
(Note: these resources are only available for Bank of America
associates)





-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Gerry
Beauregard
Sent: Friday, August 27, 2010 4:39 AM
To: Flash Coders List
Subject: [Flashcoders] Date.monthUTC uses 0 for January

This is not a question, just a little observation that might save other
folks a few minutes of gnashing of teeth and hair pulling.

I need some code that will give me the current date in ISO 8601 format,
e.g. "2010-08-27".  I figured the Date class would be a good place to
start, but I was really puzzled by the output I got.

This code...
  var date:Date = new Date;
  trace( date.fullYearUTC, date.monthUTC, date.dateUTC ); ...prints out
this:
   2010 7 27

The year and day of the month are correct, but the month is off by one.
Huh??

Well, it turns out that monthUTC is the month with *zero* as January.
It's documented, but pretty bizarre nonetheless... though it turns out
the "tm" structure in C's time.h uses the same convention.

-Gerry



_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to