@@ -145,7 +145,7 @@ if (!Number.prototype.map) {
145145( function ( $ , undefined ) {
146146
147147 $ . clock = {
148- "version" : "2.3.35 " ,
148+ "version" : "2.3.4 " ,
149149 "options" : [
150150 {
151151 "type" : "string" ,
@@ -284,23 +284,19 @@ if (!Number.prototype.map) {
284284
285285 //since system time and timezones affect the Date object, let's make sure it's not going to affect our clock:
286286 var currentTzOffset = new Date ( ) . getTimezoneOffset ( ) ;
287- var correction = 0 ;
288- if ( currentTzOffset != myoptions . tzOffset ) {
289- correction = ( currentTzOffset * 60 * 1000 ) - ( myoptions . tzOffset * 60 * 1000 ) ;
290- }
291- //var mytimestamp = new Date().getTime() + myoptions.sysdiff;
292- var mytimestamp = performance . timing . navigationStart + performance . now ( ) + myoptions . sysdiff + correction ;
287+ var correction = ( currentTzOffset === myoptions . tzOffset ) ? 0 : ( currentTzOffset - myoptions . tzOffset ) * 60 * 1000 ;
288+
289+ var pfnow = performance . now ( ) ;
290+ //get our new timestamp with all the timezone offsets and corrections !!!
291+ //corrected and re-corrected !!!
292+ var mytimestamp = performance . timing . navigationStart + pfnow + myoptions . sysdiff + correction ;
293293
294294 var mytimestamp_sysdiff = new Date ( mytimestamp ) ;
295- /*
296- var rmn = myoptions.tzOffset % 60;
297- var hrs = ((myoptions.tzOffset - rmn) / 60) * -1;
298- var mns = rmn * -1;
299- */
300295 var h = mytimestamp_sysdiff . getHours ( ) ,
301296 m = mytimestamp_sysdiff . getMinutes ( ) ,
302297 s = mytimestamp_sysdiff . getSeconds ( ) ,
303298 ms = mytimestamp_sysdiff . getMilliseconds ( ) ,
299+ us = ( '' + ( pfnow % 1 ) ) . substring ( 2 , 5 ) ,
304300 dy = mytimestamp_sysdiff . getDay ( ) ,
305301 dt = mytimestamp_sysdiff . getDate ( ) ,
306302 mo = mytimestamp_sysdiff . getMonth ( ) ,
@@ -316,28 +312,6 @@ if (!Number.prototype.map) {
316312 ap = "AM" ,
317313 calendElem = "" ,
318314 clockElem = "" ;
319- /*
320- //we had to get UTC values from the Date object to avoid system changes affecting the clock
321- //but now we have to correct the values with the original timezoneoffset
322- if(m+mns > 60){
323- h = h+hrs+1;
324- m = (m+mns-60);
325- }
326- else{
327- h = h+hrs;
328- m = m+mns;
329- }
330- if(h > 23){
331- h -= 12;
332- dt++;
333- dy++;
334- }
335- else if(h < 0){
336- h += 12;
337- dt--;
338- dt--;
339- }
340- */
341315 if ( h > 11 ) { ap = "PM" ; }
342316 var H12 = h ;
343317 if ( H12 > 12 ) { H12 = H12 - 12 ; }
@@ -468,9 +442,9 @@ if (!Number.prototype.map) {
468442 case "s" : //Seconds, with leading zeros
469443 timeStr += ( '' + s ) . padStart ( 2 , "0" ) ;
470444 break ;
471- /* case "u": //Microseconds
472- timeStr += microseconds...
473- break; */
445+ case "u" : //Microseconds
446+ timeStr += us ;
447+ break ;
474448 case "v" : //Milliseconds
475449 timeStr += ( '' + ms ) . padStart ( 3 , "0" ) ;
476450 break ;
0 commit comments