Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding JSON dates to static date formats

  • Loading branch information...
commit 9cd229b6bd94f3800ddd95f807ddc9c2e701ffc4 1 parent 4e5b1bd
@andrewplummer andrewplummer authored
View
10 lib/sugar.js
@@ -3743,7 +3743,8 @@
// @date_format 05-25-2010
// @date_format 05/25/2010
// @date_format 05.25.2010
- { src: '(\\d{1,2})[-.\\/]({month})[-.\\/]?(\\d{2,4})?', to: ['month','date','year'], variant: true }
+ { src: '(\\d{1,2})[-.\\/]({month})[-.\\/]?(\\d{2,4})?', to: ['month','date','year'], variant: true },
+ { src: '\\/Date\\((\\d+(?:\\+\\d{4})?)\\)\\/', to: ['timestamp'], time: false }
];
var DateOutputFormats = [
@@ -4234,6 +4235,11 @@
set = getFormatMatch(match, format.to);
loc = getLocalization(format.locale, true);
+ if(set.timestamp) {
+ d.setTime(0);
+ set = { 'milliseconds': set.timestamp };
+ return false;
+ }
// If there's a European variant, swap the month and day.
if(format.variant && !object.isString(set['month']) && (object.isString(set['date']) || variant)) {
@@ -4885,7 +4891,7 @@
DateUnitsReversed = DateUnits.clone().reverse();
var monthReg = '\\d{1,2}|' + English['months'].join('|');
arrayEach(StaticInputFormats, function(f) {
- date.addFormat(f.src.replace(/\{month\}/, monthReg) + OptionalTime, f.to.concat(TimeFormat), 'en', f.variant);
+ date.addFormat(f.src.replace(/\{month\}/, monthReg) + (f.time === false ? '' : OptionalTime), f.to.concat(TimeFormat), 'en', f.variant);
});
date.addFormat(RequiredTime, TimeFormat);
}
View
10 release/development/sugar-edge.development.js
@@ -3751,7 +3751,8 @@
// @date_format 05-25-2010
// @date_format 05/25/2010
// @date_format 05.25.2010
- { src: '(\\d{1,2})[-.\\/]({month})[-.\\/]?(\\d{2,4})?', to: ['month','date','year'], variant: true }
+ { src: '(\\d{1,2})[-.\\/]({month})[-.\\/]?(\\d{2,4})?', to: ['month','date','year'], variant: true },
+ { src: '\\/Date\\((\\d+(?:\\+\\d{4})?)\\)\\/', to: ['timestamp'], time: false }
];
var DateOutputFormats = [
@@ -4242,6 +4243,11 @@
set = getFormatMatch(match, format.to);
loc = getLocalization(format.locale, true);
+ if(set.timestamp) {
+ d.setTime(0);
+ set = { 'milliseconds': set.timestamp };
+ return false;
+ }
// If there's a European variant, swap the month and day.
if(format.variant && !object.isString(set['month']) && (object.isString(set['date']) || variant)) {
@@ -4893,7 +4899,7 @@
DateUnitsReversed = DateUnits.clone().reverse();
var monthReg = '\\d{1,2}|' + English['months'].join('|');
arrayEach(StaticInputFormats, function(f) {
- date.addFormat(f.src.replace(/\{month\}/, monthReg) + OptionalTime, f.to.concat(TimeFormat), 'en', f.variant);
+ date.addFormat(f.src.replace(/\{month\}/, monthReg) + (f.time === false ? '' : OptionalTime), f.to.concat(TimeFormat), 'en', f.variant);
});
date.addFormat(RequiredTime, TimeFormat);
}
View
22 release/sugar-edge.min.js
@@ -53,10 +53,10 @@ a=String(a);if(b===i)b=/\W/g;if(b){a=a.remove(b);c=c.remove(b)}return c==a?0:c<a
w(t,i,function(a){return!p.isRegExp(a)},{split:function(a,b){var c=[],d=0;a=r(a).addFlag("g");var e,f,h,g;r.m||(e=RegExp("^"+a.source+"$(?!\\s)",a.getFlags()));if(A(b)||+b<0)b=Infinity;else{b=(+b).floor();if(!b)return[]}for(;f=a.exec(this);){h=f.index+f[0].length;if(h>d){c.push(this.slice(d,f.index));!r.m&&f.length>1&&f[0].replace(e,function(){for(var k=1;k<arguments.length-2;k++)if(A(arguments[k]))f[k]=void 0});f.length>1&&f.index<this.length&&q.prototype.push.apply(c,f.slice(1));g=f[0].length;d=
h;if(c.length>=b)break}a.lastIndex===f.index&&a.lastIndex++}if(d===this.length){if(g||!a.test(""))c.push("")}else c.push(this.slice(d));return c.length>b?c.slice(0,b):c}});w(t,i,l,{insert:t.prototype.add});
var va=["hour","minute","second","millisecond","meridian","utc","offset_sign","offset_hours","offset_minutes"],wa="(\\d{1,2}):?(\\d{2})?:?(\\d{2})?(?:\\.(\\d{1,6}))?(am|pm)?(?:(Z)|(?:([+-])(\\d{2})(?::?(\\d{2}))?)?)?",xa="\\s*(?:(?:t|at |\\s+)"+wa+")?",V="\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d",za="\u5341\u767e\u5343\u4e07",Aa=r("["+V+za+"]","g"),Ba=[],Ca,W,Da=[{src:"(\\d{4})",to:["year"]},{src:"([+-])?(\\d{4})[-.]?({month})[-.]?(\\d{1,2})?",to:["year_sign","year","month","date"]},
-{src:"(\\d{1,2})[-.\\/]({month})[-.\\/]?(\\d{2,4})?",to:["month","date","year"],k:i}],Ea=[{c:"f{1,4}|ms|milliseconds",b:function(a){return a.getMilliseconds()}},{c:"ss?|seconds",b:function(a){return a.getSeconds()}},{c:"mm?|minutes",b:function(a){return a.getMinutes()}},{c:"hh?|hours|12hr",b:function(a){a=a.getHours(void 0);return a===0?12:a-(a/13).floor()*12}},{c:"HH?|24hr",b:function(a){return a.getHours()}},{c:"dd?|date|day",b:function(a){return a.getDate()}},{c:"dow|weekday",l:i,b:function(a,
-b,c){return b.weekdays[a.getDay()+(c-1)*7]}},{c:"MM?",b:function(a){return a.getMonth()+1}},{c:"mon|month",l:i,b:function(a,b,c){return b.months[a.getMonth()+(c-1)*12]}},{c:"y{2,4}|year",b:function(a){return a.getFullYear()}},{c:"[Tt]{1,2}",b:function(a,b,c,d){a=a.getHours(void 0)<12?"am":"pm";if(d.length===1)a=a.first();if(d.first()==="T")a=a.toUpperCase();return a}},{c:"z{1,4}|tz|timezone",text:i,b:function(a,b,c,d){a=a.getUTCOffset();if(d=="z"||d=="zz")a=a.replace(/(\d{2})(\d{2})/,function(e,f){return f.toNumber().pad(d.length)});
-return a}},{c:"iso(tz|timezone)",b:function(a){return a.getUTCOffset(i)}},{c:"ord",b:function(a){return a.getDate().ordinalize()}}],X=[{a:"year",method:"FullYear",e:function(a){return(365+(a?a.isLeapYear()?1:0:0.25))*24*60*60*1E3}},{a:"month",method:"Month",e:function(a,b){var c=30.4375,d;if(a){d=a.daysInMonth();if(b<=d.days())c=d}return c*24*60*60*1E3}},{a:"week",method:"Week",e:m(6048E5)},{a:"day",method:"Date",e:m(864E5)},{a:"hour",method:"Hours",e:m(36E5)},{a:"minute",method:"Minutes",e:m(6E4)},
-{a:"second",method:"Seconds",e:m(1E3)},{a:"millisecond",method:"Milliseconds",e:m(1)}],Fa={},Ga={en:"2;;January,February,March,April,May,June,July,August,September,October,November,December;Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday;millisecond:|s,second:|s,minute:|s,hour:|s,day:|s,week:|s,month:|s,year:|s;one,two,three,four,five,six,seven,eight,nine,ten;a,an,the;the,st|nd|rd|th,of;{num} {unit} {sign},{num} {unit=4-5} {sign} {day},{weekday?} {month} {date}{2} {year?} {time?},{date} {month} {year},{month} {year},{shift?} {weekday} {time?},{shift} week {weekday} {time?},{shift} {unit=5-7},{1} {edge} of {shift?} {unit=4-7?}{month?}{year?},{weekday} {3} {shift} week,{1} {date}{2} of {month},{1}{month?} {date?}{2} of {shift} {unit=6-7},{day} at {time?},{time} {day};{Month} {d}, {yyyy};,yesterday,today,tomorrow;,ago|before,,from now|after|from;,last,the|this,next;last day,end,,first day|beginning",
+{src:"(\\d{1,2})[-.\\/]({month})[-.\\/]?(\\d{2,4})?",to:["month","date","year"],k:i},{src:"\\/Date\\((\\d+(?:\\+\\d{4})?)\\)\\/",to:["timestamp"],z:l}],Ea=[{c:"f{1,4}|ms|milliseconds",b:function(a){return a.getMilliseconds()}},{c:"ss?|seconds",b:function(a){return a.getSeconds()}},{c:"mm?|minutes",b:function(a){return a.getMinutes()}},{c:"hh?|hours|12hr",b:function(a){a=a.getHours(void 0);return a===0?12:a-(a/13).floor()*12}},{c:"HH?|24hr",b:function(a){return a.getHours()}},{c:"dd?|date|day",b:function(a){return a.getDate()}},
+{c:"dow|weekday",l:i,b:function(a,b,c){return b.weekdays[a.getDay()+(c-1)*7]}},{c:"MM?",b:function(a){return a.getMonth()+1}},{c:"mon|month",l:i,b:function(a,b,c){return b.months[a.getMonth()+(c-1)*12]}},{c:"y{2,4}|year",b:function(a){return a.getFullYear()}},{c:"[Tt]{1,2}",b:function(a,b,c,d){a=a.getHours(void 0)<12?"am":"pm";if(d.length===1)a=a.first();if(d.first()==="T")a=a.toUpperCase();return a}},{c:"z{1,4}|tz|timezone",text:i,b:function(a,b,c,d){a=a.getUTCOffset();if(d=="z"||d=="zz")a=a.replace(/(\d{2})(\d{2})/,
+function(e,f){return f.toNumber().pad(d.length)});return a}},{c:"iso(tz|timezone)",b:function(a){return a.getUTCOffset(i)}},{c:"ord",b:function(a){return a.getDate().ordinalize()}}],X=[{a:"year",method:"FullYear",e:function(a){return(365+(a?a.isLeapYear()?1:0:0.25))*24*60*60*1E3}},{a:"month",method:"Month",e:function(a,b){var c=30.4375,d;if(a){d=a.daysInMonth();if(b<=d.days())c=d}return c*24*60*60*1E3}},{a:"week",method:"Week",e:m(6048E5)},{a:"day",method:"Date",e:m(864E5)},{a:"hour",method:"Hours",
+e:m(36E5)},{a:"minute",method:"Minutes",e:m(6E4)},{a:"second",method:"Seconds",e:m(1E3)},{a:"millisecond",method:"Milliseconds",e:m(1)}],Fa={},Ga={en:"2;;January,February,March,April,May,June,July,August,September,October,November,December;Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday;millisecond:|s,second:|s,minute:|s,hour:|s,day:|s,week:|s,month:|s,year:|s;one,two,three,four,five,six,seven,eight,nine,ten;a,an,the;the,st|nd|rd|th,of;{num} {unit} {sign},{num} {unit=4-5} {sign} {day},{weekday?} {month} {date}{2} {year?} {time?},{date} {month} {year},{month} {year},{shift?} {weekday} {time?},{shift} week {weekday} {time?},{shift} {unit=5-7},{1} {edge} of {shift?} {unit=4-7?}{month?}{year?},{weekday} {3} {shift} week,{1} {date}{2} of {month},{1}{month?} {date?}{2} of {shift} {unit=6-7},{day} at {time?},{time} {day};{Month} {d}, {yyyy};,yesterday,today,tomorrow;,ago|before,,from now|after|from;,last,the|this,next;last day,end,,first day|beginning",
ja:"1;\u6708;;\u65e5\u66dc\u65e5,\u6708\u66dc\u65e5,\u706b\u66dc\u65e5,\u6c34\u66dc\u65e5,\u6728\u66dc\u65e5,\u91d1\u66dc\u65e5,\u571f\u66dc\u65e5;\u30df\u30ea\u79d2,\u79d2,\u5206,\u6642\u9593,\u65e5,\u9031\u9593|\u9031,\u30f6\u6708|\u30f5\u6708|\u6708,\u5e74;;;;{num}{unit}{sign},{shift}{unit=5-7}{weekday?},{year}\u5e74{month?}\u6708?{date?}\u65e5?,{month}\u6708{date?}\u65e5?,{date}\u65e5;{yyyy}\u5e74{M}\u6708{d}\u65e5;\u4e00\u6628\u65e5,\u6628\u65e5,\u4eca\u65e5,\u660e\u65e5,\u660e\u5f8c\u65e5;,\u524d,,\u5f8c;,\u53bb|\u5148,,\u6765",
ko:"1;\uc6d4;;\uc77c\uc694\uc77c,\uc6d4\uc694\uc77c,\ud654\uc694\uc77c,\uc218\uc694\uc77c,\ubaa9\uc694\uc77c,\uae08\uc694\uc77c,\ud1a0\uc694\uc77c;\ubc00\ub9ac\ucd08,\ucd08,\ubd84,\uc2dc\uac04,\uc77c,\uc8fc,\uac1c\uc6d4|\ub2ec,\ub144;\uc77c|\ud55c,\uc774,\uc0bc,\uc0ac,\uc624,\uc721,\uce60,\ud314,\uad6c,\uc2ed;;;{num}{unit} {sign},{shift} {unit=5-7},{shift} {unit=5?} {weekday},{year}\ub144{month?}\uc6d4?{date?}\uc77c?,{month}\uc6d4{date?}\uc77c?,{date}\uc77c;{yyyy}\ub144{M}\uc6d4{d}\uc77c;\uadf8\uc800\uaed8,\uc5b4\uc81c,\uc624\ub298,\ub0b4\uc77c,\ubaa8\ub808;,\uc804,,\ud6c4;,\uc9c0\ub09c|\uc791,\uc774\ubc88,\ub2e4\uc74c|\ub0b4",
ru:"4;;\u042f\u043d\u0432\u0430\u0440:\u044f|\u044c,\u0424\u0435\u0432\u0440\u0430\u043b:\u044f|\u044c,\u041c\u0430\u0440\u0442:\u0430|,\u0410\u043f\u0440\u0435\u043b:\u044f|\u044c,\u041c\u0430:\u044f|\u0439,\u0418\u044e\u043d:\u044f|\u044c,\u0418\u044e\u043b:\u044f|\u044c,\u0410\u0432\u0433\u0443\u0441\u0442:\u0430|,\u0421\u0435\u043d\u0442\u044f\u0431\u0440:\u044f|\u044c,\u041e\u043a\u0442\u044f\u0431\u0440:\u044f|\u044c,\u041d\u043e\u044f\u0431\u0440:\u044f|\u044c,\u0414\u0435\u043a\u0430\u0431\u0440:\u044f|\u044c;\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;\u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434:\u0430|\u0443|\u044b|,\u0441\u0435\u043a\u0443\u043d\u0434:\u0430|\u0443|\u044b|,\u043c\u0438\u043d\u0443\u0442:\u0430|\u0443|\u044b|,\u0447\u0430\u0441:||\u0430|\u043e\u0432,\u0434\u0435\u043d\u044c|\u0434\u0435\u043d\u044c|\u0434\u043d\u044f|\u0434\u043d\u0435\u0439,\u043d\u0435\u0434\u0435\u043b:\u044f|\u044e|\u0438|\u044c|\u0435,\u043c\u0435\u0441\u044f\u0446:||\u0430|\u0435\u0432|\u0435,\u0433\u043e\u0434|\u0433\u043e\u0434|\u0433\u043e\u0434\u0430|\u043b\u0435\u0442|\u0433\u043e\u0434\u0443;\u043e\u0434:\u0438\u043d|\u043d\u0443,\u0434\u0432:\u0430|\u0435,\u0442\u0440\u0438,\u0447\u0435\u0442\u044b\u0440\u0435,\u043f\u044f\u0442\u044c,\u0448\u0435\u0441\u0442\u044c,\u0441\u0435\u043c\u044c,\u0432\u043e\u0441\u0435\u043c\u044c,\u0434\u0435\u0432\u044f\u0442\u044c,\u0434\u0435\u0441\u044f\u0442\u044c;;\u0432|\u043d\u0430,\u0433\u043e\u0434\u0430;{num} {unit} {sign},{sign} {num} {unit},{date} {month} {year?} {2},{month} {year},{1} {shift} {unit=5-7};{d} {month} {yyyy} \u0433\u043e\u0434\u0430;\u043f\u043e\u0437\u0430\u0432\u0447\u0435\u0440\u0430,\u0432\u0447\u0435\u0440\u0430,\u0441\u0435\u0433\u043e\u0434\u043d\u044f,\u0437\u0430\u0432\u0442\u0440\u0430,\u043f\u043e\u0441\u043b\u0435\u0437\u0430\u0432\u0442\u0440\u0430;,\u043d\u0430\u0437\u0430\u0434,,\u0447\u0435\u0440\u0435\u0437;,\u043f\u0440\u043e\u0448\u043b\u043e:\u0439|\u043c,,\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435:\u0439|\u043c",
@@ -75,11 +75,11 @@ function Ja(a){function b(e){return!!(d[0]&Math.pow(2,e-1))}if(a.slice(0,3)=="en
else c.numbers=V.split("");c.monthSuffix=d[1]}c.capitalizeUnit=a=="de";c.hasPlural=b(2);c.pastRelativeFormat=c.formats[0];c.futureRelativeFormat=c.formats[b(3)?1:0];return c}function La(a){a||(a=Date.currentLocale);return a!="en"&&a!="en-US"}function Ka(a){p.merge(this,a)}
w(Ka,i,l,{getMonth:function(a){return p.isNumber(a)?a-1:z(this.months,r(a,"i"),0,l,i)%12},o:function(a){return z(this.weekdays,r(a,"i"),0,l,i)%7},n:function(a){var b;return p.isNumber(a)?a:a&&(b=N(this.numbers,a,0,1))!==-1?(b+1)%10:1},s:function(a){var b=this;return a.replace(this.numbers[9],"").each(function(c){return b.n(c)}).join("")},r:function(a){return English.units[N(this.units,a,0,1)%8]},w:function(a,b,c){var d,e;d=c>0?this.futureRelativeFormat:this.pastRelativeFormat;if(this.code=="ru"){e=
a.toString().from(-1);switch(i){case e==1:e=1;break;case e>=2&&e<=4:e=2;break;default:e=3}}else e=this.hasPlural&&a>1?1:0;e=this.units[e*8+b]||this.units[b];if(this.capitalizeUnit)e=e.capitalize();b=z(this.modifiers,function(f){return f.name=="sign"&&f.value==(c>0?1:-1)});return d.assign({num:a,unit:e,sign:b.text})}});function Z(a){var b;if(J(a[0]))return a;else if(a.length==1&&p.isNumber(a[0]))return[a[0]];b={};I(Ca,function(c,d){b[c.a]=a[d]});return[b]}
-function Ma(a,b){if(b!="date"&&b!="month"&&b!="year")return a;return a.replace(Aa,function(c){return V.indexOf(c)+1||""})}function Na(a,b){var c={},d,e;I(b,function(f,h){d=a[h+1];if(!(A(d)||d==="")){d=Ma(d.hankaku("n"),f);if(f==="year")c.z=d;if(f==="millisecond")d*=Math.pow(10,3-d.length);e=parseFloat(d);c[f]=!isNaN(e)?e:d.toLowerCase()}});return c}
-function Qa(a,b){var c=new s,d=l,e,f,h,g,k,n,o;if(p.isDate(a))c=a;else if(p.isNumber(a))c=new s(a);else if(p.isObject(a)){c=(new s).set(a,i);g=a}else if(p.isString(a)){Ha(Y(b,i));f=La(b);a=a.trim().replace(/\.+$/,"").replace(/^now$/,"");I(Ba,function(u){var H=a.match(u.v);if(H){h=u;g=Na(H,h.to);e=Y(h.u,i);if(h.k&&!p.isString(g.month)&&(p.isString(g.date)||f)){o=g.month;g.month=g.date;g.date=o}if(g.year&&g.z.length===2)g.year=Q((new s).getFullYear()/100)*100-Q(g.year/100)*100+g.year;if(g.month){g.month=
-e.getMonth(g.month);if(g.shift&&!g.unit)g.unit="year"}if(g.weekday&&g.date)delete g.weekday;else if(g.weekday){g.weekday=e.o(g.weekday);if(g.shift&&!g.unit)g.unit="week"}if(g.day&&(o=e.i[g.day])){g.day=o.value;c.resetTime();d=i}else if(g.day&&(o=e.o(g.day))>-1){delete g.day;g.weekday=o}if(g.date&&!p.isNumber(g.date))g.date=e.s(g.date);if(g.meridian)if(g.meridian==="pm"&&g.hour<12)g.hour+=12;if(g.offset_hours||g.offset_minutes){g.utc=i;g.offset_minutes=g.offset_minutes||0;g.offset_minutes+=g.offset_hours*
-60;if(g.offset_sign==="-")g.offset_minutes*=-1;g.minute-=g.offset_minutes}if(g.unit){d=i;n=e.n(g.num);k=e.r(g.unit);if(g.shift||g.edge){n*=(o=e.i[g.shift])?o.value:0;if(k==="month"&&K(g.date)){c.set({day:g.date},i);delete g.date}if(k==="year"&&K(g.month)){c.set({month:g.month,day:g.date},i);delete g.month;delete g.date}}if(g.sign&&(o=e.i[g.sign]))n*=o.value;if(K(g.weekday)){c.set({weekday:g.weekday},i);delete g.weekday}g[k]=(g[k]||0)+n}if(g.year_sign==="-")g.year*=-1;return l}});if(h)if(d)c.advance(g);
-else g.utc?c.setUTC(g,i):c.set(g,i);else c=a?new s(a):new s;if(g&&g.edge){o=e.i[g.edge];I(W.slice(4),function(u){if(K(g[u.a])){k=u.a;return l}});if(k==="year")g.f="month";else if(k==="month"||k==="week")g.f="day";c[(o.value<0?"endOf":"beginningOf")+k.capitalize()]();o.value===-2&&c.resetTime()}}return{h:c,set:g}}
+function Ma(a,b){if(b!="date"&&b!="month"&&b!="year")return a;return a.replace(Aa,function(c){return V.indexOf(c)+1||""})}function Na(a,b){var c={},d,e;I(b,function(f,h){d=a[h+1];if(!(A(d)||d==="")){d=Ma(d.hankaku("n"),f);if(f==="year")c.A=d;if(f==="millisecond")d*=Math.pow(10,3-d.length);e=parseFloat(d);c[f]=!isNaN(e)?e:d.toLowerCase()}});return c}
+function Qa(a,b){var c=new s,d=l,e,f,h,g,k,n,o;if(p.isDate(a))c=a;else if(p.isNumber(a))c=new s(a);else if(p.isObject(a)){c=(new s).set(a,i);g=a}else if(p.isString(a)){Ha(Y(b,i));f=La(b);a=a.trim().replace(/\.+$/,"").replace(/^now$/,"");I(Ba,function(u){var H=a.match(u.v);if(H){h=u;g=Na(H,h.to);e=Y(h.u,i);if(g.timestamp){c.setTime(0);g={milliseconds:g.timestamp};return l}if(h.k&&!p.isString(g.month)&&(p.isString(g.date)||f)){o=g.month;g.month=g.date;g.date=o}if(g.year&&g.A.length===2)g.year=Q((new s).getFullYear()/
+100)*100-Q(g.year/100)*100+g.year;if(g.month){g.month=e.getMonth(g.month);if(g.shift&&!g.unit)g.unit="year"}if(g.weekday&&g.date)delete g.weekday;else if(g.weekday){g.weekday=e.o(g.weekday);if(g.shift&&!g.unit)g.unit="week"}if(g.day&&(o=e.i[g.day])){g.day=o.value;c.resetTime();d=i}else if(g.day&&(o=e.o(g.day))>-1){delete g.day;g.weekday=o}if(g.date&&!p.isNumber(g.date))g.date=e.s(g.date);if(g.meridian)if(g.meridian==="pm"&&g.hour<12)g.hour+=12;if(g.offset_hours||g.offset_minutes){g.utc=i;g.offset_minutes=
+g.offset_minutes||0;g.offset_minutes+=g.offset_hours*60;if(g.offset_sign==="-")g.offset_minutes*=-1;g.minute-=g.offset_minutes}if(g.unit){d=i;n=e.n(g.num);k=e.r(g.unit);if(g.shift||g.edge){n*=(o=e.i[g.shift])?o.value:0;if(k==="month"&&K(g.date)){c.set({day:g.date},i);delete g.date}if(k==="year"&&K(g.month)){c.set({month:g.month,day:g.date},i);delete g.month;delete g.date}}if(g.sign&&(o=e.i[g.sign]))n*=o.value;if(K(g.weekday)){c.set({weekday:g.weekday},i);delete g.weekday}g[k]=(g[k]||0)+n}if(g.year_sign===
+"-")g.year*=-1;return l}});if(h)if(d)c.advance(g);else g.utc?c.setUTC(g,i):c.set(g,i);else c=a?new s(a):new s;if(g&&g.edge){o=e.i[g.edge];I(W.slice(4),function(u){if(K(g[u.a])){k=u.a;return l}});if(k==="year")g.f="month";else if(k==="month"||k==="week")g.f="day";c[(o.value<0?"endOf":"beginningOf")+k.capitalize()]();o.value===-2&&c.resetTime()}}return{h:c,set:g}}
function Ra(a,b,c,d){var e,f=Y(d,i),h=r(/^[A-Z]/);if(a.isValid())if(Date[b])b=Date[b];else{if(p.isFunction(b)){e=Sa(a);b=b.apply(a,e.concat(f))}}else return"Invalid Date";if(!b&&!c)b=f.outputFormat;else if(!b&&c){e=e||Sa(a);if(e[1]===0){e[1]=1;e[0]=1}return f.w(e[0],e[1],e[2])}I(Ea,function(g){b=b.replace(r("\\{("+g.c+")(\\d)?\\}",g.l?"i":""),function(k,n,o){k=g.b(a,f,o||1,n);o=n.length;var u=n.match(/^(.)\1+$/);if(g.l){if(o===3)k=k.to(3);if(u||n.match(h))k=k.capitalize()}else if(u&&!g.text)k=(p.isNumber(k)?
k.pad(o):k.toString()).last(o);return k})});return b}function Ta(a,b,c){var d=Qa(b),e=0,f=b=0,h;if(c>0){b=f=c;h=i}if(!d.h.isValid())return l;if(d.set&&d.set.f){I(X,function(k){if(k.a===d.set.f)e=k.e(d.h,a-d.h)-1});if(d.set.edge||d.set.shift)d.h["beginningOf"+d.set.f.capitalize()]();if(!h&&d.set.sign&&d.set.f!="millisecond"){b=50;f=-50}}c=a.getTime();h=d.h.getTime();var g=h+e;if(d.set&&d.set.f=="week"&&(new Date(g+1)).getHours()!=0)g-=s.DSTOffset;return c>=h-b&&c<=g+f}
function $(a,b,c,d,e){if(p.isNumber(b)&&e)b={milliseconds:b};else if(p.isNumber(b)){a.setTime(b);return a}if(b.date)b.day=b.date;if(!e&&A(b.day)&&K(b.weekday)){a["set"+(d?"UTC":"")+"Weekday"](b.weekday);b.day=a["get"+(d?"UTC":"")+"Date"](void 0);delete b.weekday}I(W,function(f){if(K(b[f.a])||K(b[f.a+"s"])){b.f=f.a;return l}else if(c&&f.a!=="week"&&f.a!=="year")a["set"+(d?"UTC":"")+f.method](f.a==="day"?1:0)});I(X,function(f){var h=f.a;f=f.method;var g=K(b[h])?b[h]:b[h+"s"];if(!A(g)){if(e){if(h===
@@ -90,7 +90,7 @@ w(s,i,l,{set:function(){var a=Z(arguments);return $(this,a[0],a[1])},setUTC:func
return $(this,a[0],l,l,1,i)},rewind:function(){var a=Z(arguments);return $(this,a[0],l,l,-1)},isValid:function(){return!isNaN(this.getTime())},isAfter:function(a,b){return this.getTime()>s.create(a).getTime()-(b||0)},isBefore:function(a,b){return this.getTime()<s.create(a).getTime()+(b||0)},isBetween:function(a,b,c){var d=this.getTime();a=s.create(a).getTime();var e=s.create(b).getTime();b=Math.min(a,e);a=Math.max(a,e);c=c||0;return b-c<d&&a+c>d},isLeapYear:function(){var a=this.getFullYear();return a%
4===0&&a%100!==0||a%400===0},daysInMonth:function(){return 32-(new s(this.getFullYear(),this.getMonth(),32)).getDate()},format:function(a,b){return Ra(this,a,l,b)},relative:function(a,b){if(p.isString(a)){b=a;a=j}return Ra(this,a,i,b)},is:function(a,b){var c;if(p.isString(a)){a=a.trim().toLowerCase();switch(i){case a==="future":return this.getTime()>(new s).getTime();case a==="past":return this.getTime()<(new s).getTime();case a==="weekday":return this.getDay()>0&&this.getDay()<6;case a==="weekend":return this.getDay()===
0||this.getDay()===6;case (c=N(English.weekdays,a,0,1)%7)>-1:return this.getDay()===c;case (c=N(English.months,a,0,1)%12)>-1:return this.getMonth()===c}}return Ta(this,a,b)},resetTime:function(){return this.set({hour:0,minute:0,second:0,millisecond:0})},clone:function(){return new s(this.getTime())},compare:function(){return this-S(arguments)}});w(s,i,l,{getWeekday:s.prototype.getDay,getUTCWeekday:s.prototype.getUTCDay});r.m=A(r("()??").exec("")[1]);
-function Ua(a,b){var c="";if(b=="g"||a.global)c+="g";if(b=="i"||a.ignoreCase)c+="i";if(b=="m"||a.multiline)c+="m";if(b=="y"||a.A)c+="y";return c}w(r,l,l,{escape:function(a){return a.replace(/([/'*+?|()\[\]{}.^$])/g,"\\$1")}});w(r,i,l,{getFlags:function(){return Ua(this)},setFlags:function(a){return r(this.source,a)},addFlag:function(a){return this.setFlags(Ua(this,a))},removeFlag:function(a){return this.setFlags(Ua(this).replace(a,""))}});
+function Ua(a,b){var c="";if(b=="g"||a.global)c+="g";if(b=="i"||a.ignoreCase)c+="i";if(b=="m"||a.multiline)c+="m";if(b=="y"||a.B)c+="y";return c}w(r,l,l,{escape:function(a){return a.replace(/([/'*+?|()\[\]{}.^$])/g,"\\$1")}});w(r,i,l,{getFlags:function(){return Ua(this)},setFlags:function(a){return r(this.source,a)},addFlag:function(a){return this.setFlags(Ua(this,a))},removeFlag:function(a){return this.setFlags(Ua(this).replace(a,""))}});
function Va(a,b,c,d,e){if(!a.g)a.g=[];a.g.push(setTimeout(function(){a.g.removeAt(f);c.apply(d,e||[])},b));var f=a.g.length}
w(Function,i,l,{lazy:function(a,b){function c(){if(!(h||f.length==0)){for(var n=Math.max(f.length-k,0);f.length>n;)Function.prototype.apply.apply(e,f.shift());Va(d,g,function(){h=l;c()});h=i}}function d(){if(!(h&&f.length>b-2)){f.push([this,arguments]);c()}}var e=this,f=[],h=l,g,k;a=a||1;b=b||Infinity;g=a.ceil();k=Q(g/a);return d},delay:function(a){p.isNumber(a)||(a=0);var b=E(arguments,1);Va(this,a,this,this,b);return this},debounce:function(a,b){var c=this;return b===l?this.lazy(a,1):function(){c.cancel();
Va(c,a,c,this,arguments)}},cancel:function(){if(p.isArray(this.g))for(;this.g.length>0;)clearTimeout(this.g.shift());return this},after:function(a){var b=this,c=0,d=[];if(p.isNumber(a)){if(a===0){b.call();return b}}else a=1;return function(){var e;d.push(Array.create(arguments));c++;if(c==a){e=b.call(this,d);c=0;d=[];return e}}},once:function(){var a=this;return function(){return a.hasOwnProperty("memo")?a.memo:a.memo=a.apply(this,arguments)}},fill:function(){var a=this,b=E(arguments);return function(){var c=
@@ -104,7 +104,7 @@ U("k",a,b);b.match(ta)&&U("k",a+"\uff9e",b.shift(1));b.match(ua)&&U("k",a+"\uff9
{d:["Thai"],source:"\u0e00-\u0e7f"}].each(function(a){var b=r("^["+a.source+"\\s]+$"),c=r("["+a.source+"]");a.d.each(function(d){y(t.prototype,"is"+d,function(){return b.test(this.trim())});y(t.prototype,"has"+d,function(){return c.test(this)})})});English=s.setLocale("en");
I(X,function(a,b){var c=a.a,d=c.capitalize(),e=a.e();y(s.prototype,c+"sSince",function(f,h){return Q((this.getTime()-s.create(f,h).getTime())/e)});y(s.prototype,c+"sUntil",function(f,h){return Q((s.create(f,h).getTime()-this.getTime())/e)});y(s.prototype,c+"sAgo",s.prototype[c+"sUntil"]);y(s.prototype,c+"sFromNow",s.prototype[c+"sSince"]);y(s.prototype,"add"+d+"s",function(f){var h={};h[c]=f;return this.advance(h)});ma(c,e);b<3&&I(["Last","This","Next"],function(f){y(s.prototype,"is"+f+d,function(){return this.is(f+
" "+c)})});if(b<4){y(s.prototype,"beginningOf"+d,function(){var f={};switch(c){case "year":f.year=this.getFullYear();break;case "month":f.month=this.getMonth();break;case "day":f.day=this.getDate();break;case "week":f.weekday=0}return this.set(f,i)});y(s.prototype,"endOf"+d,function(){var f={hours:23,minutes:59,seconds:59,milliseconds:999};switch(c){case "year":f.month=11;f.day=31;break;case "month":f.day=this.daysInMonth();break;case "week":f.weekday=6}return this.set(f,i)})}});
-(function(){Ca=X.clone().removeAt(2);W=X.clone().reverse();var a="\\d{1,2}|"+English.months.join("|");I(Da,function(b){s.addFormat(b.src.replace(/\{month\}/,a)+xa,b.to.concat(va),"en",b.k)});s.addFormat(wa,va)})();(function(){var a=English.weekdays.slice(0,7),b=English.months.slice(0,12);I(["today","yesterday","tomorrow","weekday","weekend","future","past"].concat(a).concat(b),function(c){y(s.prototype,"is"+c.capitalize(),function(){return this.is(c)})})})();
+(function(){Ca=X.clone().removeAt(2);W=X.clone().reverse();var a="\\d{1,2}|"+English.months.join("|");I(Da,function(b){s.addFormat(b.src.replace(/\{month\}/,a)+(b.z===l?"":xa),b.to.concat(va),"en",b.k)});s.addFormat(wa,va)})();(function(){var a=English.weekdays.slice(0,7),b=English.months.slice(0,12);I(["today","yesterday","tomorrow","weekday","weekend","future","past"].concat(a).concat(b),function(c){y(s.prototype,"is"+c.capitalize(),function(){return this.is(c)})})})();
w(s,l,i,{DSTOffset:((new s(2E3,6,1)).getTimezoneOffset()-(new s(2E3,0,1)).getTimezoneOffset())*60*1E3,INTERNATIONAL_TIME:"{h}:{mm}:{ss}",RFC1123:"{Dow}, {dd} {Mon} {yyyy} {HH}:{mm}:{ss} {tz}",RFC1036:"{Weekday}, {dd}-{Mon}-{yy} {HH}:{mm}:{ss} {tz}",ISO8601_DATE:"{yyyy}-{MM}-{dd}",ISO8601_DATETIME:"{yyyy}-{MM}-{dd}T{HH}:{mm}:{ss}.{fff}{isotz}"});
(function(){var a=new s(s.UTC(1999,11,31));if(!a.toISOString||a.toISOString()!=="1999-12-31T00:00:00.000Z")w(s,i,i,{toISOString:function(){return Ra(this.toUTC(),s.ISO8601_DATETIME)}});if(!a.toJSON||a.toJSON()!=="1999-12-31T00:00:00.000Z")w(s,i,i,{toJSON:s.prototype.toISOString});w(s,i,l,{iso:s.prototype.toISOString})})();
(function(){var a=l;if(Function.prototype.p){a=function(){};var b=a.p();a=new b instanceof b&&!(new a instanceof b)}w(Function,i,!a,{bind:function(c){var d=this,e=E(arguments,1),f,h;if(!p.isFunction(this))throw new TypeError("Function.prototype.bind called on a non-function");h=function(){return d.apply(d.prototype&&this instanceof d?this:c,e.concat(E(arguments)))};f=function(){};f.prototype=this.prototype;h.prototype=new f;return h}})})();})();
View
22 release/utf8/sugar-edge.min.js
@@ -53,10 +53,10 @@ a=String(a);if(b===i)b=/\W/g;if(b){a=a.remove(b);c=c.remove(b)}return c==a?0:c<a
w(t,i,function(a){return!p.isRegExp(a)},{split:function(a,b){var c=[],d=0;a=r(a).addFlag("g");var e,f,h,g;r.m||(e=RegExp("^"+a.source+"$(?!\\s)",a.getFlags()));if(A(b)||+b<0)b=Infinity;else{b=(+b).floor();if(!b)return[]}for(;f=a.exec(this);){h=f.index+f[0].length;if(h>d){c.push(this.slice(d,f.index));!r.m&&f.length>1&&f[0].replace(e,function(){for(var k=1;k<arguments.length-2;k++)if(A(arguments[k]))f[k]=void 0});f.length>1&&f.index<this.length&&q.prototype.push.apply(c,f.slice(1));g=f[0].length;d=
h;if(c.length>=b)break}a.lastIndex===f.index&&a.lastIndex++}if(d===this.length){if(g||!a.test(""))c.push("")}else c.push(this.slice(d));return c.length>b?c.slice(0,b):c}});w(t,i,l,{insert:t.prototype.add});
var va=["hour","minute","second","millisecond","meridian","utc","offset_sign","offset_hours","offset_minutes"],wa="(\\d{1,2}):?(\\d{2})?:?(\\d{2})?(?:\\.(\\d{1,6}))?(am|pm)?(?:(Z)|(?:([+-])(\\d{2})(?::?(\\d{2}))?)?)?",xa="\\s*(?:(?:t|at |\\s+)"+wa+")?",V="一二三四五六七八九",za="十百千万",Aa=r("["+V+za+"]","g"),Ba=[],Ca,W,Da=[{src:"(\\d{4})",to:["year"]},{src:"([+-])?(\\d{4})[-.]?({month})[-.]?(\\d{1,2})?",to:["year_sign","year","month","date"]},{src:"(\\d{1,2})[-.\\/]({month})[-.\\/]?(\\d{2,4})?",to:["month",
-"date","year"],k:i}],Ea=[{c:"f{1,4}|ms|milliseconds",b:function(a){return a.getMilliseconds()}},{c:"ss?|seconds",b:function(a){return a.getSeconds()}},{c:"mm?|minutes",b:function(a){return a.getMinutes()}},{c:"hh?|hours|12hr",b:function(a){a=a.getHours(void 0);return a===0?12:a-(a/13).floor()*12}},{c:"HH?|24hr",b:function(a){return a.getHours()}},{c:"dd?|date|day",b:function(a){return a.getDate()}},{c:"dow|weekday",l:i,b:function(a,b,c){return b.weekdays[a.getDay()+(c-1)*7]}},{c:"MM?",b:function(a){return a.getMonth()+
-1}},{c:"mon|month",l:i,b:function(a,b,c){return b.months[a.getMonth()+(c-1)*12]}},{c:"y{2,4}|year",b:function(a){return a.getFullYear()}},{c:"[Tt]{1,2}",b:function(a,b,c,d){a=a.getHours(void 0)<12?"am":"pm";if(d.length===1)a=a.first();if(d.first()==="T")a=a.toUpperCase();return a}},{c:"z{1,4}|tz|timezone",text:i,b:function(a,b,c,d){a=a.getUTCOffset();if(d=="z"||d=="zz")a=a.replace(/(\d{2})(\d{2})/,function(e,f){return f.toNumber().pad(d.length)});return a}},{c:"iso(tz|timezone)",b:function(a){return a.getUTCOffset(i)}},
-{c:"ord",b:function(a){return a.getDate().ordinalize()}}],X=[{a:"year",method:"FullYear",e:function(a){return(365+(a?a.isLeapYear()?1:0:0.25))*24*60*60*1E3}},{a:"month",method:"Month",e:function(a,b){var c=30.4375,d;if(a){d=a.daysInMonth();if(b<=d.days())c=d}return c*24*60*60*1E3}},{a:"week",method:"Week",e:m(6048E5)},{a:"day",method:"Date",e:m(864E5)},{a:"hour",method:"Hours",e:m(36E5)},{a:"minute",method:"Minutes",e:m(6E4)},{a:"second",method:"Seconds",e:m(1E3)},{a:"millisecond",method:"Milliseconds",
-e:m(1)}],Fa={},Ga={en:"2;;January,February,March,April,May,June,July,August,September,October,November,December;Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday;millisecond:|s,second:|s,minute:|s,hour:|s,day:|s,week:|s,month:|s,year:|s;one,two,three,four,five,six,seven,eight,nine,ten;a,an,the;the,st|nd|rd|th,of;{num} {unit} {sign},{num} {unit=4-5} {sign} {day},{weekday?} {month} {date}{2} {year?} {time?},{date} {month} {year},{month} {year},{shift?} {weekday} {time?},{shift} week {weekday} {time?},{shift} {unit=5-7},{1} {edge} of {shift?} {unit=4-7?}{month?}{year?},{weekday} {3} {shift} week,{1} {date}{2} of {month},{1}{month?} {date?}{2} of {shift} {unit=6-7},{day} at {time?},{time} {day};{Month} {d}, {yyyy};,yesterday,today,tomorrow;,ago|before,,from now|after|from;,last,the|this,next;last day,end,,first day|beginning",
+"date","year"],k:i},{src:"\\/Date\\((\\d+(?:\\+\\d{4})?)\\)\\/",to:["timestamp"],z:l}],Ea=[{c:"f{1,4}|ms|milliseconds",b:function(a){return a.getMilliseconds()}},{c:"ss?|seconds",b:function(a){return a.getSeconds()}},{c:"mm?|minutes",b:function(a){return a.getMinutes()}},{c:"hh?|hours|12hr",b:function(a){a=a.getHours(void 0);return a===0?12:a-(a/13).floor()*12}},{c:"HH?|24hr",b:function(a){return a.getHours()}},{c:"dd?|date|day",b:function(a){return a.getDate()}},{c:"dow|weekday",l:i,b:function(a,
+b,c){return b.weekdays[a.getDay()+(c-1)*7]}},{c:"MM?",b:function(a){return a.getMonth()+1}},{c:"mon|month",l:i,b:function(a,b,c){return b.months[a.getMonth()+(c-1)*12]}},{c:"y{2,4}|year",b:function(a){return a.getFullYear()}},{c:"[Tt]{1,2}",b:function(a,b,c,d){a=a.getHours(void 0)<12?"am":"pm";if(d.length===1)a=a.first();if(d.first()==="T")a=a.toUpperCase();return a}},{c:"z{1,4}|tz|timezone",text:i,b:function(a,b,c,d){a=a.getUTCOffset();if(d=="z"||d=="zz")a=a.replace(/(\d{2})(\d{2})/,function(e,f){return f.toNumber().pad(d.length)});
+return a}},{c:"iso(tz|timezone)",b:function(a){return a.getUTCOffset(i)}},{c:"ord",b:function(a){return a.getDate().ordinalize()}}],X=[{a:"year",method:"FullYear",e:function(a){return(365+(a?a.isLeapYear()?1:0:0.25))*24*60*60*1E3}},{a:"month",method:"Month",e:function(a,b){var c=30.4375,d;if(a){d=a.daysInMonth();if(b<=d.days())c=d}return c*24*60*60*1E3}},{a:"week",method:"Week",e:m(6048E5)},{a:"day",method:"Date",e:m(864E5)},{a:"hour",method:"Hours",e:m(36E5)},{a:"minute",method:"Minutes",e:m(6E4)},
+{a:"second",method:"Seconds",e:m(1E3)},{a:"millisecond",method:"Milliseconds",e:m(1)}],Fa={},Ga={en:"2;;January,February,March,April,May,June,July,August,September,October,November,December;Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday;millisecond:|s,second:|s,minute:|s,hour:|s,day:|s,week:|s,month:|s,year:|s;one,two,three,four,five,six,seven,eight,nine,ten;a,an,the;the,st|nd|rd|th,of;{num} {unit} {sign},{num} {unit=4-5} {sign} {day},{weekday?} {month} {date}{2} {year?} {time?},{date} {month} {year},{month} {year},{shift?} {weekday} {time?},{shift} week {weekday} {time?},{shift} {unit=5-7},{1} {edge} of {shift?} {unit=4-7?}{month?}{year?},{weekday} {3} {shift} week,{1} {date}{2} of {month},{1}{month?} {date?}{2} of {shift} {unit=6-7},{day} at {time?},{time} {day};{Month} {d}, {yyyy};,yesterday,today,tomorrow;,ago|before,,from now|after|from;,last,the|this,next;last day,end,,first day|beginning",
ja:"1;月;;日曜日,月曜日,火曜日,水曜日,木曜日,金曜日,土曜日;ミリ秒,秒,分,時間,日,週間|週,ヶ月|ヵ月|月,年;;;;{num}{unit}{sign},{shift}{unit=5-7}{weekday?},{year}年{month?}月?{date?}日?,{month}月{date?}日?,{date}日;{yyyy}年{M}月{d}日;一昨日,昨日,今日,明日,明後日;,前,,後;,去|先,,来",ko:"1;월;;일요일,월요일,화요일,수요일,목요일,금요일,토요일;밀리초,초,분,시간,일,주,개월|달,년;일|한,이,삼,사,오,육,칠,팔,구,십;;;{num}{unit} {sign},{shift} {unit=5-7},{shift} {unit=5?} {weekday},{year}년{month?}월?{date?}일?,{month}월{date?}일?,{date}일;{yyyy}년{M}월{d}일;그저께,어제,오늘,내일,모레;,전,,후;,지난|작,이번,다음|내",ru:"4;;Январ:я|ь,Феврал:я|ь,Март:а|,Апрел:я|ь,Ма:я|й,Июн:я|ь,Июл:я|ь,Август:а|,Сентябр:я|ь,Октябр:я|ь,Ноябр:я|ь,Декабр:я|ь;Воскресенье,Понедельник,Вторник,Среда,Четверг,Пятница,Суббота;миллисекунд:а|у|ы|,секунд:а|у|ы|,минут:а|у|ы|,час:||а|ов,день|день|дня|дней,недел:я|ю|и|ь|е,месяц:||а|ев|е,год|год|года|лет|году;од:ин|ну,дв:а|е,три,четыре,пять,шесть,семь,восемь,девять,десять;;в|на,года;{num} {unit} {sign},{sign} {num} {unit},{date} {month} {year?} {2},{month} {year},{1} {shift} {unit=5-7};{d} {month} {yyyy} года;позавчера,вчера,сегодня,завтра,послезавтра;,назад,,через;,прошло:й|м,,следующе:й|м",
es:"6;;enero,febrero,marzo,abril,mayo,junio,julio,agosto,septiembre,octubre,noviembre,diciembre;domingo,lunes,martes,miércoles|miercoles,jueves,viernes,sábado|sabado;milisegundo:|s,segundo:|s,minuto:|s,hora:|s,día|días|dia|dias,semana:|s,mes:|es,año|años|ano|anos;uno,dos,tres,cuatro,cinco,seis,siete,ocho,nueve,diez;;el,de;{sign} {num} {unit},{num} {unit} {sign},{date?} {2} {month} {2} {year?},{1} {unit=5-7} {shift},{1} {shift} {unit=5-7};{d} de {month} de {yyyy};anteayer,ayer,hoy,mañana|manana;,hace,,de ahora;,pasad:o|a,,próximo|próxima|proximo|proxima",
pt:"6;;janeiro,fevereiro,março,abril,maio,junho,julho,agosto,setembro,outubro,novembro,dezembro;domingo,segunda-feira,terça-feira,quarta-feira,quinta-feira,sexta-feira,sábado|sabado;milisegundo:|s,segundo:|s,minuto:|s,hora:|s,dia:|s,semana:|s,mês|mêses|mes|meses,ano:|s;um,dois,três|tres,quatro,cinco,seis,sete,oito,nove,dez,uma,duas;;a,de;{num} {unit} {sign},{sign} {num} {unit},{date?} {2} {month} {2} {year?},{1} {unit=5-7} {shift},{1} {shift} {unit=5-7};{d} de {month} de {yyyy};anteontem,ontem,hoje,amanh:ã|a;,atrás|atras|há|ha,,daqui a;,passad:o|a,,próximo|próxima|proximo|proxima",
@@ -72,11 +72,11 @@ function Ja(a){function b(e){return!!(d[0]&Math.pow(2,e-1))}if(a.slice(0,3)=="en
else c.numbers=V.split("");c.monthSuffix=d[1]}c.capitalizeUnit=a=="de";c.hasPlural=b(2);c.pastRelativeFormat=c.formats[0];c.futureRelativeFormat=c.formats[b(3)?1:0];return c}function La(a){a||(a=Date.currentLocale);return a!="en"&&a!="en-US"}function Ka(a){p.merge(this,a)}
w(Ka,i,l,{getMonth:function(a){return p.isNumber(a)?a-1:z(this.months,r(a,"i"),0,l,i)%12},o:function(a){return z(this.weekdays,r(a,"i"),0,l,i)%7},n:function(a){var b;return p.isNumber(a)?a:a&&(b=N(this.numbers,a,0,1))!==-1?(b+1)%10:1},s:function(a){var b=this;return a.replace(this.numbers[9],"").each(function(c){return b.n(c)}).join("")},r:function(a){return English.units[N(this.units,a,0,1)%8]},w:function(a,b,c){var d,e;d=c>0?this.futureRelativeFormat:this.pastRelativeFormat;if(this.code=="ru"){e=
a.toString().from(-1);switch(i){case e==1:e=1;break;case e>=2&&e<=4:e=2;break;default:e=3}}else e=this.hasPlural&&a>1?1:0;e=this.units[e*8+b]||this.units[b];if(this.capitalizeUnit)e=e.capitalize();b=z(this.modifiers,function(f){return f.name=="sign"&&f.value==(c>0?1:-1)});return d.assign({num:a,unit:e,sign:b.text})}});function Z(a){var b;if(J(a[0]))return a;else if(a.length==1&&p.isNumber(a[0]))return[a[0]];b={};I(Ca,function(c,d){b[c.a]=a[d]});return[b]}
-function Ma(a,b){if(b!="date"&&b!="month"&&b!="year")return a;return a.replace(Aa,function(c){return V.indexOf(c)+1||""})}function Na(a,b){var c={},d,e;I(b,function(f,h){d=a[h+1];if(!(A(d)||d==="")){d=Ma(d.hankaku("n"),f);if(f==="year")c.z=d;if(f==="millisecond")d*=Math.pow(10,3-d.length);e=parseFloat(d);c[f]=!isNaN(e)?e:d.toLowerCase()}});return c}
-function Qa(a,b){var c=new s,d=l,e,f,h,g,k,n,o;if(p.isDate(a))c=a;else if(p.isNumber(a))c=new s(a);else if(p.isObject(a)){c=(new s).set(a,i);g=a}else if(p.isString(a)){Ha(Y(b,i));f=La(b);a=a.trim().replace(/\.+$/,"").replace(/^now$/,"");I(Ba,function(u){var H=a.match(u.v);if(H){h=u;g=Na(H,h.to);e=Y(h.u,i);if(h.k&&!p.isString(g.month)&&(p.isString(g.date)||f)){o=g.month;g.month=g.date;g.date=o}if(g.year&&g.z.length===2)g.year=Q((new s).getFullYear()/100)*100-Q(g.year/100)*100+g.year;if(g.month){g.month=
-e.getMonth(g.month);if(g.shift&&!g.unit)g.unit="year"}if(g.weekday&&g.date)delete g.weekday;else if(g.weekday){g.weekday=e.o(g.weekday);if(g.shift&&!g.unit)g.unit="week"}if(g.day&&(o=e.i[g.day])){g.day=o.value;c.resetTime();d=i}else if(g.day&&(o=e.o(g.day))>-1){delete g.day;g.weekday=o}if(g.date&&!p.isNumber(g.date))g.date=e.s(g.date);if(g.meridian)if(g.meridian==="pm"&&g.hour<12)g.hour+=12;if(g.offset_hours||g.offset_minutes){g.utc=i;g.offset_minutes=g.offset_minutes||0;g.offset_minutes+=g.offset_hours*
-60;if(g.offset_sign==="-")g.offset_minutes*=-1;g.minute-=g.offset_minutes}if(g.unit){d=i;n=e.n(g.num);k=e.r(g.unit);if(g.shift||g.edge){n*=(o=e.i[g.shift])?o.value:0;if(k==="month"&&K(g.date)){c.set({day:g.date},i);delete g.date}if(k==="year"&&K(g.month)){c.set({month:g.month,day:g.date},i);delete g.month;delete g.date}}if(g.sign&&(o=e.i[g.sign]))n*=o.value;if(K(g.weekday)){c.set({weekday:g.weekday},i);delete g.weekday}g[k]=(g[k]||0)+n}if(g.year_sign==="-")g.year*=-1;return l}});if(h)if(d)c.advance(g);
-else g.utc?c.setUTC(g,i):c.set(g,i);else c=a?new s(a):new s;if(g&&g.edge){o=e.i[g.edge];I(W.slice(4),function(u){if(K(g[u.a])){k=u.a;return l}});if(k==="year")g.f="month";else if(k==="month"||k==="week")g.f="day";c[(o.value<0?"endOf":"beginningOf")+k.capitalize()]();o.value===-2&&c.resetTime()}}return{h:c,set:g}}
+function Ma(a,b){if(b!="date"&&b!="month"&&b!="year")return a;return a.replace(Aa,function(c){return V.indexOf(c)+1||""})}function Na(a,b){var c={},d,e;I(b,function(f,h){d=a[h+1];if(!(A(d)||d==="")){d=Ma(d.hankaku("n"),f);if(f==="year")c.A=d;if(f==="millisecond")d*=Math.pow(10,3-d.length);e=parseFloat(d);c[f]=!isNaN(e)?e:d.toLowerCase()}});return c}
+function Qa(a,b){var c=new s,d=l,e,f,h,g,k,n,o;if(p.isDate(a))c=a;else if(p.isNumber(a))c=new s(a);else if(p.isObject(a)){c=(new s).set(a,i);g=a}else if(p.isString(a)){Ha(Y(b,i));f=La(b);a=a.trim().replace(/\.+$/,"").replace(/^now$/,"");I(Ba,function(u){var H=a.match(u.v);if(H){h=u;g=Na(H,h.to);e=Y(h.u,i);if(g.timestamp){c.setTime(0);g={milliseconds:g.timestamp};return l}if(h.k&&!p.isString(g.month)&&(p.isString(g.date)||f)){o=g.month;g.month=g.date;g.date=o}if(g.year&&g.A.length===2)g.year=Q((new s).getFullYear()/
+100)*100-Q(g.year/100)*100+g.year;if(g.month){g.month=e.getMonth(g.month);if(g.shift&&!g.unit)g.unit="year"}if(g.weekday&&g.date)delete g.weekday;else if(g.weekday){g.weekday=e.o(g.weekday);if(g.shift&&!g.unit)g.unit="week"}if(g.day&&(o=e.i[g.day])){g.day=o.value;c.resetTime();d=i}else if(g.day&&(o=e.o(g.day))>-1){delete g.day;g.weekday=o}if(g.date&&!p.isNumber(g.date))g.date=e.s(g.date);if(g.meridian)if(g.meridian==="pm"&&g.hour<12)g.hour+=12;if(g.offset_hours||g.offset_minutes){g.utc=i;g.offset_minutes=
+g.offset_minutes||0;g.offset_minutes+=g.offset_hours*60;if(g.offset_sign==="-")g.offset_minutes*=-1;g.minute-=g.offset_minutes}if(g.unit){d=i;n=e.n(g.num);k=e.r(g.unit);if(g.shift||g.edge){n*=(o=e.i[g.shift])?o.value:0;if(k==="month"&&K(g.date)){c.set({day:g.date},i);delete g.date}if(k==="year"&&K(g.month)){c.set({month:g.month,day:g.date},i);delete g.month;delete g.date}}if(g.sign&&(o=e.i[g.sign]))n*=o.value;if(K(g.weekday)){c.set({weekday:g.weekday},i);delete g.weekday}g[k]=(g[k]||0)+n}if(g.year_sign===
+"-")g.year*=-1;return l}});if(h)if(d)c.advance(g);else g.utc?c.setUTC(g,i):c.set(g,i);else c=a?new s(a):new s;if(g&&g.edge){o=e.i[g.edge];I(W.slice(4),function(u){if(K(g[u.a])){k=u.a;return l}});if(k==="year")g.f="month";else if(k==="month"||k==="week")g.f="day";c[(o.value<0?"endOf":"beginningOf")+k.capitalize()]();o.value===-2&&c.resetTime()}}return{h:c,set:g}}
function Ra(a,b,c,d){var e,f=Y(d,i),h=r(/^[A-Z]/);if(a.isValid())if(Date[b])b=Date[b];else{if(p.isFunction(b)){e=Sa(a);b=b.apply(a,e.concat(f))}}else return"Invalid Date";if(!b&&!c)b=f.outputFormat;else if(!b&&c){e=e||Sa(a);if(e[1]===0){e[1]=1;e[0]=1}return f.w(e[0],e[1],e[2])}I(Ea,function(g){b=b.replace(r("\\{("+g.c+")(\\d)?\\}",g.l?"i":""),function(k,n,o){k=g.b(a,f,o||1,n);o=n.length;var u=n.match(/^(.)\1+$/);if(g.l){if(o===3)k=k.to(3);if(u||n.match(h))k=k.capitalize()}else if(u&&!g.text)k=(p.isNumber(k)?
k.pad(o):k.toString()).last(o);return k})});return b}function Ta(a,b,c){var d=Qa(b),e=0,f=b=0,h;if(c>0){b=f=c;h=i}if(!d.h.isValid())return l;if(d.set&&d.set.f){I(X,function(k){if(k.a===d.set.f)e=k.e(d.h,a-d.h)-1});if(d.set.edge||d.set.shift)d.h["beginningOf"+d.set.f.capitalize()]();if(!h&&d.set.sign&&d.set.f!="millisecond"){b=50;f=-50}}c=a.getTime();h=d.h.getTime();var g=h+e;if(d.set&&d.set.f=="week"&&(new Date(g+1)).getHours()!=0)g-=s.DSTOffset;return c>=h-b&&c<=g+f}
function $(a,b,c,d,e){if(p.isNumber(b)&&e)b={milliseconds:b};else if(p.isNumber(b)){a.setTime(b);return a}if(b.date)b.day=b.date;if(!e&&A(b.day)&&K(b.weekday)){a["set"+(d?"UTC":"")+"Weekday"](b.weekday);b.day=a["get"+(d?"UTC":"")+"Date"](void 0);delete b.weekday}I(W,function(f){if(K(b[f.a])||K(b[f.a+"s"])){b.f=f.a;return l}else if(c&&f.a!=="week"&&f.a!=="year")a["set"+(d?"UTC":"")+f.method](f.a==="day"?1:0)});I(X,function(f){var h=f.a;f=f.method;var g=K(b[h])?b[h]:b[h+"s"];if(!A(g)){if(e){if(h===
@@ -87,7 +87,7 @@ w(s,i,l,{set:function(){var a=Z(arguments);return $(this,a[0],a[1])},setUTC:func
return $(this,a[0],l,l,1,i)},rewind:function(){var a=Z(arguments);return $(this,a[0],l,l,-1)},isValid:function(){return!isNaN(this.getTime())},isAfter:function(a,b){return this.getTime()>s.create(a).getTime()-(b||0)},isBefore:function(a,b){return this.getTime()<s.create(a).getTime()+(b||0)},isBetween:function(a,b,c){var d=this.getTime();a=s.create(a).getTime();var e=s.create(b).getTime();b=Math.min(a,e);a=Math.max(a,e);c=c||0;return b-c<d&&a+c>d},isLeapYear:function(){var a=this.getFullYear();return a%
4===0&&a%100!==0||a%400===0},daysInMonth:function(){return 32-(new s(this.getFullYear(),this.getMonth(),32)).getDate()},format:function(a,b){return Ra(this,a,l,b)},relative:function(a,b){if(p.isString(a)){b=a;a=j}return Ra(this,a,i,b)},is:function(a,b){var c;if(p.isString(a)){a=a.trim().toLowerCase();switch(i){case a==="future":return this.getTime()>(new s).getTime();case a==="past":return this.getTime()<(new s).getTime();case a==="weekday":return this.getDay()>0&&this.getDay()<6;case a==="weekend":return this.getDay()===
0||this.getDay()===6;case (c=N(English.weekdays,a,0,1)%7)>-1:return this.getDay()===c;case (c=N(English.months,a,0,1)%12)>-1:return this.getMonth()===c}}return Ta(this,a,b)},resetTime:function(){return this.set({hour:0,minute:0,second:0,millisecond:0})},clone:function(){return new s(this.getTime())},compare:function(){return this-S(arguments)}});w(s,i,l,{getWeekday:s.prototype.getDay,getUTCWeekday:s.prototype.getUTCDay});r.m=A(r("()??").exec("")[1]);
-function Ua(a,b){var c="";if(b=="g"||a.global)c+="g";if(b=="i"||a.ignoreCase)c+="i";if(b=="m"||a.multiline)c+="m";if(b=="y"||a.A)c+="y";return c}w(r,l,l,{escape:function(a){return a.replace(/([/'*+?|()\[\]{}.^$])/g,"\\$1")}});w(r,i,l,{getFlags:function(){return Ua(this)},setFlags:function(a){return r(this.source,a)},addFlag:function(a){return this.setFlags(Ua(this,a))},removeFlag:function(a){return this.setFlags(Ua(this).replace(a,""))}});
+function Ua(a,b){var c="";if(b=="g"||a.global)c+="g";if(b=="i"||a.ignoreCase)c+="i";if(b=="m"||a.multiline)c+="m";if(b=="y"||a.B)c+="y";return c}w(r,l,l,{escape:function(a){return a.replace(/([/'*+?|()\[\]{}.^$])/g,"\\$1")}});w(r,i,l,{getFlags:function(){return Ua(this)},setFlags:function(a){return r(this.source,a)},addFlag:function(a){return this.setFlags(Ua(this,a))},removeFlag:function(a){return this.setFlags(Ua(this).replace(a,""))}});
function Va(a,b,c,d,e){if(!a.g)a.g=[];a.g.push(setTimeout(function(){a.g.removeAt(f);c.apply(d,e||[])},b));var f=a.g.length}
w(Function,i,l,{lazy:function(a,b){function c(){if(!(h||f.length==0)){for(var n=Math.max(f.length-k,0);f.length>n;)Function.prototype.apply.apply(e,f.shift());Va(d,g,function(){h=l;c()});h=i}}function d(){if(!(h&&f.length>b-2)){f.push([this,arguments]);c()}}var e=this,f=[],h=l,g,k;a=a||1;b=b||Infinity;g=a.ceil();k=Q(g/a);return d},delay:function(a){p.isNumber(a)||(a=0);var b=E(arguments,1);Va(this,a,this,this,b);return this},debounce:function(a,b){var c=this;return b===l?this.lazy(a,1):function(){c.cancel();
Va(c,a,c,this,arguments)}},cancel:function(){if(p.isArray(this.g))for(;this.g.length>0;)clearTimeout(this.g.shift());return this},after:function(a){var b=this,c=0,d=[];if(p.isNumber(a)){if(a===0){b.call();return b}}else a=1;return function(){var e;d.push(Array.create(arguments));c++;if(c==a){e=b.call(this,d);c=0;d=[];return e}}},once:function(){var a=this;return function(){return a.hasOwnProperty("memo")?a.memo:a.memo=a.apply(this,arguments)}},fill:function(){var a=this,b=E(arguments);return function(){var c=
@@ -100,7 +100,7 @@ f=a.indexOf(c.charAt(n++));g=a.indexOf(c.charAt(n++));k=a.indexOf(c.charAt(n++))
y(t.prototype,"has"+d,function(){return c.test(this)})})});English=s.setLocale("en");
I(X,function(a,b){var c=a.a,d=c.capitalize(),e=a.e();y(s.prototype,c+"sSince",function(f,h){return Q((this.getTime()-s.create(f,h).getTime())/e)});y(s.prototype,c+"sUntil",function(f,h){return Q((s.create(f,h).getTime()-this.getTime())/e)});y(s.prototype,c+"sAgo",s.prototype[c+"sUntil"]);y(s.prototype,c+"sFromNow",s.prototype[c+"sSince"]);y(s.prototype,"add"+d+"s",function(f){var h={};h[c]=f;return this.advance(h)});ma(c,e);b<3&&I(["Last","This","Next"],function(f){y(s.prototype,"is"+f+d,function(){return this.is(f+
" "+c)})});if(b<4){y(s.prototype,"beginningOf"+d,function(){var f={};switch(c){case "year":f.year=this.getFullYear();break;case "month":f.month=this.getMonth();break;case "day":f.day=this.getDate();break;case "week":f.weekday=0}return this.set(f,i)});y(s.prototype,"endOf"+d,function(){var f={hours:23,minutes:59,seconds:59,milliseconds:999};switch(c){case "year":f.month=11;f.day=31;break;case "month":f.day=this.daysInMonth();break;case "week":f.weekday=6}return this.set(f,i)})}});
-(function(){Ca=X.clone().removeAt(2);W=X.clone().reverse();var a="\\d{1,2}|"+English.months.join("|");I(Da,function(b){s.addFormat(b.src.replace(/\{month\}/,a)+xa,b.to.concat(va),"en",b.k)});s.addFormat(wa,va)})();(function(){var a=English.weekdays.slice(0,7),b=English.months.slice(0,12);I(["today","yesterday","tomorrow","weekday","weekend","future","past"].concat(a).concat(b),function(c){y(s.prototype,"is"+c.capitalize(),function(){return this.is(c)})})})();
+(function(){Ca=X.clone().removeAt(2);W=X.clone().reverse();var a="\\d{1,2}|"+English.months.join("|");I(Da,function(b){s.addFormat(b.src.replace(/\{month\}/,a)+(b.z===l?"":xa),b.to.concat(va),"en",b.k)});s.addFormat(wa,va)})();(function(){var a=English.weekdays.slice(0,7),b=English.months.slice(0,12);I(["today","yesterday","tomorrow","weekday","weekend","future","past"].concat(a).concat(b),function(c){y(s.prototype,"is"+c.capitalize(),function(){return this.is(c)})})})();
w(s,l,i,{DSTOffset:((new s(2E3,6,1)).getTimezoneOffset()-(new s(2E3,0,1)).getTimezoneOffset())*60*1E3,INTERNATIONAL_TIME:"{h}:{mm}:{ss}",RFC1123:"{Dow}, {dd} {Mon} {yyyy} {HH}:{mm}:{ss} {tz}",RFC1036:"{Weekday}, {dd}-{Mon}-{yy} {HH}:{mm}:{ss} {tz}",ISO8601_DATE:"{yyyy}-{MM}-{dd}",ISO8601_DATETIME:"{yyyy}-{MM}-{dd}T{HH}:{mm}:{ss}.{fff}{isotz}"});
(function(){var a=new s(s.UTC(1999,11,31));if(!a.toISOString||a.toISOString()!=="1999-12-31T00:00:00.000Z")w(s,i,i,{toISOString:function(){return Ra(this.toUTC(),s.ISO8601_DATETIME)}});if(!a.toJSON||a.toJSON()!=="1999-12-31T00:00:00.000Z")w(s,i,i,{toJSON:s.prototype.toISOString});w(s,i,l,{iso:s.prototype.toISOString})})();
(function(){var a=l;if(Function.prototype.p){a=function(){};var b=a.p();a=new b instanceof b&&!(new a instanceof b)}w(Function,i,!a,{bind:function(c){var d=this,e=E(arguments,1),f,h;if(!p.isFunction(this))throw new TypeError("Function.prototype.bind called on a non-function");h=function(){return d.apply(d.prototype&&this instanceof d?this:c,e.concat(E(arguments)))};f=function(){};f.prototype=this.prototype;h.prototype=new f;return h}})})();})();
View
3  unit_tests/environments/sugar/date.js
@@ -300,6 +300,9 @@ test('Date', function () {
dateEqual(Date.create('2001-04-03T15:00-03:30'), getUTCDate(2001,4,3,18,30), 'Date#create | ISO8601 | Synonymous dates with timezone 4');
+ dateEqual(Date.create('\/Date(628318530718)\/'), new Date(628318530718), 'Date#create | handles JSON date format');
+ dateEqual(Date.create('\/Date(1318287600+0100)\/'), new Date(1318287600), 'Date#create | handles JSON date format with timezone');
+
// Fuzzy dates
Please sign in to comment.
Something went wrong with that request. Please try again.