| Is it Daylight Savings Time? |
| Kevin Tipa posted at Friday, October 30, 2009 2:29 PM |
|
I recently went through trying to find a way to know for sure if a given javascript Date object had a value that was in daylight savings time or standard time. I found lots of posts online about finding out the dates for when it occurs, but not one post about finding out if the value in the Date object is in DST or not. Took me longer than it should have (probably), but I figured out a couple things, and so I'm sharing them here. I apologize if I'm not supposed to link to other sites, but if you're interested in what I figured out...
I hope that helps if anyone else searches for info on daylight savings time in javascript.
- Kevin |
| Reply Reply Using Power Editor |
| Kevin is a software engineer working primarily in C#.Net with winforms apps, but has experience with various web technologies including ASP, ASP.Net, PHP, Ajax, Javascript, CSS, DHTML. In addition he has some experience with several versions of MS SQL and mySQL.
Kevin lives and works in New England (North East United States) |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
|
| javascript |
Jack jack provided a rated reply to Kevin Tipa on Monday, November 09, 2009 3:58 AM |
|
Date.prototype.stdTimezoneOffset = function() { var jan = new Date(this.getFullYear(), 0, 1); var jul = new Date(this.getFullYear(), 6, 1); return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); }
Date.prototype.dst = function() { return this.getTimezoneOffset() < this.stdTimezoneOffset(); }
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
16 |
$0.00 |
19 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| interesting... |
| Kevin Tipa replied to Jack jack on Monday, November 09, 2009 9:11 AM |
|
Interesting... and you went the extra step to make them extension methods. Nice. |
| Reply Reply Using Power Editor |
| Kevin is a software engineer working primarily in C#.Net with winforms apps, but has experience with various web technologies including ASP, ASP.Net, PHP, Ajax, Javascript, CSS, DHTML. In addition he has some experience with several versions of MS SQL and mySQL.
Kevin lives and works in New England (North East United States) |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
|
|