Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

WebArticlesForumsFAQs
JavaScript
ASP
ASP.NET
WCF

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

Operating SysArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Lounge
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

  View Other JavaScript Posts   Ask New Question  Ask New Question With Power Editor

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