diff --git a/jqClock.js b/jqClock.js index bcbcbb9..953057c 100644 --- a/jqClock.js +++ b/jqClock.js @@ -420,7 +420,7 @@ if (!Number.prototype.map) { : "+00" ) + ":00", //Timezone abbreviation - "T": ( clk ) => new Intl.DateTimeFormat( clk.myoptions.locale, { + "T": ( clk ) => /(UTC|GMT)\+/.test( clk.myoptions.timezone ) ? clk.myoptions.timezone : new Intl.DateTimeFormat( clk.myoptions.locale, { timeZone: clk.myoptions.timezone, timeZoneName: "short" } ).formatToParts( clk.mytimestamp_sysdiff ).filter(e => e.type === 'timeZoneName')[0].value, diff --git a/jqClock.min.js b/jqClock.min.js index 6a62b00..b0e2d6f 100644 --- a/jqClock.min.js +++ b/jqClock.min.js @@ -11,8 +11,8 @@ type:"Boolean",values:[!0,!1]},{name:"rate",description:"Defines the rate at whi Object.freeze(d.clock);let g={};d.fn.clock=function(e){let k=this;this.initialize=()=>k;this.destroy=()=>k.each((a,b)=>{m.destroy(b)});this.stop=()=>k.each((a,b)=>{m.stop(b)});this.start=()=>k.each((a,b)=>{m.start(b)});const l=a=>"[object Object]"===Object.prototype.toString.call(a),r={d:a=>(""+a.dt).padStart(2,"0"),D:a=>(new Intl.DateTimeFormat(a.myoptions.locale,{weekday:"short"})).format(a.mytimestamp_sysdiff),j:a=>a.dt,l:a=>(new Intl.DateTimeFormat(a.myoptions.locale,{weekday:"long"})).format(a.mytimestamp_sysdiff), N:a=>0===a.dy?7:a.dy,S:a=>{a=a.dt;return 1===a||1===a%10&&11!==a?"st":2===a||2===a%10&&12!==a?"nd":3===a||3===a%10&&13!==a?"rd":"th"},w:a=>a.dy,z:a=>a.doy-1,W:a=>a.woy,F:a=>(new Intl.DateTimeFormat(a.myoptions.locale,{month:"long"})).format(a.mytimestamp_sysdiff),m:a=>(a.mo+1+"").padStart(2,"0"),M:a=>(new Intl.DateTimeFormat(a.myoptions.locale,{month:"short"})).format(a.mytimestamp_sysdiff),n:a=>a.mo+1,t:a=>a.dim,L:a=>a.ly?1:0,o:a=>a.iso8601Year,Y:a=>a.y,y:a=>a.y.toString().substr(2,2)},t={a:a=>a.ap.toLowerCase(), A:a=>a.ap,B:a=>a.swt,g:a=>a.H12,G:a=>a.h,h:a=>(""+a.H12).padStart(2,"0"),H:a=>(""+a.h).padStart(2,"0"),i:a=>(""+a.m).padStart(2,"0"),s:a=>(""+a.s).padStart(2,"0"),u:a=>(""+a.ms).padStart(3,"0")+(""+a.us).padStart(3,"0"),v:a=>(""+a.ms).padStart(3,"0"),e:a=>a.myoptions.timezone,I:a=>a.myoptions.isDST?"DST":"",O:a=>(0>a.tzH?"+"+(""+Math.abs(a.tzH)).padStart(2,"0"):0(0>a.tzH?"+"+(""+Math.abs(a.tzH)).padStart(2,"0"):0(new Intl.DateTimeFormat(a.myoptions.locale,{timeZone:a.myoptions.timezone,timeZoneName:"short"})).formatToParts(a.mytimestamp_sysdiff).filter(b=>"timeZoneName"===b.type)[0].value,Z:a=>0>a.tzS?""+Math.abs(a.tzS):0a.y+"-"+(a.mo+1+"").padStart(2,"0")+"-"+(""+a.dt).padStart(2,"0")+"T"+(""+a.h).padStart(2,"0")+":"+(""+a.m).padStart(2,"0")+":"+(""+a.s).padStart(2,"0")+(0>a.tzH?"+"+(""+Math.abs(a.tzH)).padStart(2,"0"):0(new Intl.DateTimeFormat(a.myoptions.locale,{weekday:"short"})).format(a.mytimestamp_sysdiff)+", "+a.dt+" "+(new Intl.DateTimeFormat(a.myoptions.locale,{month:"short"})).format(a.mytimestamp_sysdiff)+" "+a.y+" "+(""+a.h).padStart(2,"0")+":"+(""+a.m).padStart(2,"0")+":"+(""+a.s).padStart(2,"0")+" "+(0>a.tzH?"+"+(""+Math.abs(a.tzH)).padStart(2,"0"):0Math.floor(a.mytimestamp/1E3)},n="calendar numberingSystem weekday era year month day dateStyle".split(" "), +"0"):"+00")+":00",T:a=>/(UTC|GMT)\+/.test(a.myoptions.timezone)?a.myoptions.timezone:(new Intl.DateTimeFormat(a.myoptions.locale,{timeZone:a.myoptions.timezone,timeZoneName:"short"})).formatToParts(a.mytimestamp_sysdiff).filter(b=>"timeZoneName"===b.type)[0].value,Z:a=>0>a.tzS?""+Math.abs(a.tzS):0a.y+"-"+(a.mo+1+"").padStart(2,"0")+"-"+(""+a.dt).padStart(2,"0")+"T"+(""+a.h).padStart(2,"0")+":"+(""+a.m).padStart(2,"0")+":"+(""+a.s).padStart(2,"0")+(0>a.tzH?"+"+(""+Math.abs(a.tzH)).padStart(2, +"0"):0(new Intl.DateTimeFormat(a.myoptions.locale,{weekday:"short"})).format(a.mytimestamp_sysdiff)+", "+a.dt+" "+(new Intl.DateTimeFormat(a.myoptions.locale,{month:"short"})).format(a.mytimestamp_sysdiff)+" "+a.y+" "+(""+a.h).padStart(2,"0")+":"+(""+a.m).padStart(2,"0")+":"+(""+a.s).padStart(2,"0")+" "+(0>a.tzH?"+"+(""+Math.abs(a.tzH)).padStart(2,"0"):0Math.floor(a.mytimestamp/1E3)},n="calendar numberingSystem weekday era year month day dateStyle".split(" "), p="numberingSystem hour12 hourCycle timeZone timeZoneName hour minute second fractionalSecondDigits dayPeriod timeStyle".split(" "),m={destroy:a=>{let b=d(a).attr("id");g.hasOwnProperty(b)&&(clearTimeout(g[b]),delete g[b]);d(a).html("");d(a).hasClass("jqclock")&&d(a).removeClass("jqclock");d(a).removeData("clockoptions")},stop:a=>{a=d(a).attr("id");g.hasOwnProperty(a)&&(clearTimeout(g[a]),delete g[a])},start:a=>{let b=d(a).attr("id"),c=d(a).data("clockoptions");void 0!==c&&!1===g.hasOwnProperty(b)&& (g[b]=setTimeout(()=>{q(a)},c.rate))}},w=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const b=16*Math.random()|0;return("x"===a?b:b&3|8).toString(16)}).toUpperCase(),q=a=>{let b={};b.myoptions=d(a).data("clockoptions");b.currentTzOffset=(new Date).getTimezoneOffset();b.correction=b.currentTzOffset===b.myoptions.tzOffset?0:6E4*(b.currentTzOffset-b.myoptions.tzOffset);b.pfnow=performance.now();b.mytimestamp=performance.timeOrigin+b.pfnow+b.myoptions.sysdiff+b.correction;b.mytimestamp_sysdiff= new Date(b.mytimestamp);b.h=b.mytimestamp_sysdiff.getHours();b.m=b.mytimestamp_sysdiff.getMinutes();b.s=b.mytimestamp_sysdiff.getSeconds();b.ms=b.mytimestamp_sysdiff.getMilliseconds();b.us=(""+b.pfnow%1).substring(2,5);b.dy=b.mytimestamp_sysdiff.getDay();b.dt=b.mytimestamp_sysdiff.getDate();b.mo=b.mytimestamp_sysdiff.getMonth();b.y=b.mytimestamp_sysdiff.getFullYear();b.ly=b.mytimestamp_sysdiff.isLeapYear();b.doy=b.mytimestamp_sysdiff.getDOY();b.woy=b.mytimestamp_sysdiff.getWOY();b.iso8601Year=b.mytimestamp_sysdiff.getWOY(!0);