Daylight Savings Time is a vexed issue to compute for the world:
- different countries in the same hemisphere start/end a summer offset on different days ...
- summer in the Southern hemisphere is winter in the Northern hemisphere
- confusion abounds since the globe usually has 2 dates simultaneously - on boundary days any one can be in or out of daylight savings
- some areas are on double daylight (or soon will switch to it)
You do not need to worry about the above ... but bear it in mind before you try some exotic "world global time zone" programming.
IGNORING the issues above... The following Javascript code gives some idea of what can be done to detect daylight Savings PC's versus those not on Daylighht Savings.
<html>
<p>
<script language="javascript">
var ww = new Date();
var xx = new Date();
var yy = new Date();
var tt = ww.getTimezoneOffset();
var gg = xx.getUTCHours();
var mm = xx.getUTCMinutes();
var ll = yy.toLocaleString() ;
var aa = xx.getHours();
var bb = xx.getMinutes();
var actualdiff = (gg-aa)*60+(mm-bb);
document.write('<p>');
document.write('Time Zone Offset(mins.) ='+tt+' UTC='+gg+':'+mm);
document.write('<p>');
document.write('Actual Offset Diff(mins.)='+actualdiff+' Local='+aa+':'+bb);
var insyncwithGMT = 0 ;
if (actualdiff==tt)
{
document.write('<p>Same Offset Means Same Daylight Shift as British GMT');
insyncwithGMT = 1 ;
}
var dtoday = new Date() ;
var dnweekday = dtoday.getDay() ; // day of week 0..6
var dnmonth = dtoday.getMonth() ; // month of year 0..11
var dndaymon = dtoday.getDate() ; // day of month 0..31
var dnyear = dtoday.getFullYear() ; // year e.g. 2009
var tdiff=999;
var dwkdate = new Date() ;
var springChangeover = new Date() ;
springChangeover.setFullYear(dnyear,2,21) ; // when is march 21
var dnweekday = springChangeover.getDay() ; // day of week 0..6 for march 21
if(dnweekday==0)
{
}
else
{
var tdiff = 7-dnweekday ;
springChangeover.setDate(springChangeover.getDate()+tdiff)
}
var fallChangeover = new Date() ;
fallChangeover.setFullYear(dnyear,9,23) ; // when is october 23
var dnweekday = fallChangeover.getDay() ; // day of week 0..6 for october 23
if(dnweekday==0)
{
}
else
{
var tdiff = 7-dnweekday ;
fallChangeover.setDate(fallChangeover.getDate()+tdiff)
}
var DTmsg = 'British Summer Time from ' +(''+springChangeover).substring(0,10) + ' to ' +(''+fallChangeover).substring(0,10)+ ' - ' ;
//
// are we in summer in the N. hemisphere
//
var inNHSummer = 1 ;
if (dtoday>=fallChangeover)
{
inNHSummer= 0 ;
}
else {
if (dtoday<springChangeover)
{ inNHSummer= 0 ; }
}
document.write('<p>'+DTmsg) ;
if (inNHSummer==1) { document.write('<p>British Summer Time is In Effect Now') ; }
if( (inNHSummer==1)&&(insyncwithGMT = 1) )
{ document.write('<p>Local machine is in Daylight Savings Time') ; }
</script>