Window. onload = function (){ // TODO begin processes the time zone of the login user // Obtain the difference between the time zone of the login user and the GMT time zone Var exp = new Date (); Var gmtHours =-(exp. getTimezoneOffset ()/60 ); SetCookie ('customer _ timezone ', gmtHours, 1 ); // When determining whether it is seeking Date = exp. format ('yyyy-MM-dd HH: mm: SS '); If (inDaylightTime (date )){ SetCookie ('daylighttime', 1, 1 ); } } // Set Cookie 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 ()) } // Determine whether the time is the eastern hemisphere or the Western Hemisphere Function iseasteartime (newDate) { Var dj = newDate. getGMTOffset (false ); If (dj. indexOf ("-") =-1 ){ Return true; } Else { Return false; } } // Whether it is enabled 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 the time difference is the same from the beginning of the year and the middle of the year, it is deemed that there is no renewal time in this country If (middle. getTimezoneOffset ()-start. getTimezoneOffset () = 0) { Return false; } Var margin = 0; If (this. iseastearthur time (date )){ Margin = middle. getTimezoneOffset (); } Else { Margin = start. getTimezoneOffset (); } If (date. getTimezoneOffset () = margin ){ Return true; } Return false; } // DONE end |