Date Object Doesn't Work.

Garrett Smith dhtmlkitchen at gmail.com
Thu May 29 10:00:10 PDT 2014


On 5/28/14, Andrea Giammarchi <andrea.giammarchi at gmail.com> wrote:

Hi Andrea -

> While I agree we should expect consistent results, you might get more
> consistent one via UTC time, i.e.
>
> ```
> var r = new Date(2013, 02, 10),
>     r2 = new Date(2013, 02, 10),
>     diff = 7;
> r.setUTCHours(2 + diff);
> r2.setUTCHours(3 + diff);
> ```
>
> Above operation will actually show 1 hour difference in all browsers
> (visually 2 due -8 VS -7 zone)
>

The difference between 2am and 3am on that date, for this timezone
(America/Los_Angeles), is zero. diff isn't needed to calculate
DST-free difference.

r
Sun Mar 10 2013 01:00:00 GMT-0800 (PST)

Given arbitrary dates and timezones, tzo difference might or might not
cross DST and that might be adjusted by the user.

But calculating DST-free difference seems like a safer bet. And so the
way to do that would be to send a local date but treat it as UTC.
-- 
Garrett
@xkit
ChordCycles.com
garretts.github.io


More information about the es-discuss mailing list