Skip to content
This repository
Browse code

Fixed formatting param issues. Added comments documenting use of stri…

…ng offset for twoDigitYearMax.
  • Loading branch information...
commit 08eb8f497d7a1acde36b00772eb5e4f0b94915d3 1 parent 72df551
InfinitiesLoop authored

Showing 3 changed files with 18 additions and 9 deletions. Show diff stats Hide diff stats

  1. +3 1 README.md
  2. +14 7 jquery.glob.js
  3. +1 1  jquery.glob.min.js
4 README.md
Source Rendered
@@ -325,7 +325,9 @@ jQuery.cultures['default'] = {
325 325 {"name":"A.D.","start":null,"offset":0}
326 326 ],
327 327 // when a two digit year is given, it will never be parsed as a four digit
328   - // year great than this year (in the appropriate era for the culture)
  328 + // year greater than this year (in the appropriate era for the culture)
  329 + // Set it as a full year (e.g. 2029) or use an offset format starting from
  330 + // the current year: "+19" would correspond to 2029 if the current year 2010.
329 331 twoDigitYearMax: 2029,
330 332 // set of predefined date and time patterns used by the culture
331 333 // these represent the format someone in this culture would expect
21 jquery.glob.js
@@ -169,13 +169,18 @@ $.extend({
169 169 culture = $.findClosestCulture( culture );
170 170
171 171 var date;
172   - if ( formats && formats.length ) {
173   - for ( var i = 1, l = formats.length; i < l; i++ ) {
174   - var format = formats[ i ];
175   - if ( format ) {
176   - date = parseExact( value, format, cultureInfo );
177   - if ( date ) {
178   - break;
  172 + if ( formats ) {
  173 + if ( typeof formats === "string" ) {
  174 + formats = [ formats ];
  175 + }
  176 + if ( formats.length ) {
  177 + for ( var i = 0, l = formats.length; i < l; i++ ) {
  178 + var format = formats[ i ];
  179 + if ( format ) {
  180 + date = parseExact( value, format, culture );
  181 + if ( date ) {
  182 + break;
  183 + }
179 184 }
180 185 }
181 186 }
@@ -342,6 +347,8 @@ var en = cultures["default"] = cultures.en = $.extend(true, {
342 347 ],
343 348 // when a two digit year is given, it will never be parsed as a four digit
344 349 // year greater than this year (in the appropriate era for the culture)
  350 + // Set it as a full year (e.g. 2029) or use an offset format starting from
  351 + // the current year: "+19" would correspond to 2029 if the current year 2010.
345 352 twoDigitYearMax: 2029,
346 353 // set of predefined date and time patterns used by the culture
347 354 // these represent the format someone in this culture would expect
2  jquery.glob.min.js
... ... @@ -1 +1 @@
1   -(function(a){var e={"invariant":{}};a.extend({findClosestCulture:function(b){var c;if(!b)c=a.culture||a.cultures.invariant;else if(a.isPlainObject(b))c=b;else{for(var f=a.cultures,e=a.isArray(b)?b:[b],h=e.length,d=0;d<h;d++){b=e[d];c=f[b];if(c)return c}for(d=0;d<h;d++){b=e[d];do{var g=b.lastIndexOf("-");if(g===-1)break;b=b.substr(0,g);c=f[b];if(c)return c}while(1)}}return c||null},preferCulture:function(b){a.culture=a.findClosestCulture(b)||a.cultures.invariant},localize:function(f,b,c){if(typeof b==="string"){b=b||"invariant";b=a.cultures[b]||{name:b}}var d=e[b.name];if(arguments.length===3){if(!d)d=e[b.name]={};d[f]=c}else{if(d)c=d[f];if(typeof c==="undefined"){var g=e[b.language];if(g)c=g[f];if(typeof c==="undefined")c=e["invariant"][f]}}return typeof c==="undefined"?null:c},format:function(b,d,c){c=a.findClosestCulture(c);if(typeof b==="number")b=y(b,d,c);else if(b instanceof Date)b=q(b,d,c);return b},parseInt:function(d,c,b){return Math.floor(a.parseFloat(d,c,b))},parseFloat:function(b,x,r){r=a.findClosestCulture(r);var m=NaN,d=r.numberFormat;b=n(b);if(w.test(b))m=parseFloat(b,x);else if(!x&&C.test(b))m=parseInt(b,16);else{var h=i(b,d,d.pattern[0]),j=h[0],f=h[1];if(j===""&&d.pattern[0]!=="-n"){h=i(b,d,"-n");j=h[0];f=h[1]}j=j||"+";var k,e,g=f.indexOf("e");if(g<0)g=f.indexOf("E");if(g<0){e=f;k=null}else{e=f.substr(0,g);k=f.substr(g+1)}var c,l,v=d["."],p=e.indexOf(v);if(p<0){c=e;l=null}else{c=e.substr(0,p);l=e.substr(p+v.length)}var q=d[","];c=c.split(q).join("");var s=q.replace(/\u00A0/g," ");if(q!==s)c=c.split(s).join("");var o=j+c;if(l!==null)o+="."+l;if(k!==null){var u=i(k,d,"-n");o+="e"+(u[0]||"+")+u[1]}if(t.test(o))m=parseFloat(o)}return m},parseDate:function(g,d,c){c=a.findClosestCulture(c);var b;if(d&&d.length)for(var e=1,h=d.length;e<h;e++){var f=d[e];if(f){b=r(g,f,cultureInfo);if(b)break}}else a.each(c.calendar.patterns,function(d,a){b=r(g,a,c);if(b)return false});return b||null}});var s=a.cultures=a.cultures||{},k=s.invariant=a.extend(true,{name:"invariant",englishName:"Invariant",nativeName:"Invariant",isRTL:false,language:"",numberFormat:{pattern:["-n"],decimals:2,",":",",".":".",groupSizes:[3],"+":"+","-":"-",percent:{pattern:["-n %","n %"],decimals:2,groupSizes:[3],",":",",".":".",symbol:"%"},currency:{pattern:["($n)","$n"],decimals:2,groupSizes:[3],",":",",".":".",symbol:"\ufffd"}},calendars:{standard:{name:"Gregorian_USEnglish","/":"/",":":":",firstDay:0,days:[["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],["Su","Mo","Tu","We","Th","Fr","Sa"]],months:[["January","February","March","April","May","June","July","August","September","October","November","December",""],["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""]],AM:["AM","am","AM"],PM:["PM","pm","PM"],eras:[{name:"A.D.",start:null,offset:0}],twoDigitYearMax:2029,patterns:{d:"MM/dd/yyyy",D:"dddd, dd MMMM yyyy",t:"HH:mm",T:"HH:mm:ss",f:"dddd, dd MMMM yyyy HH:mm",F:"dddd, dd MMMM yyyy HH:mm:ss",M:"MMMM dd",Y:"yyyy MMMM",S:"yyyy'-'MM'-'dd'T'HH':'mm':'ss"}}}},s.invariant);k.calendar=k.calendar||k.calendars.standard;var B=/^\s+|\s+$/g,w=/^[+-]?infinity$/i,C=/^0x[a-f0-9]+$/i,t=/^[+-]?\d*\.?\d*(e[+-]?\d+)?$/;function d(b,a){return b.indexOf(a)===0}function l(b,a){return b.substr(b.length-a.length)===a}function n(a){return(a+"").replace(B,"")}function f(a,c,d){for(var b=a.length;b<c;b++)a=d?"0"+a:a+"0";return a}function x(j,h,l){var m=l.groupSizes,i=m[0],k=1,p=Math.pow(10,h),n=Math.round(j*p)/p;if(!isFinite(n))n=j;j=n;var b=j+"",a="",e=b.split(/e/i),c=e.length>1?parseInt(e[1],10):0;b=e[0];e=b.split(".");b=e[0];a=e.length>1?e[1]:"";var q;if(c>0){a=f(a,c,false);b+=a.slice(0,c);a=a.substr(c)}else if(c<0){c=-c;b=f(b,c+1);a=b.slice(-c,b.length)+a;b=b.slice(0,-c)}if(h>0)a=l["."]+(a.length>h?a.slice(0,h):f(a,h));else a="";var d=b.length-1,o=l[","],g="";while(d>=0){if(i===0||i>d)return b.slice(0,d+1)+(g.length?o+g+a:a);g=b.slice(d-i+1,d+1)+(g.length?o+g:"");d-=i;if(k<m.length){i=m[k];k++}}return b.slice(0,d+1)+o+g+a}function i(a,f,g){var b=f["-"],c=f["+"],e;switch(g){case"n -":b=" "+b;c=" "+c;case"n-":if(l(a,b))e=["-",a.substr(0,a.length-b.length)];else if(l(a,c))e=["+",a.substr(0,a.length-c.length)];break;case"- n":b+=" ";c+=" ";case"-n":if(d(a,b))e=["-",a.substr(b.length)];else if(d(a,c))e=["+",a.substr(c.length)];break;case"(n)":if(d(a,"(")&&l(a,")"))e=["-",a.substr(1,a.length-2)]}return e||["",a]}function y(j,d,n){if(!d||d==="i")return n.name.length?j.toLocaleString():j.toString();d=d||"D";var h=n.numberFormat,c=Math.abs(j),e=-1,i;if(d.length>1)e=parseInt(d.slice(1),10);var l=d.charAt(0).toUpperCase(),b;switch(l){case"D":i="n";if(e!==-1)c=f(""+c,e,true);if(j<0)c=-c;break;case"N":b=h;case"C":b=b||h.currency;case"P":b=b||h.percent;i=j<0?b.pattern[0]:b.pattern[1]||"n";if(e===-1)e=b.decimals;c=x(c*(l==="P"?100:1),e,b);break;default:a.error("Bad number format specifier: "+l)}for(var m=/n|\$|-|%/g,g="";true;){var o=m.lastIndex,k=m.exec(i);g+=i.slice(o,k?k.index:i.length);if(!k)break;switch(k[0]){case"n":g+=c;break;case"$":g+=h.currency.symbol;break;case"-":if(/[1-9]/.test(c))g+=h["-"];break;case"%":g+=h.percent.symbol}}return g}function b(a,c,b){return a<c||a>b}function A(d,b){var e=new Date,f=g(e);if(b<100){var a=d.twoDigitYearMax;a=typeof a==="string"?(new Date).getFullYear()%100+parseInt(a,10):a;var c=j(e,d,f);b+=c-c%100;if(b>a)b-=100}return b}function g(e,c){if(!c)return 0;for(var b,d=e.getTime(),a=0,f=c.length;a<f;a++){b=c[a].start;if(b===null||d>=b)return a}return 0}function m(a){return a.split("\u00a0").join(" ").toUpperCase()}function c(b){return a.map(b,function(a){return m(a)})}function j(d,b,e,c){var a=d.getFullYear();if(!c&&b.eras)a-=b.eras[e].offset;return a}function z(g,d,h){var e,f=g.days,b=g._upperDays;if(!b)g._upperDays=b=[c(f[0]),c(f[1]),c(f[2])];d=m(d);if(h){e=a.inArray(d,b[1]);if(e===-1)e=a.inArray(d,b[2])}else e=a.inArray(d,b[0]);return e}function v(b,f,i){var d=b.months,j=b.monthsGenitive||b.months,e=b._upperMonths,g=b._upperMonthsGen;if(!e){b._upperMonths=e=[c(d[0]),c(d[1])];b._upperMonthsGen=g=[c(d[2]||d[0]),c(d[3]||d[1])]}f=m(f);var h=a.inArray(f,i?e[1]:e[0]);if(h<0)h=a.inArray(f,i?g[1]:g[0]);return h}function h(e,b){for(var d=0,a=false,c=0,g=e.length;c<g;c++){var f=e.charAt(c);switch(f){case"'":if(a)b.push("'");else d++;a=false;break;case"\\":a&&b.push("\\");a=!a;break;default:b.push(f);a=false}}return d}function p(f,b){b=b||"F";var c,e=f.patterns,d=b.length;if(d===1){c=e[b];!c&&a.error("Invalid date format string '"+b+"'.");b=c}else if(d===2&&b.charAt(0)==="%")b=b.charAt(1);return b}function u(e,i){var f=e._parseRegExp;if(!f)e._parseRegExp=f={};else{var n=f[i];if(n)return n}var g=p(e,i).replace(/([\^\$\.\*\+\?\|\[\]\(\)\{\}])/g,"\\\\$1"),c=["^"],q=[],j=0,m=0,l=o(),d;while((d=l.exec(g))!==null){var t=g.slice(j,d.index);j=l.lastIndex;m+=h(t,c);if(m%2){c.push(d[0]);continue}var k=d[0],u=k.length,b;switch(k){case"dddd":case"ddd":case"MMMM":case"MMM":case"gg":case"g":b="(\\D+)";break;case"tt":case"t":b="(\\D*)";break;case"yyyy":case"fff":case"ff":case"f":b="(\\d{"+u+"})";break;case"dd":case"d":case"MM":case"M":case"yy":case"y":case"HH":case"H":case"hh":case"h":case"mm":case"m":case"ss":case"s":b="(\\d\\d?)";break;case"zzz":b="([+-]?\\d\\d?:\\d{2})";break;case"zz":case"z":b="([+-]?\\d\\d?)";break;case"/":b="(\\"+e["/"]+")";break;default:a.error("Invalid date format pattern '"+k+"'.")}b&&c.push(b);q.push(d[0])}h(g.slice(j),c);c.push("$");var s=c.join("").replace(/\s+/g,"\\s+"),r={regExp:s,groups:q};return f[i]=r}function o(){return/\/|dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z|gg|g/g}function r(y,M,L){y=n(y);var a=L.calendar,H=u(a,M),K=(new RegExp(H.regExp)).exec(y);if(K===null)return null;for(var J=H.groups,C=null,j=null,h=null,i=null,q=null,g=0,k,D=0,E=0,B=0,l=null,x=false,s=0,N=J.length;s<N;s++){var c=K[s+1];if(c){var I=J[s],m=I.length,f=parseInt(c,10);switch(I){case"dd":case"d":i=f;if(b(i,1,31))return null;break;case"MMM":case"MMMM":h=v(a,c,m===3);if(b(h,0,11))return null;break;case"M":case"MM":h=f-1;if(b(h,0,11))return null;break;case"y":case"yy":case"yyyy":j=m<4?A(a,f):f;if(b(j,0,9999))return null;break;case"h":case"hh":g=f;if(g===12)g=0;if(b(g,0,11))return null;break;case"H":case"HH":g=f;if(b(g,0,23))return null;break;case"m":case"mm":D=f;if(b(D,0,59))return null;break;case"s":case"ss":E=f;if(b(E,0,59))return null;break;case"tt":case"t":x=a.PM&&(c===a.PM[0]||c===a.PM[1]||c===a.PM[2]);if(!x&&(!a.AM||c!==a.AM[0]&&c!==a.AM[1]&&c!==a.AM[2]))return null;break;case"f":case"ff":case"fff":B=f*Math.pow(10,3-m);if(b(B,0,999))return null;break;case"ddd":case"dddd":q=z(a,c,m===3);if(b(q,0,6))return null;break;case"zzz":var w=c.split(/:/);if(w.length!==2)return null;k=parseInt(w[0],10);if(b(k,-12,13))return null;var t=parseInt(w[1],10);if(b(t,0,59))return null;l=k*60+(d(c,"-")?-t:t);break;case"z":case"zz":k=f;if(b(k,-12,13))return null;l=k*60;break;case"g":case"gg":var p=c;if(!p||!a.eras)return null;p=n(p.toLowerCase());for(var r=0,O=a.eras.length;r<O;r++)if(p===a.eras[r].name.toLowerCase()){C=r;break}if(C===null)return null}}}var e=new Date,G,o=a.convert;G=o?o.fromGregorian(e)[0]:e.getFullYear();if(j===null)j=G;else if(a.eras)j+=a.eras[C||0].offset;if(h===null)h=0;if(i===null)i=1;if(o){e=o.toGregorian(j,h,i);if(e===null)return null}else{e.setFullYear(j,h,i);if(e.getDate()!==i)return null;if(q!==null&&e.getDay()!==q)return null}if(x&&g<12)g+=12;e.setHours(g,D,E,B);if(l!==null){var F=e.getMinutes()-(l+e.getTimezoneOffset());e.setHours(e.getHours()+parseInt(F/60,10),F%60)}return e}function q(c,i,s){var d=s.calendar,t=d.convert;if(!i||!i.length||i==="i"){var b;if(s&&s.name.length)if(t)b=q(c,d.patterns.F,s);else{var A=new Date(c.getTime()),H=g(c,d.eras);A.setFullYear(j(c,d,H));b=A.toLocaleString()}else b=c.toString();return b}var B=d.eras,z=i==="s";i=p(d,i);b=[];var k,G=["0","00","000"],n,x,C=/([^d]|^)(d|dd)([^d]|$)/g,y=0,w=o(),m;function f(d,a){var b,c=d+"";if(a>1&&c.length<a){b=G[a-2]+c;return b.substr(b.length-a,a)}else b=c;return b}function E(){if(n||x)return n;n=C.test(i);x=true;return n}function v(a,b){if(m)return m[b];switch(b){case 0:return a.getFullYear();case 1:return a.getMonth();case 2:return a.getDate()}}if(!z&&t)m=t.fromGregorian(c);for(;true;){var F=w.lastIndex,r=w.exec(i),D=i.slice(F,r?r.index:i.length);y+=h(D,b);if(!r)break;if(y%2){b.push(r[0]);continue}var u=r[0],e=u.length;switch(u){case"ddd":case"dddd":names=e===3?d.days[1]:d.days[0];b.push(names[c.getDay()]);break;case"d":case"dd":n=true;b.push(f(v(c,2),e));break;case"MMM":case"MMMM":var l=v(c,1);b.push(d.monthsGenitive&&E()?(d.monthsGenitive||d.months)[e===3?1:0][l]:d.months[e===3?1:0][l]);break;case"M":case"MM":b.push(f(v(c,1)+1,e));break;case"y":case"yy":case"yyyy":l=m?m[0]:j(c,d,g(c,B),z);if(e<4)l=l%100;b.push(f(l,e));break;case"h":case"hh":k=c.getHours()%12;if(k===0)k=12;b.push(f(k,e));break;case"H":case"HH":b.push(f(c.getHours(),e));break;case"m":case"mm":b.push(f(c.getMinutes(),e));break;case"s":case"ss":b.push(f(c.getSeconds(),e));break;case"t":case"tt":l=c.getHours()<12?d.AM?d.AM[0]:" ":d.PM?d.PM[0]:" ";b.push(e===1?l.charAt(0):l);break;case"f":case"ff":case"fff":b.push(f(c.getMilliseconds(),3).substr(0,e));break;case"z":case"zz":k=c.getTimezoneOffset()/60;b.push((k<=0?"+":"-")+f(Math.floor(Math.abs(k)),e));break;case"zzz":k=c.getTimezoneOffset()/60;b.push((k<=0?"+":"-")+f(Math.floor(Math.abs(k)),2)+":"+f(Math.abs(c.getTimezoneOffset()%60),2));break;case"g":case"gg":d.eras&&b.push(d.eras[g(c,B)].name);break;case"/":b.push(d["/"]);break;default:a.error("Invalid date format pattern '"+u+"'.")}}return b.join("")}})(jQuery)
  1 +(function(a){var d={en:{}};d["default"]=d.en;a.extend({findClosestCulture:function(b){var c;if(!b)c=a.culture||a.cultures["default"];else if(a.isPlainObject(b))c=b;else{for(var f=a.cultures,e=a.isArray(b)?b:[b],h=e.length,d=0;d<h;d++){b=e[d];c=f[b];if(c)return c}for(d=0;d<h;d++){b=e[d];do{var g=b.lastIndexOf("-");if(g===-1)break;b=b.substr(0,g);c=f[b];if(c)return c}while(1)}}return c||null},preferCulture:function(b){a.culture=a.findClosestCulture(b)||a.cultures["default"]},localize:function(f,b,c){if(typeof b==="string"){b=b||"default";b=a.cultures[b]||{name:b}}var e=d[b.name];if(arguments.length===3){if(!e)e=d[b.name]={};e[f]=c}else{if(e)c=e[f];if(typeof c==="undefined"){var g=d[b.language];if(g)c=g[f];if(typeof c==="undefined")c=d["default"][f]}}return typeof c==="undefined"?null:c},format:function(b,d,c){c=a.findClosestCulture(c);if(typeof b==="number")b=y(b,d,c);else if(b instanceof Date)b=r(b,d,c);return b},parseInt:function(d,c,b){return Math.floor(a.parseFloat(d,c,b))},parseFloat:function(b,x,r){r=a.findClosestCulture(r);var m=NaN,d=r.numberFormat;b=n(b);if(w.test(b))m=parseFloat(b,x);else if(!x&&C.test(b))m=parseInt(b,16);else{var h=i(b,d,d.pattern[0]),j=h[0],f=h[1];if(j===""&&d.pattern[0]!=="-n"){h=i(b,d,"-n");j=h[0];f=h[1]}j=j||"+";var k,e,g=f.indexOf("e");if(g<0)g=f.indexOf("E");if(g<0){e=f;k=null}else{e=f.substr(0,g);k=f.substr(g+1)}var c,l,v=d["."],p=e.indexOf(v);if(p<0){c=e;l=null}else{c=e.substr(0,p);l=e.substr(p+v.length)}var q=d[","];c=c.split(q).join("");var s=q.replace(/\u00A0/g," ");if(q!==s)c=c.split(s).join("");var o=j+c;if(l!==null)o+="."+l;if(k!==null){var u=i(k,d,"-n");o+="e"+(u[0]||"+")+u[1]}if(t.test(o))m=parseFloat(o)}return m},parseDate:function(g,b,c){c=a.findClosestCulture(c);var d;if(b){if(typeof b==="string")b=[b];if(b.length)for(var e=0,h=b.length;e<h;e++){var f=b[e];if(f){d=s(g,f,c);if(d)break}}}else a.each(c.calendar.patterns,function(b,a){d=s(g,a,c);if(d)return false});return d||null}});var k=a.cultures=a.cultures||{},o=k["default"]=k.en=a.extend(true,{name:"en",englishName:"English",nativeName:"English",isRTL:false,language:"en",numberFormat:{pattern:["-n"],decimals:2,",":",",".":".",groupSizes:[3],"+":"+","-":"-",percent:{pattern:["-n %","n %"],decimals:2,groupSizes:[3],",":",",".":".",symbol:"%"},currency:{pattern:["($n)","$n"],decimals:2,groupSizes:[3],",":",",".":".",symbol:"$"}},calendars:{standard:{name:"Gregorian_USEnglish","/":"/",":":":",firstDay:0,days:{names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],namesAbbr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],namesShort:["Su","Mo","Tu","We","Th","Fr","Sa"]},months:{names:["January","February","March","April","May","June","July","August","September","October","November","December",""],namesAbbr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""]},AM:["AM","am","AM"],PM:["PM","pm","PM"],eras:[{name:"A.D.",start:null,offset:0}],twoDigitYearMax:2029,patterns:{d:"M/d/yyyy",D:"dddd, MMMM dd, yyyy",t:"h:mm tt",T:"h:mm:ss tt",f:"dddd, MMMM dd, yyyy h:mm tt",F:"dddd, MMMM dd, yyyy h:mm:ss tt",M:"MMMM dd",Y:"yyyy MMMM",S:"yyyy'-'MM'-'dd'T'HH':'mm':'ss"}}}},k.en);o.calendar=o.calendar||o.calendars.standard;var B=/^\s+|\s+$/g,w=/^[+-]?infinity$/i,C=/^0x[a-f0-9]+$/i,t=/^[+-]?\d*\.?\d*(e[+-]?\d+)?$/;function e(b,a){return b.indexOf(a)===0}function l(b,a){return b.substr(b.length-a.length)===a}function n(a){return(a+"").replace(B,"")}function f(a,c,d){for(var b=a.length;b<c;b++)a=d?"0"+a:a+"0";return a}function x(j,h,l){var m=l.groupSizes,i=m[0],k=1,p=Math.pow(10,h),n=Math.round(j*p)/p;if(!isFinite(n))n=j;j=n;var b=j+"",a="",e=b.split(/e/i),c=e.length>1?parseInt(e[1],10):0;b=e[0];e=b.split(".");b=e[0];a=e.length>1?e[1]:"";var q;if(c>0){a=f(a,c,false);b+=a.slice(0,c);a=a.substr(c)}else if(c<0){c=-c;b=f(b,c+1);a=b.slice(-c,b.length)+a;b=b.slice(0,-c)}if(h>0)a=l["."]+(a.length>h?a.slice(0,h):f(a,h));else a="";var d=b.length-1,o=l[","],g="";while(d>=0){if(i===0||i>d)return b.slice(0,d+1)+(g.length?o+g+a:a);g=b.slice(d-i+1,d+1)+(g.length?o+g:"");d-=i;if(k<m.length){i=m[k];k++}}return b.slice(0,d+1)+o+g+a}function i(a,f,g){var b=f["-"],c=f["+"],d;switch(g){case"n -":b=" "+b;c=" "+c;case"n-":if(l(a,b))d=["-",a.substr(0,a.length-b.length)];else if(l(a,c))d=["+",a.substr(0,a.length-c.length)];break;case"- n":b+=" ";c+=" ";case"-n":if(e(a,b))d=["-",a.substr(b.length)];else if(e(a,c))d=["+",a.substr(c.length)];break;case"(n)":if(e(a,"(")&&l(a,")"))d=["-",a.substr(1,a.length-2)]}return d||["",a]}function y(j,d,n){if(!d||d==="i")return n.name.length?j.toLocaleString():j.toString();d=d||"D";var h=n.numberFormat,c=Math.abs(j),e=-1,i;if(d.length>1)e=parseInt(d.slice(1),10);var l=d.charAt(0).toUpperCase(),b;switch(l){case"D":i="n";if(e!==-1)c=f(""+c,e,true);if(j<0)c=-c;break;case"N":b=h;case"C":b=b||h.currency;case"P":b=b||h.percent;i=j<0?b.pattern[0]:b.pattern[1]||"n";if(e===-1)e=b.decimals;c=x(c*(l==="P"?100:1),e,b);break;default:a.error("Bad number format specifier: "+l)}for(var m=/n|\$|-|%/g,g="";true;){var o=m.lastIndex,k=m.exec(i);g+=i.slice(o,k?k.index:i.length);if(!k)break;switch(k[0]){case"n":g+=c;break;case"$":g+=h.currency.symbol;break;case"-":if(/[1-9]/.test(c))g+=h["-"];break;case"%":g+=h.percent.symbol}}return g}function b(a,c,b){return a<c||a>b}function A(d,b){var e=new Date,f=g(e);if(b<100){var a=d.twoDigitYearMax;a=typeof a==="string"?(new Date).getFullYear()%100+parseInt(a,10):a;var c=j(e,d,f);b+=c-c%100;if(b>a)b-=100}return b}function g(e,c){if(!c)return 0;for(var b,d=e.getTime(),a=0,f=c.length;a<f;a++){b=c[a].start;if(b===null||d>=b)return a}return 0}function m(a){return a.split("\u00a0").join(" ").toUpperCase()}function c(b){return a.map(b,function(a){return m(a)})}function j(d,b,e,c){var a=d.getFullYear();if(!c&&b.eras)a-=b.eras[e].offset;return a}function z(g,d,h){var e,f=g.days,b=g._upperDays;if(!b)g._upperDays=b=[c(f.names),c(f.namesAbbr),c(f.namesShort)];d=m(d);if(h){e=a.inArray(d,b[1]);if(e===-1)e=a.inArray(d,b[2])}else e=a.inArray(d,b[0]);return e}function v(b,e,j){var i=b.months,h=b.monthsGenitive||b.months,d=b._upperMonths,f=b._upperMonthsGen;if(!d){b._upperMonths=d=[c(i.names),c(i.namesAbbr)];b._upperMonthsGen=f=[c(h.names),c(h.namesAbbr)]}e=m(e);var g=a.inArray(e,j?d[1]:d[0]);if(g<0)g=a.inArray(e,j?f[1]:f[0]);return g}function h(e,b){for(var d=0,a=false,c=0,g=e.length;c<g;c++){var f=e.charAt(c);switch(f){case"'":if(a)b.push("'");else d++;a=false;break;case"\\":a&&b.push("\\");a=!a;break;default:b.push(f);a=false}}return d}function q(f,b){b=b||"F";var c,e=f.patterns,d=b.length;if(d===1){c=e[b];!c&&a.error("Invalid date format string '"+b+"'.");b=c}else if(d===2&&b.charAt(0)==="%")b=b.charAt(1);return b}function u(e,i){var f=e._parseRegExp;if(!f)e._parseRegExp=f={};else{var n=f[i];if(n)return n}var g=q(e,i).replace(/([\^\$\.\*\+\?\|\[\]\(\)\{\}])/g,"\\\\$1"),c=["^"],o=[],j=0,m=0,l=p(),d;while((d=l.exec(g))!==null){var t=g.slice(j,d.index);j=l.lastIndex;m+=h(t,c);if(m%2){c.push(d[0]);continue}var k=d[0],u=k.length,b;switch(k){case"dddd":case"ddd":case"MMMM":case"MMM":case"gg":case"g":b="(\\D+)";break;case"tt":case"t":b="(\\D*)";break;case"yyyy":case"fff":case"ff":case"f":b="(\\d{"+u+"})";break;case"dd":case"d":case"MM":case"M":case"yy":case"y":case"HH":case"H":case"hh":case"h":case"mm":case"m":case"ss":case"s":b="(\\d\\d?)";break;case"zzz":b="([+-]?\\d\\d?:\\d{2})";break;case"zz":case"z":b="([+-]?\\d\\d?)";break;case"/":b="(\\"+e["/"]+")";break;default:a.error("Invalid date format pattern '"+k+"'.")}b&&c.push(b);o.push(d[0])}h(g.slice(j),c);c.push("$");var s=c.join("").replace(/\s+/g,"\\s+"),r={regExp:s,groups:o};return f[i]=r}function p(){return/\/|dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z|gg|g/g}function s(y,M,L){y=n(y);var a=L.calendar,H=u(a,M),K=(new RegExp(H.regExp)).exec(y);if(K===null)return null;for(var J=H.groups,C=null,j=null,h=null,i=null,q=null,g=0,k,D=0,E=0,B=0,l=null,x=false,s=0,N=J.length;s<N;s++){var c=K[s+1];if(c){var I=J[s],m=I.length,f=parseInt(c,10);switch(I){case"dd":case"d":i=f;if(b(i,1,31))return null;break;case"MMM":case"MMMM":h=v(a,c,m===3);if(b(h,0,11))return null;break;case"M":case"MM":h=f-1;if(b(h,0,11))return null;break;case"y":case"yy":case"yyyy":j=m<4?A(a,f):f;if(b(j,0,9999))return null;break;case"h":case"hh":g=f;if(g===12)g=0;if(b(g,0,11))return null;break;case"H":case"HH":g=f;if(b(g,0,23))return null;break;case"m":case"mm":D=f;if(b(D,0,59))return null;break;case"s":case"ss":E=f;if(b(E,0,59))return null;break;case"tt":case"t":x=a.PM&&(c===a.PM[0]||c===a.PM[1]||c===a.PM[2]);if(!x&&(!a.AM||c!==a.AM[0]&&c!==a.AM[1]&&c!==a.AM[2]))return null;break;case"f":case"ff":case"fff":B=f*Math.pow(10,3-m);if(b(B,0,999))return null;break;case"ddd":case"dddd":q=z(a,c,m===3);if(b(q,0,6))return null;break;case"zzz":var w=c.split(/:/);if(w.length!==2)return null;k=parseInt(w[0],10);if(b(k,-12,13))return null;var t=parseInt(w[1],10);if(b(t,0,59))return null;l=k*60+(e(c,"-")?-t:t);break;case"z":case"zz":k=f;if(b(k,-12,13))return null;l=k*60;break;case"g":case"gg":var p=c;if(!p||!a.eras)return null;p=n(p.toLowerCase());for(var r=0,O=a.eras.length;r<O;r++)if(p===a.eras[r].name.toLowerCase()){C=r;break}if(C===null)return null}}}var d=new Date,G,o=a.convert;G=o?o.fromGregorian(d)[0]:d.getFullYear();if(j===null)j=G;else if(a.eras)j+=a.eras[C||0].offset;if(h===null)h=0;if(i===null)i=1;if(o){d=o.toGregorian(j,h,i);if(d===null)return null}else{d.setFullYear(j,h,i);if(d.getDate()!==i)return null;if(q!==null&&d.getDay()!==q)return null}if(x&&g<12)g+=12;d.setHours(g,D,E,B);if(l!==null){var F=d.getMinutes()-(l+d.getTimezoneOffset());d.setHours(d.getHours()+parseInt(F/60,10),F%60)}return d}function r(c,i,s){var d=s.calendar,t=d.convert;if(!i||!i.length||i==="i"){var b;if(s&&s.name.length)if(t)b=r(c,d.patterns.F,s);else{var A=new Date(c.getTime()),H=g(c,d.eras);A.setFullYear(j(c,d,H));b=A.toLocaleString()}else b=c.toString();return b}var B=d.eras,z=i==="s";i=q(d,i);b=[];var k,G=["0","00","000"],n,x,C=/([^d]|^)(d|dd)([^d]|$)/g,y=0,w=p(),m;function f(d,a){var b,c=d+"";if(a>1&&c.length<a){b=G[a-2]+c;return b.substr(b.length-a,a)}else b=c;return b}function E(){if(n||x)return n;n=C.test(i);x=true;return n}function v(a,b){if(m)return m[b];switch(b){case 0:return a.getFullYear();case 1:return a.getMonth();case 2:return a.getDate()}}if(!z&&t)m=t.fromGregorian(c);for(;true;){var F=w.lastIndex,o=w.exec(i),D=i.slice(F,o?o.index:i.length);y+=h(D,b);if(!o)break;if(y%2){b.push(o[0]);continue}var u=o[0],e=u.length;switch(u){case"ddd":case"dddd":names=e===3?d.days.namesAbbr:d.days.names;b.push(names[c.getDay()]);break;case"d":case"dd":n=true;b.push(f(v(c,2),e));break;case"MMM":case"MMMM":var l=v(c,1);b.push(d.monthsGenitive&&E()?d.monthsGenitive[e===3?"namesAbbr":"names"][l]:d.months[e===3?"namesAbbr":"names"][l]);break;case"M":case"MM":b.push(f(v(c,1)+1,e));break;case"y":case"yy":case"yyyy":l=m?m[0]:j(c,d,g(c,B),z);if(e<4)l=l%100;b.push(f(l,e));break;case"h":case"hh":k=c.getHours()%12;if(k===0)k=12;b.push(f(k,e));break;case"H":case"HH":b.push(f(c.getHours(),e));break;case"m":case"mm":b.push(f(c.getMinutes(),e));break;case"s":case"ss":b.push(f(c.getSeconds(),e));break;case"t":case"tt":l=c.getHours()<12?d.AM?d.AM[0]:" ":d.PM?d.PM[0]:" ";b.push(e===1?l.charAt(0):l);break;case"f":case"ff":case"fff":b.push(f(c.getMilliseconds(),3).substr(0,e));break;case"z":case"zz":k=c.getTimezoneOffset()/60;b.push((k<=0?"+":"-")+f(Math.floor(Math.abs(k)),e));break;case"zzz":k=c.getTimezoneOffset()/60;b.push((k<=0?"+":"-")+f(Math.floor(Math.abs(k)),2)+":"+f(Math.abs(c.getTimezoneOffset()%60),2));break;case"g":case"gg":d.eras&&b.push(d.eras[g(c,B)].name);break;case"/":b.push(d["/"]);break;default:a.error("Invalid date format pattern '"+u+"'.")}}return b.join("")}})(jQuery)

0 comments on commit 08eb8f4

Please sign in to comment.
Something went wrong with that request. Please try again.