From d54f57a81207b2eb23eb8e5a39c1a055a6a51cc7 Mon Sep 17 00:00:00 2001 From: gregor herrmann Date: Mon, 3 Sep 2018 17:53:02 +0200 Subject: [PATCH] add strftime library version v0.10.0 from https://github.com/samsonjs/strftime --- web/static/strftime-min.js | 23 ++ web/static/strftime.js | 818 +++++++++++++++++++++++++++++++++++++ 2 files changed, 841 insertions(+) create mode 100644 web/static/strftime-min.js create mode 100644 web/static/strftime.js diff --git a/web/static/strftime-min.js b/web/static/strftime-min.js new file mode 100644 index 0000000..91c3c0d --- /dev/null +++ b/web/static/strftime-min.js @@ -0,0 +1,23 @@ +(function(){function q(c,g,n){function i(c,a,e,f){for(var b="",d=null,g=!1,l=c.length,n=!1,j=0;j99?Math.floor(f%1E3):Math.floor(f%1E3)>9?"0"+Math.floor(f%1E3):"00"+Math.floor(f%1E3);break;case 77:b+=h(a.getMinutes(),d);break;case 80:b+=a.getHours()<12?e.am:e.pm;break;case 82:b+=i(e.formats.R,a,e,f);break;case 83:b+=h(a.getSeconds(),d);break;case 84:b+=i(e.formats.T,a,e,f);break;case 85:b+=h(v(a,"sunday"),d);break;case 87:b+=h(v(a,"monday"),d);break;case 88:b+=i(e.formats.X, +a,e,f);break;case 89:b+=a.getFullYear();break;case 90:o&&k===0?b+="GMT":(d=a.toString().match(/\(([\w\s]+)\)/),b+=d&&d[1]||"");break;case 97:b+=e.shortDays[a.getDay()];break;case 98:b+=e.shortMonths[a.getMonth()];break;case 99:b+=i(e.formats.c,a,e,f);break;case 100:b+=h(a.getDate(),d);break;case 101:b+=h(a.getDate(),d==null?" ":d);break;case 104:b+=e.shortMonths[a.getMonth()];break;case 106:d=new Date(a.getFullYear(),0,1);d=Math.ceil((a.getTime()-d.getTime())/864E5);b+=d>99?d:d>9?"0"+d:"00"+d;break; +case 107:b+=h(a.getHours(),d==null?" ":d);break;case 108:b+=h(u(a.getHours()),d==null?" ":d);break;case 109:b+=h(a.getMonth()+1,d);break;case 110:b+="\n";break;case 111:d=a.getDate();b+=e.ordinalSuffixes?String(d)+(e.ordinalSuffixes[d-1]||w(d)):String(d)+w(d);break;case 112:b+=a.getHours()<12?e.AM:e.PM;break;case 114:b+=i(e.formats.r,a,e,f);break;case 115:b+=Math.floor(f/1E3);break;case 116:b+="\t";break;case 117:d=a.getDay();b+=d===0?7:d;break;case 118:b+=i(e.formats.v,a,e,f);break;case 119:b+=a.getDay(); +break;case 120:b+=i(e.formats.x,a,e,f);break;case 121:b+=(""+a.getFullYear()).slice(2);break;case 122:o&&k===0?b+=n?"+00:00":"+0000":(d=k!==0?k/6E4:-a.getTimezoneOffset(),g=n?":":"",m=Math.abs(d%60),b+=(d<0?"-":"+")+h(Math.floor(Math.abs(d/60)))+g+h(m));break;default:g&&(b+="%"),b+=c[j]}d=null;g=!1}else m===37?g=!0:b+=c[j]}return b}var j=c||x,k=g||0,o=n||!1,p=0,r,l=function(c,a){var e;if(a){if(e=a.getTime(),o){var f=(a.getTimezoneOffset()||0)*6E4,a=new Date(e+f+k);if((a.getTimezoneOffset()||0)*6E4!== +f)f=(a.getTimezoneOffset()||0)*6E4,a=new Date(e+f+k)}}else e=Date.now(),e>p?(p=e,r=new Date(p),e=p,o&&(r=new Date(p+(r.getTimezoneOffset()||0)*6E4+k))):e=p,a=r;return i(c,a,j,e)};l.localize=function(c){return new q(c||j,k,o)};l.localizeByIdentifier=function(c){var a=y[c];return!a?(t('[WARNING] No locale found with identifier "'+c+'".'),l):l.localize(a)};l.timezone=function(c){var a=k,e=o,f=typeof c;if(f==="number"||f==="string")e=!0,f==="string"?(a=c[0]==="-"?-1:1,f=parseInt(c.slice(1,3),10),c=parseInt(c.slice(3, +5),10),a=a*(60*f+c)*6E4):f==="number"&&(a=c*6E4);return new q(j,a,e)};l.utc=function(){return new q(j,k,!0)};return l}function h(c,g){if(g===""||c>9)return c;g==null&&(g="0");return g+c}function u(c){if(c===0)return 12;else if(c>12)return c-12;return c}function v(c,g){var g=g||"sunday",h=c.getDay();g==="monday"&&(h===0?h=6:h--);var i=Date.UTC(c.getFullYear(),0,1),j=Date.UTC(c.getFullYear(),c.getMonth(),c.getDate());return Math.floor((Math.floor((j-i)/864E5)+7-h)/7)}function w(c){var g=c%10;c%=100; +if(c>=11&&c<=13||g===0||g>=4)return"th";switch(g){case 1:return"st";case 2:return"nd";case 3:return"rd"}}function t(c){typeof console!=="undefined"&&typeof console.warn=="function"&&console.warn(c)}var y={de_DE:{days:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],shortDays:["So","Mo","Di","Mi","Do","Fr","Sa"],months:["Januar","Februar","M\u00e4rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],shortMonths:["Jan","Feb","M\u00e4r","Apr", +"Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z",D:"%d.%m.%Y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},en_CA:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr", +"May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ordinalSuffixes:["st","nd","rd","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","st","nd","rd","th","th","th","th","th","th","th","st"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z",D:"%d/%m/%y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%r",x:"%D"}},en_US:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu", +"Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ordinalSuffixes:["st","nd","rd","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","st","nd","rd","th","th","th","th","th","th","th","st"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z",D:"%m/%d/%y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p", +T:"%H:%M:%S",v:"%e-%b-%Y",X:"%r",x:"%D"}},es_MX:{days:["domingo","lunes","martes","mi\u00e9rcoles","jueves","viernes","s\u00e1bado"],shortDays:["dom","lun","mar","mi\u00e9","jue","vie","s\u00e1b"],months:["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre"," diciembre"],shortMonths:["ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z",D:"%d/%m/%Y",F:"%Y-%m-%d",R:"%H:%M", +r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},fr_FR:{days:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"],shortDays:["dim.","lun.","mar.","mer.","jeu.","ven.","sam."],months:["janvier","f\u00e9vrier","mars","avril","mai","juin","juillet","ao\u00fbt","septembre","octobre","novembre","d\u00e9cembre"],shortMonths:["janv.","f\u00e9vr.","mars","avril","mai","juin","juil.","ao\u00fbt","sept.","oct.","nov.","d\u00e9c."],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z", +D:"%d/%m/%Y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},it_IT:{days:["domenica","luned\u00ec","marted\u00ec","mercoled\u00ec","gioved\u00ec","venerd\u00ec","sabato"],shortDays:["dom","lun","mar","mer","gio","ven","sab"],months:["gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre"],shortMonths:["pr","mag","giu","lug","ago","set","ott","nov","dic"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z", +D:"%d/%m/%Y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},nl_NL:{days:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"],shortDays:["zo","ma","di","wo","do","vr","za"],months:["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"],shortMonths:["jan","feb","mrt","apr","mei","jun","jul","aug","sep","okt","nov","dec"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z",D:"%d-%m-%y", +F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},pt_BR:{days:["domingo","segunda","ter\u00e7a","quarta","quinta","sexta","s\u00e1bado"],shortDays:["Dom","Seg","Ter","Qua","Qui","Sex","S\u00e1b"],months:["janeiro","fevereiro","mar\u00e7o","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"],shortMonths:["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z", +D:"%d-%m-%Y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},ru_RU:{days:["\u0412\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435","\u041f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a","\u0412\u0442\u043e\u0440\u043d\u0438\u043a","\u0421\u0440\u0435\u0434\u0430","\u0427\u0435\u0442\u0432\u0435\u0440\u0433","\u041f\u044f\u0442\u043d\u0438\u0446\u0430","\u0421\u0443\u0431\u0431\u043e\u0442\u0430"],shortDays:["\u0412\u0441","\u041f\u043d","\u0412\u0442", +"\u0421\u0440","\u0427\u0442","\u041f\u0442","\u0421\u0431"],months:["\u042f\u043d\u0432\u0430\u0440\u044c","\u0424\u0435\u0432\u0440\u0430\u043b\u044c","\u041c\u0430\u0440\u0442","\u0410\u043f\u0440\u0435\u043b\u044c","\u041c\u0430\u0439","\u0418\u044e\u043d\u044c","\u0418\u044e\u043b\u044c","\u0410\u0432\u0433\u0443\u0441\u0442","\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044c","\u041e\u043a\u0442\u044f\u0431\u0440\u044c","\u041d\u043e\u044f\u0431\u0440\u044c","\u0414\u0435\u043a\u0430\u0431\u0440\u044c"], +shortMonths:["\u044f\u043d\u0432","\u0444\u0435\u0432","\u043c\u0430\u0440","\u0430\u043f\u0440","\u043c\u0430\u0439","\u0438\u044e\u043d","\u0438\u044e\u043b","\u0430\u0432\u0433","\u0441\u0435\u043d","\u043e\u043a\u0442","\u043d\u043e\u044f","\u0434\u0435\u043a"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X",D:"%d.%m.%y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},tr_TR:{days:["Pazar","Pazartesi","Sal\u0131","\u00c7ar\u015famba","Per\u015fembe", +"Cuma","Cumartesi"],shortDays:["Paz","Pzt","Sal","\u00c7r\u015f","Pr\u015f","Cum","Cts"],months:["Ocak","\u015eubat","Mart","Nisan","May\u0131s","Haziran","Temmuz","A\u011fustos","Eyl\u00fcl","Ekim","Kas\u0131m","Aral\u0131k"],shortMonths:["Oca","\u015eub","Mar","Nis","May","Haz","Tem","A\u011fu","Eyl","Eki","Kas","Ara"],AM:"\u00d6\u00d6",PM:"\u00d6S",am:"\u00d6\u00d6",pm:"\u00d6S",formats:{c:"%a %d %b %Y %X %Z",D:"%d-%m-%Y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T", +x:"%D"}},zh_CN:{days:["\u661f\u671f\u65e5","\u661f\u671f\u4e00","\u661f\u671f\u4e8c","\u661f\u671f\u4e09","\u661f\u671f\u56db","\u661f\u671f\u4e94","\u661f\u671f\u516d"],shortDays:["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"],months:["\u4e00\u6708\u4efd","\u4e8c\u6708\u4efd","\u4e09\u6708\u4efd","\u56db\u6708\u4efd","\u4e94\u6708\u4efd","\u516d\u6708\u4efd","\u4e03\u6708\u4efd","\u516b\u6708\u4efd","\u4e5d\u6708\u4efd","\u5341\u6708\u4efd","\u5341\u4e00\u6708\u4efd","\u5341\u4e8c\u6708\u4efd"], +shortMonths:["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"],AM:"\u4e0a\u5348",PM:"\u4e0b\u5348",am:"\u4e0a\u5348",pm:"\u4e0b\u5348",formats:{c:"%a %d %b %Y %X %Z",D:"%d/%m/%y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%r",x:"%D"}}},x=y.en_US,z=new q(x,0,!1),s;typeof module!=="undefined"?s=module.exports=z:(s=function(){return this|| +(0,eval)("this")}(),s.strftime=z);if(typeof Date.now!=="function")Date.now=function(){return+new Date}})(); diff --git a/web/static/strftime.js b/web/static/strftime.js new file mode 100644 index 0000000..34c058f --- /dev/null +++ b/web/static/strftime.js @@ -0,0 +1,818 @@ +// +// strftime +// github.com/samsonjs/strftime +// @_sjs +// +// Copyright 2010 - 2016 Sami Samhuri +// +// MIT License +// http://sjs.mit-license.org +// + +;(function() { + + var Locales = { + de_DE: { + days: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'], + shortDays: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'], + months: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'], + shortMonths: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'], + AM: 'AM', + PM: 'PM', + am: 'am', + pm: 'pm', + formats: { + c: '%a %d %b %Y %X %Z', + D: '%d.%m.%Y', + F: '%Y-%m-%d', + R: '%H:%M', + r: '%I:%M:%S %p', + T: '%H:%M:%S', + v: '%e-%b-%Y', + X: '%T', + x: '%D' + } + }, + + en_CA: { + days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ], + shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], + shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + ordinalSuffixes: [ + 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', + 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', + 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', + 'st' + ], + AM: 'AM', + PM: 'PM', + am: 'am', + pm: 'pm', + formats: { + c: '%a %d %b %Y %X %Z', + D: '%d/%m/%y', + F: '%Y-%m-%d', + R: '%H:%M', + r: '%I:%M:%S %p', + T: '%H:%M:%S', + v: '%e-%b-%Y', + X: '%r', + x: '%D' + } + }, + + en_US: { + days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ], + shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], + shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + ordinalSuffixes: [ + 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', + 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', + 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', + 'st' + ], + AM: 'AM', + PM: 'PM', + am: 'am', + pm: 'pm', + formats: { + c: '%a %d %b %Y %X %Z', + D: '%m/%d/%y', + F: '%Y-%m-%d', + R: '%H:%M', + r: '%I:%M:%S %p', + T: '%H:%M:%S', + v: '%e-%b-%Y', + X: '%r', + x: '%D' + } + }, + + es_MX: { + days: ['domingo', 'lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado'], + shortDays: ['dom', 'lun', 'mar', 'mié', 'jue', 'vie', 'sáb'], + months: ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre',' diciembre'], + shortMonths: ['ene', 'feb', 'mar', 'abr', 'may', 'jun', 'jul', 'ago', 'sep', 'oct', 'nov', 'dic'], + AM: 'AM', + PM: 'PM', + am: 'am', + pm: 'pm', + formats: { + c: '%a %d %b %Y %X %Z', + D: '%d/%m/%Y', + F: '%Y-%m-%d', + R: '%H:%M', + r: '%I:%M:%S %p', + T: '%H:%M:%S', + v: '%e-%b-%Y', + X: '%T', + x: '%D' + } + }, + + fr_FR: { + days: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'], + shortDays: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'], + months: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'], + shortMonths: ['janv.', 'févr.', 'mars', 'avril', 'mai', 'juin', 'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'], + AM: 'AM', + PM: 'PM', + am: 'am', + pm: 'pm', + formats: { + c: '%a %d %b %Y %X %Z', + D: '%d/%m/%Y', + F: '%Y-%m-%d', + R: '%H:%M', + r: '%I:%M:%S %p', + T: '%H:%M:%S', + v: '%e-%b-%Y', + X: '%T', + x: '%D' + } + }, + + it_IT: { + days: ['domenica', 'lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato'], + shortDays: ['dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab'], + months: ['gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre'], + shortMonths: ['pr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic'], + AM: 'AM', + PM: 'PM', + am: 'am', + pm: 'pm', + formats: { + c: '%a %d %b %Y %X %Z', + D: '%d/%m/%Y', + F: '%Y-%m-%d', + R: '%H:%M', + r: '%I:%M:%S %p', + T: '%H:%M:%S', + v: '%e-%b-%Y', + X: '%T', + x: '%D' + } + }, + + nl_NL: { + days: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'], + shortDays: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'], + months: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'], + shortMonths: ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'], + AM: 'AM', + PM: 'PM', + am: 'am', + pm: 'pm', + formats: { + c: '%a %d %b %Y %X %Z', + D: '%d-%m-%y', + F: '%Y-%m-%d', + R: '%H:%M', + r: '%I:%M:%S %p', + T: '%H:%M:%S', + v: '%e-%b-%Y', + X: '%T', + x: '%D' + } + }, + + pt_BR: { + days: ['domingo', 'segunda', 'terça', 'quarta', 'quinta', 'sexta', 'sábado'], + shortDays: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'], + months: ['janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro'], + shortMonths: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'], + AM: 'AM', + PM: 'PM', + am: 'am', + pm: 'pm', + formats: { + c: '%a %d %b %Y %X %Z', + D: '%d-%m-%Y', + F: '%Y-%m-%d', + R: '%H:%M', + r: '%I:%M:%S %p', + T: '%H:%M:%S', + v: '%e-%b-%Y', + X: '%T', + x: '%D' + } + }, + + ru_RU: { + days: ['Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'], + shortDays: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'], + months: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'], + shortMonths: ['янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек'], + AM: 'AM', + PM: 'PM', + am: 'am', + pm: 'pm', + formats: { + c: '%a %d %b %Y %X', + D: '%d.%m.%y', + F: '%Y-%m-%d', + R: '%H:%M', + r: '%I:%M:%S %p', + T: '%H:%M:%S', + v: '%e-%b-%Y', + X: '%T', + x: '%D' + } + }, + + tr_TR: { + days: ['Pazar', 'Pazartesi', 'Salı','Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'], + shortDays: ['Paz', 'Pzt', 'Sal', 'Çrş', 'Prş', 'Cum', 'Cts'], + months: ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'], + shortMonths: ['Oca', 'Şub', 'Mar', 'Nis', 'May', 'Haz', 'Tem', 'Ağu', 'Eyl', 'Eki', 'Kas', 'Ara'], + AM: 'ÖÖ', + PM: 'ÖS', + am: 'ÖÖ', + pm: 'ÖS', + formats: { + c: '%a %d %b %Y %X %Z', + D: '%d-%m-%Y', + F: '%Y-%m-%d', + R: '%H:%M', + r: '%I:%M:%S %p', + T: '%H:%M:%S', + v: '%e-%b-%Y', + X: '%T', + x: '%D' + } + }, + + // By michaeljayt + // https://github.com/michaeljayt/strftime/commit/bcb4c12743811d51e568175aa7bff3fd2a77cef3 + zh_CN: { + days: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'], + shortDays: ['日', '一', '二', '三', '四', '五', '六'], + months: ['一月份', '二月份', '三月份', '四月份', '五月份', '六月份', '七月份', '八月份', '九月份', '十月份', '十一月份', '十二月份'], + shortMonths: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], + AM: '上午', + PM: '下午', + am: '上午', + pm: '下午', + formats: { + c: '%a %d %b %Y %X %Z', + D: '%d/%m/%y', + F: '%Y-%m-%d', + R: '%H:%M', + r: '%I:%M:%S %p', + T: '%H:%M:%S', + v: '%e-%b-%Y', + X: '%r', + x: '%D' + } + } + }; + + var DefaultLocale = Locales['en_US'], + defaultStrftime = new Strftime(DefaultLocale, 0, false), + isCommonJS = typeof module !== 'undefined', + namespace; + + // CommonJS / Node module + if (isCommonJS) { + namespace = module.exports = defaultStrftime; + } + // Browsers and other environments + else { + // Get the global object. Works in ES3, ES5, and ES5 strict mode. + namespace = (function() { return this || (1,eval)('this'); }()); + namespace.strftime = defaultStrftime; + } + + // Polyfill Date.now for old browsers. + if (typeof Date.now !== 'function') { + Date.now = function() { + return +new Date(); + }; + } + + function Strftime(locale, customTimezoneOffset, useUtcTimezone) { + var _locale = locale || DefaultLocale, + _customTimezoneOffset = customTimezoneOffset || 0, + _useUtcBasedDate = useUtcTimezone || false, + + // we store unix timestamp value here to not create new Date() each iteration (each millisecond) + // Date.now() is 2 times faster than new Date() + // while millisecond precise is enough here + // this could be very helpful when strftime triggered a lot of times one by one + _cachedDateTimestamp = 0, + _cachedDate; + + function _strftime(format, date) { + var timestamp; + + if (!date) { + var currentTimestamp = Date.now(); + if (currentTimestamp > _cachedDateTimestamp) { + _cachedDateTimestamp = currentTimestamp; + _cachedDate = new Date(_cachedDateTimestamp); + + timestamp = _cachedDateTimestamp; + + if (_useUtcBasedDate) { + // how to avoid duplication of date instantiation for utc here? + // we tied to getTimezoneOffset of the current date + _cachedDate = new Date(_cachedDateTimestamp + getTimestampToUtcOffsetFor(_cachedDate) + _customTimezoneOffset); + } + } + else { + timestamp = _cachedDateTimestamp; + } + date = _cachedDate; + } + else { + timestamp = date.getTime(); + + if (_useUtcBasedDate) { + var utcOffset = getTimestampToUtcOffsetFor(date); + date = new Date(timestamp + utcOffset + _customTimezoneOffset); + // If we've crossed a DST boundary with this calculation we need to + // adjust the new date accordingly or it will be off by an hour in UTC. + if (getTimestampToUtcOffsetFor(date) !== utcOffset) { + var newUTCOffset = getTimestampToUtcOffsetFor(date); + date = new Date(timestamp + newUTCOffset + _customTimezoneOffset); + } + } + } + + return _processFormat(format, date, _locale, timestamp); + } + + function _processFormat(format, date, locale, timestamp) { + var resultString = '', + padding = null, + isInScope = false, + length = format.length, + extendedTZ = false; + + for (var i = 0; i < length; i++) { + + var currentCharCode = format.charCodeAt(i); + + if (isInScope === true) { + // '-' + if (currentCharCode === 45) { + padding = ''; + continue; + } + // '_' + else if (currentCharCode === 95) { + padding = ' '; + continue; + } + // '0' + else if (currentCharCode === 48) { + padding = '0'; + continue; + } + // ':' + else if (currentCharCode === 58) { + if (extendedTZ) { + warn("[WARNING] detected use of unsupported %:: or %::: modifiers to strftime"); + } + extendedTZ = true; + continue; + } + + switch (currentCharCode) { + + // Examples for new Date(0) in GMT + + // '%' + // case '%': + case 37: + resultString += '%'; + break; + + // 'Thursday' + // case 'A': + case 65: + resultString += locale.days[date.getDay()]; + break; + + // 'January' + // case 'B': + case 66: + resultString += locale.months[date.getMonth()]; + break; + + // '19' + // case 'C': + case 67: + resultString += padTill2(Math.floor(date.getFullYear() / 100), padding); + break; + + // '01/01/70' + // case 'D': + case 68: + resultString += _processFormat(locale.formats.D, date, locale, timestamp); + break; + + // '1970-01-01' + // case 'F': + case 70: + resultString += _processFormat(locale.formats.F, date, locale, timestamp); + break; + + // '00' + // case 'H': + case 72: + resultString += padTill2(date.getHours(), padding); + break; + + // '12' + // case 'I': + case 73: + resultString += padTill2(hours12(date.getHours()), padding); + break; + + // '000' + // case 'L': + case 76: + resultString += padTill3(Math.floor(timestamp % 1000)); + break; + + // '00' + // case 'M': + case 77: + resultString += padTill2(date.getMinutes(), padding); + break; + + // 'am' + // case 'P': + case 80: + resultString += date.getHours() < 12 ? locale.am : locale.pm; + break; + + // '00:00' + // case 'R': + case 82: + resultString += _processFormat(locale.formats.R, date, locale, timestamp); + break; + + // '00' + // case 'S': + case 83: + resultString += padTill2(date.getSeconds(), padding); + break; + + // '00:00:00' + // case 'T': + case 84: + resultString += _processFormat(locale.formats.T, date, locale, timestamp); + break; + + // '00' + // case 'U': + case 85: + resultString += padTill2(weekNumber(date, 'sunday'), padding); + break; + + // '00' + // case 'W': + case 87: + resultString += padTill2(weekNumber(date, 'monday'), padding); + break; + + // '16:00:00' + // case 'X': + case 88: + resultString += _processFormat(locale.formats.X, date, locale, timestamp); + break; + + // '1970' + // case 'Y': + case 89: + resultString += date.getFullYear(); + break; + + // 'GMT' + // case 'Z': + case 90: + if (_useUtcBasedDate && _customTimezoneOffset === 0) { + resultString += "GMT"; + } + else { + // fixme optimize + var tzString = date.toString().match(/\(([\w\s]+)\)/); + resultString += tzString && tzString[1] || ''; + } + break; + + // 'Thu' + // case 'a': + case 97: + resultString += locale.shortDays[date.getDay()]; + break; + + // 'Jan' + // case 'b': + case 98: + resultString += locale.shortMonths[date.getMonth()]; + break; + + // '' + // case 'c': + case 99: + resultString += _processFormat(locale.formats.c, date, locale, timestamp); + break; + + // '01' + // case 'd': + case 100: + resultString += padTill2(date.getDate(), padding); + break; + + // ' 1' + // case 'e': + case 101: + resultString += padTill2(date.getDate(), padding == null ? ' ' : padding); + break; + + // 'Jan' + // case 'h': + case 104: + resultString += locale.shortMonths[date.getMonth()]; + break; + + // '000' + // case 'j': + case 106: + var y = new Date(date.getFullYear(), 0, 1); + var day = Math.ceil((date.getTime() - y.getTime()) / (1000 * 60 * 60 * 24)); + resultString += padTill3(day); + break; + + // ' 0' + // case 'k': + case 107: + resultString += padTill2(date.getHours(), padding == null ? ' ' : padding); + break; + + // '12' + // case 'l': + case 108: + resultString += padTill2(hours12(date.getHours()), padding == null ? ' ' : padding); + break; + + // '01' + // case 'm': + case 109: + resultString += padTill2(date.getMonth() + 1, padding); + break; + + // '\n' + // case 'n': + case 110: + resultString += '\n'; + break; + + // '1st' + // case 'o': + case 111: + // Try to use an ordinal suffix from the locale, but fall back to using the old + // function for compatibility with old locales that lack them. + var day = date.getDate(); + if (locale.ordinalSuffixes) { + resultString += String(day) + (locale.ordinalSuffixes[day - 1] || ordinal(day)); + } + else { + resultString += String(day) + ordinal(day); + } + break; + + // 'AM' + // case 'p': + case 112: + resultString += date.getHours() < 12 ? locale.AM : locale.PM; + break; + + // '12:00:00 AM' + // case 'r': + case 114: + resultString += _processFormat(locale.formats.r, date, locale, timestamp); + break; + + // '0' + // case 's': + case 115: + resultString += Math.floor(timestamp / 1000); + break; + + // '\t' + // case 't': + case 116: + resultString += '\t'; + break; + + // '4' + // case 'u': + case 117: + var day = date.getDay(); + resultString += day === 0 ? 7 : day; + break; // 1 - 7, Monday is first day of the week + + // ' 1-Jan-1970' + // case 'v': + case 118: + resultString += _processFormat(locale.formats.v, date, locale, timestamp); + break; + + // '4' + // case 'w': + case 119: + resultString += date.getDay(); + break; // 0 - 6, Sunday is first day of the week + + // '12/31/69' + // case 'x': + case 120: + resultString += _processFormat(locale.formats.x, date, locale, timestamp); + break; + + // '70' + // case 'y': + case 121: + resultString += ('' + date.getFullYear()).slice(2); + break; + + // '+0000' + // case 'z': + case 122: + if (_useUtcBasedDate && _customTimezoneOffset === 0) { + resultString += extendedTZ ? "+00:00" : "+0000"; + } + else { + var off; + if (_customTimezoneOffset !== 0) { + off = _customTimezoneOffset / (60 * 1000); + } + else { + off = -date.getTimezoneOffset(); + } + var sign = off < 0 ? '-' : '+'; + var sep = extendedTZ ? ':' : ''; + var hours = Math.floor(Math.abs(off / 60)); + var mins = Math.abs(off % 60); + resultString += sign + padTill2(hours) + sep + padTill2(mins); + } + break; + + default: + if (isInScope) { + resultString += '%'; + } + resultString += format[i]; + break; + } + + padding = null; + isInScope = false; + continue; + } + + // '%' + if (currentCharCode === 37) { + isInScope = true; + continue; + } + + resultString += format[i]; + } + + return resultString; + } + + var strftime = _strftime; + + strftime.localize = function(locale) { + return new Strftime(locale || _locale, _customTimezoneOffset, _useUtcBasedDate); + }; + + strftime.localizeByIdentifier = function(localeIdentifier) { + var locale = Locales[localeIdentifier]; + if (!locale) { + warn('[WARNING] No locale found with identifier "' + localeIdentifier + '".'); + return strftime; + } + return strftime.localize(locale); + }; + + strftime.timezone = function(timezone) { + var customTimezoneOffset = _customTimezoneOffset; + var useUtcBasedDate = _useUtcBasedDate; + + var timezoneType = typeof timezone; + if (timezoneType === 'number' || timezoneType === 'string') { + useUtcBasedDate = true; + + // ISO 8601 format timezone string, [-+]HHMM + if (timezoneType === 'string') { + var sign = timezone[0] === '-' ? -1 : 1, + hours = parseInt(timezone.slice(1, 3), 10), + minutes = parseInt(timezone.slice(3, 5), 10); + + customTimezoneOffset = sign * ((60 * hours) + minutes) * 60 * 1000; + // in minutes: 420 + } + else if (timezoneType === 'number') { + customTimezoneOffset = timezone * 60 * 1000; + } + } + + return new Strftime(_locale, customTimezoneOffset, useUtcBasedDate); + }; + + strftime.utc = function() { + return new Strftime(_locale, _customTimezoneOffset, true); + }; + + return strftime; + } + + function padTill2(numberToPad, paddingChar) { + if (paddingChar === '' || numberToPad > 9) { + return numberToPad; + } + if (paddingChar == null) { + paddingChar = '0'; + } + return paddingChar + numberToPad; + } + + function padTill3(numberToPad) { + if (numberToPad > 99) { + return numberToPad; + } + if (numberToPad > 9) { + return '0' + numberToPad; + } + return '00' + numberToPad; + } + + function hours12(hour) { + if (hour === 0) { + return 12; + } + else if (hour > 12) { + return hour - 12; + } + return hour; + } + + // firstWeekday: 'sunday' or 'monday', default is 'sunday' + // + // Pilfered & ported from Ruby's strftime implementation. + function weekNumber(date, firstWeekday) { + firstWeekday = firstWeekday || 'sunday'; + + // This works by shifting the weekday back by one day if we + // are treating Monday as the first day of the week. + var weekday = date.getDay(); + if (firstWeekday === 'monday') { + if (weekday === 0) // Sunday + weekday = 6; + else + weekday--; + } + + var firstDayOfYearUtc = Date.UTC(date.getFullYear(), 0, 1), + dateUtc = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()), + yday = Math.floor((dateUtc - firstDayOfYearUtc) / 86400000), + weekNum = (yday + 7 - weekday) / 7; + + return Math.floor(weekNum); + } + + // Get the ordinal suffix for a number: st, nd, rd, or th + function ordinal(number) { + var i = number % 10; + var ii = number % 100; + + if ((ii >= 11 && ii <= 13) || i === 0 || i >= 4) { + return 'th'; + } + switch (i) { + case 1: return 'st'; + case 2: return 'nd'; + case 3: return 'rd'; + } + } + + function getTimestampToUtcOffsetFor(date) { + return (date.getTimezoneOffset() || 0) * 60000; + } + + function warn(message) { + if (typeof console !== 'undefined' && typeof console.warn == 'function') { + console.warn(message) + } + } + +}()); -- 2.47.3