window.onload = function () {
var exp = new Date();
var gmtHours = -(exp.getTimezoneOffset()/60);
setCookie( 'customer_timezone' ,gmtHours,1);
date = exp.format( 'yyyy-MM-dd HH:mm:ss' );
if (inDaylightTime(date)){
setCookie( 'inDaylightTime' ,1,1);
}
}
function setCookie(c_name,value,expiredays){
var exdate= new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+
((expiredays== null ) ? "" : "; expires=" +exdate.toGMTString())
}
function isEastEarthTime(newDate)
{
var dj= newDate.getGMTOffset( false );
if (dj.indexOf( "-" ) == -1){
return true ;
} else {
return false ;
}
}
function inDaylightTime(date){
var start = new Date(date.getTime());
start.setMonth(0);
start.setDate(1);
start.setHours(0);
start.setMinutes(0);
start.setSeconds(0);
var middle = new Date(start.getTime());
middle.setMonth(6);
if ((middle.getTimezoneOffset() - start.getTimezoneOffset()) == 0)
{
return false ;
}
var margin = 0;
if ( this .isEastEarthTime(date)) {
margin = middle.getTimezoneOffset();
} else {
margin = start.getTimezoneOffset();
}
if (date.getTimezoneOffset() == margin) {
return true ;
}
return false ;
}
|