Makes sense.. a little annoying when working with other data sources but
then i suppose going the unix route would've made more sense in the first
place.

Thanks for all the replies:)
S

-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Matthias Reuter
Sent: 01 July 2011 09:01 AM
To: [email protected]
Subject: Re: [JSMentors] Google API Date() a month ahead?

>>> Months in js are typically offset at zero when using the Date object. I
>> assume the google api used that too. So 0=jan, 5=june, 6=july.
>>
>
> Putting it more strongly, months in the Date object *do* start at zero:
> 0=Jan ... 11=Dec. But just to keep things confusing, years and days use  
> the actual numbers, e.g. 2011 is 2011, and the first day of any month is  
> 1.

And this makes it easier to get the names of months:

var months = ["January", "February", "March", "April"]; // and so on
var currentMonth = months[new Date().getMonth()]; // don't run this script  
today (or extend the array above)

Since we usually don't have names for years and the day-in-month, these  
don't start with zero. We do have names for the weekdays though, and thus  
they start with 0 (for sunday):

var weekdays = ["Sunday", "Monday", "Tuesday"]; // and so on
weekdays[new Date("2011-07-03").getDay()]; // is "Sunday"


Matt

-- 
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to