IT Community - Software Programming, Web Development and Technical Support

How can I tell when Daylight Saving is in effect?

This is a discussion on How can I tell when Daylight Saving is in effect? within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi all... Can anyone tell me How can I tell when Daylight Saving is in effect. Thanks......


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 01-01-2008, 08:39 PM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Default How can I tell when Daylight Saving is in effect?

Hi all...

Can anyone tell me How can I tell when Daylight Saving is in effect.

Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-01-2008, 08:40 PM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default Re: How can I tell when Daylight Saving is in effect?

Hi all...


<SCRIPT LANGUAGE="JavaScript">
function makeArray() {
this[0] = makeArray.arguments.length;
for (i = 0; i<makeArray.arguments.length; i++)
this[i+1] = makeArray.arguments[i];
}

var daysofmonth = new makeArray( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var daysofmonthLY = new makeArray( 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

function LeapYear(year) {
if ((year/4) != Math.floor(year/4)) return false;
if ((year/100) != Math.floor(year/100)) return true;
if ((year/400) != Math.floor(year/400)) return false;
return true;
}

function NthDay(nth,weekday,month,year) {
if (nth > 0) return (nth-1)*7 + 1 + (7 + weekday -
DayOfWeek((nth-1)*7 + 1,month,year))%7;
if (LeapYear(year)) var days = daysofmonthLY[month];
else var days = daysofmonth[month];
return days - (DayOfWeek(days,month,year) - weekday + 7)%7;
}

function DayOfWeek(day,month,year) {
var a = Math.floor((14 - month)/12);
var y = year - a;
var m = month + 12*a - 2;
var d = (day + y + Math.floor(y/4) - Math.floor(y/100) +
Math.floor(y/400) + Math.floor((31*m)/12)) % 7;
return d+1;
}

function y2k(number) { return (number < 1000) ? number + 1900 : number; }

var today = new Date();
var year = y2k(today.getYear());

var DSTstart = new Date(year,4-1,NthDay(1,1,4,year),2,0,0);
var DSTend = new Date(year,10-1,NthDay(-1,1,10,year),2,0,0);

function getMS(date) {
return
Date.UTC(y2k(date.getYear()),date.getMonth(),date. getDate(),date.getHours(),date.getMinutes(),date.g etSeconds())
}

var todayMS = getMS(today);
var DSTstartMS = getMS(DSTstart);
var DSTendMS = getMS(DSTend);

if (todayMS > DSTstartMS && todayMS < DSTendMS)
document.write('Daylight Saving within effect');
else
document.write('Daylght Saving NOT within effect');
</SCRIPT>

Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
tint effect nssukumar Flash Actionscript Programming 1 02-26-2008 10:05 PM
Database space-saving functions available in php vigneshgets PHP Programming 1 01-18-2008 04:20 AM
Magnifying Glass Effect aramesh Flash Actionscript Programming 0 12-12-2007 10:32 PM
How to encrypt the passwords before saving to database in c#? itbarota C# Programming 1 07-26-2007 12:19 AM
Taking Snapshot and saving image clipping in flash oxygen Flash Actionscript Programming 0 07-17-2007 12:12 AM


All times are GMT -7. The time now is 12:15 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0