check for DST in NY; close #376

This commit is contained in:
James Campos 2011-11-07 21:41:14 -08:00
parent 19da9155c9
commit 21dc16ef86
2 changed files with 33 additions and 24 deletions

View File

@ -412,27 +412,32 @@
}, },
isDST: function() { isDST: function() {
/* /*
http://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States http://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States
Since 2007, daylight saving time starts on the second Sunday of March Since 2007, daylight saving time starts on the second Sunday of March
and ends on the first Sunday of November, with all time changes taking and ends on the first Sunday of November, with all time changes taking
place at 2:00 AM (0200) local time. place at 2:00 AM (0200) local time.
0200 EST (UTC -5) = 0700 UTC
*/ */
var date, month, sunday; var D, date, day, hours, month, sunday;
date = new Date(); D = new Date();
month = date.getMonth(); date = D.getUTCDate();
day = D.getUTCDay();
hours = D.getUTCHours();
month = D.getUTCMonth();
if (month < 2 || 10 < month) { if (month < 2 || 10 < month) {
return false; return false;
} }
if ((2 < month && month < 10)) { if ((2 < month && month < 10)) {
return true; return true;
} }
sunday = date.getDate() - date.getDay(); sunday = date - day;
if (month === 2) { if (month === 2) {
if (sunday < 8) { if (sunday < 8) {
return false; return false;
} }
if (sunday < 15 && date.getDay() === 0) { if (sunday < 15 && day === 0) {
if (date.getHours() < 1) { if (hours < 7) {
return false; return false;
} }
return true; return true;
@ -442,8 +447,8 @@
if (sunday < 1) { if (sunday < 1) {
return true; return true;
} }
if (sunday < 8 && date.getDay() === 0) { if (sunday < 8 && day === 0) {
if (date.getHours() < 1) { if (hours < 7) {
return true; return true;
} }
return false; return false;

View File

@ -284,16 +284,20 @@ $.extend $,
off: (el, eventType, handler) -> off: (el, eventType, handler) ->
el.removeEventListener eventType, handler, false el.removeEventListener eventType, handler, false
isDST: -> isDST: ->
# XXX this should check for DST in NY
### ###
http://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States http://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States
Since 2007, daylight saving time starts on the second Sunday of March Since 2007, daylight saving time starts on the second Sunday of March
and ends on the first Sunday of November, with all time changes taking and ends on the first Sunday of November, with all time changes taking
place at 2:00 AM (0200) local time. place at 2:00 AM (0200) local time.
0200 EST (UTC -5) = 0700 UTC
### ###
date = new Date() D = new Date()
month = date.getMonth() date = D.getUTCDate()
day = D.getUTCDay()
hours = D.getUTCHours()
month = D.getUTCMonth()
#this is the easy part #this is the easy part
if month < 2 or 10 < month if month < 2 or 10 < month
@ -303,7 +307,7 @@ $.extend $,
# (sunday's date) = (today's date) - (number of days past sunday) # (sunday's date) = (today's date) - (number of days past sunday)
# date is not zero-indexed # date is not zero-indexed
sunday = date.getDate() - date.getDay() sunday = date - day
if month is 2 if month is 2
#before second sunday #before second sunday
@ -311,8 +315,8 @@ $.extend $,
return false return false
#during second sunday #during second sunday
if sunday < 15 and date.getDay() is 0 if sunday < 15 and day is 0
if date.getHours() < 1 if hours < 7
return false return false
return true return true
@ -325,8 +329,8 @@ $.extend $,
return true return true
# during first sunday # during first sunday
if sunday < 8 and date.getDay() is 0 if sunday < 8 and day is 0
if date.getHours() < 1 if hours < 7
return true return true
return false return false