User:Aiiane/Sandbox/PSTime

From Guild Wars Wiki
Jump to navigationJump to search

<script language="JavaScript">

function tS(){ x=new Date(tN().getUTCFullYear(),tN().getUTCMonth(),tN().getUTCDate(),tN().getUTCHours(),tN().getUTCMinutes(),tN().getUTCSeconds()); x.setTime(x.getTime()+dS()-28800000); return x; } function tN(){ return new Date(); } function dS(){ return ((tN().getTime()>fD(0,2,3,2).getTime())&&(tN().getTime()<fD(0,10,3,1).getTime()))?3600000:0; } function fD(d,m,h,p){ var week=(p<0)?7*(p+1):7*(p-1),nm=(p<0)?m+1:m,x=new Date(tN().getUTCFullYear(),nm,1,h,0,0),dOff=0; if(p<0){ x.setTime(x.getTime()-86400000); } if(x.getDay()!=d){ dOff=(x.getDay()<d)?(d-x.getDay()):0-(x.getDay()-d); if(p<0&&dOff>0){ week-=7; } if(p>0&&dOff<0){ week+=7; } x.setTime(x.getTime()+((dOff+week)*86400000)); } return x; } function lZ(x){ return (x>9)?x:'0'+x; } function tH(x){ if(x==0){ x=12; } return (x>12)?x-=12:x; } function dE(x){ if(x==1||x==21||x==31){ return 'st'; } if(x==2||x==22){ return 'nd'; } if(x==3||x==23){ return 'rd'; } return 'th'; } function dT(){ if(fr==0){ fr=1; document.write(''+eval(oT)+''); } document.getElementById('tP').innerHTML=eval(oT); setTimeout('dT()',1000); } function aP(x){ return (x>11)?'pm':'am'; } var mN=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'),fr=0,oT="tS().getDate()+dE(tS().getDate())+' '+mN[tS().getMonth()]+' '+':'+':'+' '+tH(tS().getHours())+':'+lZ(tS().getMinutes())+':'+lZ(tS().getSeconds())+' '+aP(tS().getHours())";

dT();</script>