Javascript Date - how to find out if DST is valid in a given time zone

First, I am NOT looking to see if DST acts locally.

I am starting a Node process that has data with associated timestamps. I need to convert these timestamps in day / month / year to the specified time zone, but all that is given to me is the time zone offset and DST offset.

I want Date / Moment to work better with time zones. They work great with UTC or local time zones, but it looks like you need to hack it to get something else.

Is there something I am missing? Assuming I can determine if the DST is valid, whether this will work:

var d = new Date(ts + timezone_offset - local_offset);
d.getMonth();
d.getDate();

where timezone_offset is the timezone offset (standard offset or dst)?

How can I determine if DST is valid?

+5
3

-, , , , , . , "America/New_York". , , , .

, TimeZoneJS, - DST TimeZoneJS , DST.

moment.js - . ( , ), :

moment(timestamp).tz(timezone).isDST()

:

moment(1451624400000).tz('America/New_York').isDST(); // false
moment(1467345600000).tz('America/New_York').isDST(); // true

, , :

moment.tz('2016-01-01T00:00:00','America/New_York').isDST(); // false
moment.tz('2016-07-01T00:00:00','America/New_York').isDST(); // true
+2

-, ? , , DST, , timezone_offset ?

UTC . , () :

var d = new Date(ts + timezone_offset);
d.getUTCMonth();
d.getUTCDate();

, DST?

. / DST, - http://en.wikipedia.org/wiki/Daylight_saving_time_by_country, .

, , , , , . .

0

moment.js(http://momentjs.com/) isDST. ( ) , .

moment(your_date).isDST();
0

All Articles