Comparing version 0.4.1 to 0.4.2
50
d8.js
@@ -9,2 +9,3 @@ ;!function( util ) { | ||
// utility methods | ||
@@ -26,4 +27,6 @@ function _indexOf( o, k ) { var i = o.indexOf( k ); return i == -1 ? null : i; } | ||
/*~ src/vars.js ~*/ | ||
var U, | ||
@@ -62,4 +65,6 @@ // DAY_OFFSETS is the amount of days from the current day to the Monday of the week it belongs to | ||
/*~ src/coerce.js ~*/ | ||
function coerce( date_str, date_format ) { | ||
@@ -171,4 +176,6 @@ return buildParser( date_format )( date_str ); | ||
/*~ src/diff.js ~*/ | ||
function diff( now, props ) { //noinspection FallthroughInSwitchStatementJS | ||
@@ -314,4 +321,6 @@ switch ( util.ntype( now ) ) { | ||
/*~ src/fns.js ~*/ | ||
// private methods | ||
@@ -427,4 +436,6 @@ function _24hrTime( o, res ) { return ( o = Number( o ) ) < 12 && _lc( res.ampm ) == _lc( Type.locale.PM ) ? o += 12 : o; } | ||
/*~ src/format.js ~*/ | ||
function buildTemplate( date_format ) { | ||
@@ -461,4 +472,6 @@ var LID = Type.locale.id, fn, i, l, part, parts, re_invalid; | ||
/*~ src/lexicalize.js ~*/ | ||
function lexicalize( now, precision ) { | ||
@@ -496,3 +509,3 @@ if ( !valid( now ) ) { | ||
dkeys = Type.diffKeys( diff ), index, parts, tense, | ||
tm = Type.time_map, tu = this.time_units, use_noun; | ||
tm = Type.time_map, tu = this.time_units, today, use_noun; | ||
@@ -503,11 +516,15 @@ if ( diff.value < Type.MS_MINUTE ) | ||
switch ( dkeys[0] ) { | ||
case 'years' : index = 0; break; | ||
case 'months' : index = 1; break; | ||
case 'weeks' : index = 2; break; | ||
case 'days' : use_noun = diff.days === 1 && ( dkeys[1] != 'hours' || diff.hours / 24 < .25 ); | ||
index = 3; break; | ||
case 'hours' : use_noun = diff.hours / 24 >= .75; | ||
determiner = this.an; | ||
index = 4; break; | ||
case 'minutes' : index = 5; break; | ||
case 'years' : index = 0; break; | ||
case 'months' : index = 1; break; | ||
case 'weeks' : index = 2; break; | ||
case 'days' : if ( diff.days < 2 ) { | ||
today = date.format( 'l' ) === now.format( 'l' ); | ||
use_noun = today || dkeys[1] != 'hours' || diff.hours < 25; | ||
} | ||
index = 3; break; | ||
case 'hours' : today = date.format( 'l' ) === now.format( 'l' ); | ||
use_noun = diff.hours / 24 >= .75; | ||
determiner = this.an; | ||
index = 4; break; | ||
case 'minutes' : index = 5; break; | ||
} | ||
@@ -518,3 +535,3 @@ | ||
if ( use_noun ) | ||
return diff.tense > 0 ? this.tomorrow : index === 4 ? this.today : this.yesterday; | ||
return today ? this.today : diff.tense > 0 ? this.tomorrow : this.yesterday; | ||
@@ -576,4 +593,6 @@ parts = []; | ||
/*~ src/localize.js ~*/ | ||
function localize( locale ) { //noinspection FallthroughInSwitchStatementJS | ||
@@ -617,4 +636,6 @@ switch ( util.ntype( locale ) ) { | ||
/*~ src/filters.js ~*/ | ||
function localize_filters( L ) { | ||
@@ -687,4 +708,6 @@ var F = { | ||
/*~ src/formats.js ~*/ | ||
function localize_formats( L ) { | ||
@@ -706,4 +729,6 @@ var F = util.copy( { | ||
/*~ src/parsers.js ~*/ | ||
function localize_parsers( L ) { | ||
@@ -771,4 +796,6 @@ var P = { | ||
/*~ src/expose.js ~*/ | ||
// instance methods | ||
@@ -804,2 +831,3 @@ util.defs( Type.prototype, { | ||
} ).x( Date ); | ||
@@ -806,0 +834,0 @@ // at this point we don't know if util is available or not, and as such do not know what environment we are in. |
@@ -1,1 +0,1 @@ | ||
!function(e){"use strict";e.x.cache("Date",function(t){function n(e,t){var n=e.indexOf(t);return-1==n?null:n}function r(e){return e.toLocaleLowerCase()}function i(e){return e.toLocaleUpperCase()}function u(e,t){return e.reduce(function(e,n,r){return e[t[r]]=n,e},{})}function s(e,t,n){return e>=t&&n>=e}function a(e,t,n){var r=-1,i=e.toString(n||10);for(t-=i.length;t>++r;)i="0"+i;return i}function o(e,t){return e+t}function c(e,t){return l(t)(e)}function l(n){var r,i,s,a,o,c,l,h=t.locale.id;if(At[h][n])return At[h][n];for(c=n.replace(Pt,Lt).replace(Wt,Ft).split(Vt),i=[],r=-1,s=c.length,a={},l=[];s>++r;)o=c[r],o!=Tt?o.replace(ct,function(t,n,r,s){var o,c,f;(f=ot[r])&&(f.k&&(i.push(f.k),f.fn&&(a[f.k]=f.fn)),f.combo&&(c=f.combo.pluck("k"),o=u(f.combo.pluck("fn"),c),i.push.apply(i,c),e.copy(a,o,!0)),f.re&&l.push(n,f.re,s))}):(l.push(c[++r]),++r);return At[h][n]=f.bind(null,RegExp(l.join("")),i,a)}function f(e,n,r,i){var s=new t,a=i.match(e),o=u(a.slice(1),n);return Object.reduce(o,function(e,t,n){return"string"==typeof t&&r[n]&&(o[n]=r[n](t,o)),e},null),isNaN(o[Dt])?(g(s,o[vt],o[wt],o[Yt],o[Nt]),h(s,o),d(s,o[jt])):s.setTime(o[Dt]),s}function h(n,r){var i,u,a,o,c=t.locale,l=-1;if(!Ct.every(e.has.bind(null,r))){if(isNaN(r[xt])&&(r[xt]=n.getFullYear()),isNaN(r[Ot])&&(a=c.isLeapYear(r[xt])?1:0,o=c.ordinal_day_count[a],u=o.length,r[Ot]=0,r[St]&&!r[yt]&&(i=r[Mt],i=isNaN(i)?0:i?i:7,r[yt]=7*r[St]-(4-i)),!isNaN(r[yt])))for(r[yt]>o[o.length-1]&&(r[yt]-=o[o.length-1],++r[xt]);u>++l;)if(s(r[yt],o[l],o[l+1])){r[Ot]=l,r[kt]=0==o[l]?r[yt]:r[yt]-o[l];break}isNaN(r[kt])&&(r[kt]=1),n.setYear(r[xt]),n.setMonth(r[Ot]),n.setDate(r[kt])}}function g(e,t,n,r,i){e.setHours(t||0),e.setMinutes(n||0),e.setSeconds(r||0),e.setMilliseconds(i||0)}function d(e,n){!s(n,-43200,50400)||e.adjust(t.SECOND,60*-e.getTimezoneOffset()-n)}function m(n,r){switch(e.ntype(n)){case"number":case"string":if(!q(new t(n))){r||(r=n),n=t.now();break}n=new t(n);case"array":case"object":r=n,n=t.now();break;case"date":if(q(new t(+n)))break;default:n=t.now()}var i,u=+n-+this,s=0>u?1:u>0?-1:0;return s?i=b(Math.abs(u),_(r)):(i=e.obj(),i.value=0),i.tense=s,i}function p(e,t,n,r){var i;return e.__ms__?e.excl[t[0]]?r[n+1]&&!e.excl[r[n+1][0]]||!(t=r[n-1])?e:(i=e.__ms__/t[1],e.__ms__=Math.round(i)*t[1]+e.__ms__/r[n][1]%1*r[n][1],p(e,t,n-1,[])):(e.__ms__>=t[1]&&(i=e.__ms__/t[1],t[0]in e.val?(i=Math.floor(i),e.__ms__-=i*t[1],e.val[t[0]]+=i):(e.__ms__=i%1*t[1],e.val[t[0]]=Math.floor(i))),e):e}function b(t,n){var r=Qt.reduce(p,{__ms__:t,excl:n,val:e.obj()}).val;return r.value=t,r}function _(t){var n=e.obj(),r=!0;if(t)switch(e.ntype(t)){case"object":r=!1;break;case"string":t=t.split(" ");case"array":t=t.reduce(k,n),r=!!e.len(n)}return Xt.map(function(e){e in this||(this[e]=!r)},n),n}function k(e,t){var n=(t=(t+"").toLowerCase()).substring(1);switch(t.charAt(0)){case"-":e[n]=!0;break;case"+":e[n]=!1;break;case">":Qt.map(M,{excl:e,prop:n,val:!0});break;case"<":Qt.slice().reverse().map(M,{excl:e,prop:n,val:!1});break;default:e[t]=!1}return e}function M(e){e[0]===this.prop&&(this.SET_VALID=!0),this.SET_VALID&&(this.excl[e[0]]=this.val)}function y(t){return t=e.copy(t),e.remove(t,"tense","value"),Object.keys(t).map(function(e){return[Xt.indexOf(e),e]}).sort(function(e,t){return e=e[0],t=t[0],e>t?1:-1}).pluck(1)}function v(e,n){return 12>(e=Number(e))&&r(n.ampm)==r(t.locale.PM)?e+=12:e}function N(e,t,n){return e.adjust(n,t)}function w(t){return Et.reduce(function(e,n,r){var i=parseFloat(t[r]);return isNaN(i)||0===i||(e[n]=i),e},e.obj())}function O(e){return Math.floor((e-C.call(e))/ft)}function Y(e){var t=!!e.indexOf("-"),n=e.match(Jt),r=3600*(Number(n[1])+n[2]/60);return t?r:-r}function j(e){return Math.floor(Math.abs(O(e)/7))}function D(e,t){return isNaN(t)?Number(e)-1:t==e?0:Number(t)}function S(n,r){var i,u,s,a=this;switch(e.ntype(n)){case"number":n=arguments;case"array":n=w(n);case"object":Object.reduce(n,N,a);break;case"string":u=Ht[n.toLowerCase()],u&&0!==r&&(t.locale.setLeapYear(a),u==Ht.month&&(i=a.getDate(),28>i||a.setDate(Math.min(i,U.call(H.call(a).adjust(t.MONTH,r)).getDate()))),u!=Ht.week||(s=a.getDay()),a[u[1]](a[u[0]]()+r),!s||a.setDate(a.getDate()+s))}return a}function x(e,t){return+this>=+e&&+t>=+this}function T(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this}function L(){return new t(this.getTime())}function F(){var e=t.locale;return e.setLeapYear(this),e.day_count.slice(0,this.getMonth()).reduce(o,0)+this.getDate()-1}function H(){return new t(this.getFullYear(),this.getMonth(),1)}function E(e){var t=this.getTimezoneOffset();return[t>0?"-":"+",a(Math.floor(Math.abs(t)/60),2),e?":":"",a(Math.abs(t%60),2)].join("")}function I(){return this.getDay()||7}function A(){return Math.ceil((C.call(new t(this.getFullYear()+1,0,1))-C.call(this))/ft)}function C(){var e=this.getFullYear();return new t(e,0,lt[new t(e,0,1).getDay()])}function z(){var e,n=this.getFullYear();return this>=C.call(new t(n+1,0,1))?1:(e=Math.floor((F.call(this)-I.call(this)+10)/7),0==e?R.call(new t(n-1,0,1))-j(this):e)}function R(){return Math.round((C.call(new t(this.getFullYear()+1,0,1))-C.call(this))/pt)}function U(){var e=t.locale,n=this.getMonth();return e.setLeapYear(this),new t(this.getFullYear(),n,e.day_count[n])}function W(){return Math.floor(F.call(this)/7)}function P(){return new t(this.getFullYear(),0,1).getTimezoneOffset()!=this.getTimezoneOffset()}function Z(){return t.locale.isLeapYear(this.getFullYear())}function G(e){return this.setMonth(0),this.setDate(1),this.adjust(t.DAY,7*e).getTime()}function K(){var e=(""+this).split(" ");return e.splice(4,e.length).join(" ").replace($t,"$1").replace(Bt,"")}function q(t){return"date"==e.ntype(t)&&!isNaN(+t)}function V(e){var n,r,i,u,s,a,o=t.locale.id;if(It[o][e])return It[o][e];for(n=[" var out=[];"],s=e.replace(Pt,Lt).replace(Wt,Ft).split(Vt),a=/^[^A-Za-z]*$/g,r=-1,i=s.length;i>++r;)u=s[r],u==Tt?(n.push(J(s[++r])),++r):a.test(u)?n.push(J(u)):n.push(B(u));return n.push('return out.join( "" );\n //@ sourceURL=d8/format/'+o+"/"+e),It[o][e]=Function("filter","date",n.join("\n\n "))}function $(e){return V(e)(ut,this)}function B(e){return e.replace(ct,function(e,t,n,r){return J(t+"', filter."+n+"( date ), '"+r)})}function J(e){return"out.push( '"+e+"' );"}function Q(e,n){q(e)||(q(new t(e))?e=new t(e):(n=e,e=t.now()));var r=t.locale.lexicon;return"function"!=typeof zt[n=(n+"").toLowerCase()]&&(n=r.DEFAULT),+e-+this?zt[n].call(r,this,e).replace(qt," "):r.just_now}function X(e){return e.join(" ")}function et(e,t){var n=e.pop();return(e.length?e.join(this.delim)+" "+this.and+" "+n:n)+" "+this[1>t.tense?"ago":"from_now"]}function tt(n){switch(e.ntype(n)){case"object":if(n.id){Rt[n.id]=n;break}case"string":if(n in Rt){n=Rt[n];break}default:n=null}return"object"==e.ntype(n)&&(e.defs(t,{locale:{value:n},getOrdinal:n.getOrdinal,isLeapYear:n.isLeapYear,setLeapYear:n.setLeapYear},"w",!0),n.id in It||(It[n.id]=e.obj()),n.id in At||(At[n.id]=e.obj()),ut=nt(n),at=rt(n),ot=it(n)),t}function nt(n){var u={d:function(e){return a(e.getDate(),2)},D:function(e){return n.days[e.getDay()].substring(0,3)},j:function(e){return e.getDate()},l:function(e){return n.days[e.getDay()]},N:function(e){return I.call(e)},S:function(e){return n.getOrdinal(e.getDate())},w:function(e){return e.getDay()},z:function(e){return e.getDayOfYear()},W:function(e){return z.call(e)},F:function(e){return n.months[e.getMonth()]},m:function(e){return a(e.getMonth()+1,2)},M:function(e){return n.months[e.getMonth()].substring(0,3)},n:function(e){return e.getMonth()+1},t:function(e){return n.setLeapYear(e),n.day_count[e.getMonth()]},L:function(e){return e.isLeapYear()?1:0},o:function(e){var t=e.getMonth(),n=z.call(e);return e.getFullYear()+(1==n&&t>0?1:n>=52&&11>t?-1:0)},Y:function(e){return e.getFullYear()},y:function(e){return(e.getFullYear()+"").substring(2,4)},a:function(e){return r(12>e.getHours()?n.AM:n.PM)},A:function(e){return i(12>e.getHours()?n.AM:n.PM)},g:function(e){return e.getHours()%12||12},G:function(e){return e.getHours()},h:function(e){return a(ut.g(e),2)},H:function(e){return a(ut.G(e),2)},i:function(e){return a(e.getMinutes(),2)},s:function(e){return a(e.getSeconds(),2)},u:function(e){return a(e.getMilliseconds(),3)},O:function(e){return E.call(e)},P:function(e){return E.call(e,!0)},T:function(e){return K.call(e)},Z:function(e){return-60*e.getTimezoneOffset()},c:function(e){return $.call(e,at.ISO_8601)},r:function(e){return $.call(e,at.RFC_2822)},U:function(e){return e.getTime()},e:function(e){return e.lexicalize("exact")},x:function(e){return e.lexicalize("approx")}};return st=Object.keys(u).sort().join(""),ct=RegExp("([^"+st+"]*)(["+st+"])([^"+st+"]*)","g"),e.def(t,"filters",{value:ut=u},"w",!0),u}function rt(n){var r=e.copy({ISO_8601:"Y-m-d<T>H:i:s.u<Z>",ISO_8601_SHORT:"Y-m-d",RFC_850:"l, d-M-y H:i:s T",RFC_2822:"D, d M Y H:i:s O",sortable:"Y-m-d H:i:sO"},n.formats);return r.atom=r.ISO_8601,r.cookie=r.RFC_850,r.rss=r.RFC_2822,e.def(t,"formats",{value:at=r},"w",!0),r}function it(u){var s={d:{k:kt,fn:Number,re:Gt},D:{k:Mt,fn:n.bind(null,u.days_short),re:"("+u.days_short.join("|")+")"},j:{k:kt,fn:Number,re:Zt},l:{k:Mt,fn:n.bind(null,u.days),re:"("+u.days.join("|")+")"},N:{k:Mt,fn:D.bind(null,7),re:"([1-7])"},S:{re:"(?:"+u.ordinal.join("|")+")"},w:{k:Mt,fn:Number,re:"([0-6])"},z:{k:yt,fn:Number,re:"([0-9]{1,3})"},W:{k:St,fn:Number,re:Gt},F:{k:Ot,fn:n.bind(null,u.months),re:"("+u.months.join("|")+")"},m:{k:Ot,fn:D,re:Gt},M:{k:Ot,fn:n.bind(null,u.months_short),re:"("+u.months_short.join("|")+")"},n:{k:Ot,fn:D,re:Zt},t:{re:"[0-9]{2}"},L:{re:"(?:0|1)"},o:{k:xt,fn:Number,re:Kt},Y:{k:xt,fn:Number,re:Kt},y:{k:xt,fn:function(e){return e=Number(e),e+=30>e?2e3:1900},re:Gt},a:{k:_t,fn:e,re:Ut},A:{k:_t,fn:r,re:i(Ut)},g:{k:vt,fn:v,re:Zt},G:{k:vt,fn:Number,re:Zt},h:{k:vt,fn:v,re:Gt},H:{k:vt,fn:Number,re:Gt},i:{k:wt,fn:Number,re:Gt},s:{k:Yt,fn:Number,re:Gt},u:{k:Nt,fn:Number,re:"([0-9]{1,})"},O:{k:jt,fn:Y,re:"([\\+-][0-9]{4})"},P:{k:jt,fn:Y,re:"([\\+-][0-9]{2}:[0-9]{2})"},T:{re:"[A-Z]{1,4}"},Z:{k:jt,fn:Number,re:"([\\+-]?[0-9]{5})"},U:{k:Dt,fn:Number,re:"(-?[0-9]{1,})"}};return s.c={combo:[s.Y,s.m,s.d,s.H,s.i,s.s,s.u,s.P],re:[s.Y.re,"-",s.m.re,"-",s.d.re,"T",s.H.re,":",s.i.re,":",s.s.re,"(?:\\.",s.u.re,"){0,1}",s.P.re,"{0,1}"].join("")},s.r={combo:[s.D,s.d,s.M,s.Y,s.H,s.i,s.s,s.O],re:[s.D.re,", ",s.d.re," ",s.M.re," ",s.Y.re," ",s.H.re,":",s.i.re,":",s.s.re," ",s.O.re].join("")},e.def(t,"parsers",{value:ot=s},"w",!0),s}var ut,st,at,ot,ct,lt=[9,1,0,-1,-2,4,3],ft=864e5,ht=36e5,gt=6e4,dt=2592e6,mt=1e3,pt=6048e5,bt=31536e6,_t="ampm",kt="day",Mt="dayweek",yt="dayyear",vt="hour",Nt="ms",wt="minute",Ot="month",Yt="second",jt="timezone",Dt="unix",St="week",xt="year",Tt="NOREPLACE",Lt="<"+Tt+"<",Ft=">END"+Tt+">",Ht={day:["getDate","setDate"],hr:["getHours","setHours"],min:["getMinutes","setMinutes"],month:["getMonth","setMonth"],ms:["getMilliseconds","setMilliseconds"],sec:["getSeconds","setSeconds"],week:["getWeek","setWeek"],year:["getFullYear","setFullYear"]},Et=[xt,Ot,St,kt,"hr",wt.substring(0,3),Yt.substring(0,3),Nt],It=e.obj(),At=e.obj(),Ct=[kt,Mt,yt,Ot,St,xt],zt=e.obj(),Rt=e.obj(),Ut="(am|pm)",Wt=/>/g,Pt=/</g,Zt="([0-9]{1,2})",Gt="([0-9]{2})",Kt="([0-9]{4})",qt=/\s{2,}/g,Vt=/[<>]/,$t=/[^\(]*\(([^\)]+)\)/g,Bt=/[^A-Z]+/g,Jt=/[\+-]?([0-9]{2}):?([0-9]{2})/,Qt=[[xt+"s",bt],[Ot+"s",dt],[St+"s",pt],[kt+"s",ft],[vt+"s",ht],[wt+"s",gt],[Yt+"s",mt],[Nt,1]],Xt=Qt.pluck(0);zt.approx=function(e,n){var r,i,u,s,a,o,c=this.a,l=e.diff(n),f=t.diffKeys(l),h=t.time_map,g=this.time_units;if(l.value<t.MS_MINUTE)return this.just_now;switch(f[0]){case"years":u=0;break;case"months":u=1;break;case"weeks":u=2;break;case"days":o=1===l.days&&("hours"!=f[1]||.25>l.hours/24),u=3;break;case"hours":o=l.hours/24>=.75,c=this.an,u=4;break;case"minutes":u=5}if(i=(l.value-h[u][1]*l[f[0]])/h[u][1],o)return l.tense>0?this.tomorrow:4===u?this.today:this.yesterday;if(s=[],a=l.tense>0?this.from_now:this.ago,.1>i)switch(f[0]){case"years":case"months":case"weeks":if(1===l[f[0]]){s.push(1>l.tense?this.last:this.next,g[u][0]);break}default:!i||s.push(this.about),s.push(l[f[0]],g[u][l[f[0]]>1?1:0],a)}else.74>i?.24>i?r=this.just_over:(r=i>.24&&.4>i?this.almost:this.about,s.push(this.and,this.a,this.half)):s.push(this.almost,l[f[0]]+1,g[u][1],a);return r&&(s.push(g[u][l[f[0]]>1||s.length?1:0],a),s.unshift(r,l[f[0]])),"function"==typeof this.approx?this.approx.call(this,s,l):X.call(this,s,l)},zt.exact=function(e,n){var r,i=e.diff(n),u=this.time_units;return r=t.time_map.reduce(function(e,t,n){var r=i[t[0]];return!r||!u[n]||e.push(r+" "+u[n][r>1?1:0]),e},[]),r.length?"function"==typeof this.exact?this.exact.call(this,r,i):et.call(this,r,i):this.just_now},e.defs(t.prototype,{adjust:S,between:x,clearTime:T,clone:L,diff:m,format:$,getDayOfYear:F,getFirstOfTheMonth:H,getGMTOffset:E,getISODay:I,getISODaysInYear:A,getISOFirstMondayOfYear:C,getISOWeek:z,getISOWeeksInYear:R,getLastOfTheMonth:U,getWeek:W,isDST:P,isLeapYear:Z,lexicalize:Q,setWeek:G,timezone:K,valid:function(){return t.valid(this)}},"r"),e.defs(t,{DAY:kt,HOUR:"hr",MINUTE:wt.substring(0,3),MILLISECOND:Nt,MONTH:Ot,SECOND:Yt.substring(0,3),WEEK:St,YEAR:xt,MS_DAY:ft,MS_HOUR:ht,MS_MINUTE:gt,MS_MONTH:dt,MS_SECOND:mt,MS_WEEK:pt,MS_YEAR:bt,lexicon:{value:zt},time_map:{value:Qt},time_props:{value:Xt},coerce:c,diffKeys:y,localize:tt,toDate:c,valid:q},"r")}).x(Date)}("undefined"!=typeof m8?m8:"undefined"!=typeof require?require("m8"):null); | ||
!function(e){"use strict";e.x.cache("Date",function(t){function n(e,t){var n=e.indexOf(t);return-1==n?null:n}function r(e){return e.toLocaleLowerCase()}function i(e){return e.toLocaleUpperCase()}function u(e,t){return e.reduce(function(e,n,r){return e[t[r]]=n,e},{})}function s(e,t,n){return e>=t&&n>=e}function a(e,t,n){var r=-1,i=e.toString(n||10);for(t-=i.length;t>++r;)i="0"+i;return i}function o(e,t){return e+t}function c(e,t){return l(t)(e)}function l(n){var r,i,s,a,o,c,l,h=t.locale.id;if(At[h][n])return At[h][n];for(c=n.replace(Pt,Lt).replace(Wt,Ft).split(Vt),i=[],r=-1,s=c.length,a={},l=[];s>++r;)o=c[r],o!=Tt?o.replace(ct,function(t,n,r,s){var o,c,f;(f=ot[r])&&(f.k&&(i.push(f.k),f.fn&&(a[f.k]=f.fn)),f.combo&&(c=f.combo.pluck("k"),o=u(f.combo.pluck("fn"),c),i.push.apply(i,c),e.copy(a,o,!0)),f.re&&l.push(n,f.re,s))}):(l.push(c[++r]),++r);return At[h][n]=f.bind(null,RegExp(l.join("")),i,a)}function f(e,n,r,i){var s=new t,a=i.match(e),o=u(a.slice(1),n);return Object.reduce(o,function(e,t,n){return"string"==typeof t&&r[n]&&(o[n]=r[n](t,o)),e},null),isNaN(o[Dt])?(m(s,o[vt],o[wt],o[Yt],o[Nt]),h(s,o),g(s,o[jt])):s.setTime(o[Dt]),s}function h(n,r){var i,u,a,o,c=t.locale,l=-1;if(!Ct.every(e.has.bind(null,r))){if(isNaN(r[xt])&&(r[xt]=n.getFullYear()),isNaN(r[Ot])&&(a=c.isLeapYear(r[xt])?1:0,o=c.ordinal_day_count[a],u=o.length,r[Ot]=0,r[St]&&!r[yt]&&(i=r[Mt],i=isNaN(i)?0:i?i:7,r[yt]=7*r[St]-(4-i)),!isNaN(r[yt])))for(r[yt]>o[o.length-1]&&(r[yt]-=o[o.length-1],++r[xt]);u>++l;)if(s(r[yt],o[l],o[l+1])){r[Ot]=l,r[kt]=0==o[l]?r[yt]:r[yt]-o[l];break}isNaN(r[kt])&&(r[kt]=1),n.setYear(r[xt]),n.setMonth(r[Ot]),n.setDate(r[kt])}}function m(e,t,n,r,i){e.setHours(t||0),e.setMinutes(n||0),e.setSeconds(r||0),e.setMilliseconds(i||0)}function g(e,n){!s(n,-43200,50400)||e.adjust(t.SECOND,60*-e.getTimezoneOffset()-n)}function d(n,r){switch(e.ntype(n)){case"number":case"string":if(!q(new t(n))){r||(r=n),n=t.now();break}n=new t(n);case"array":case"object":r=n,n=t.now();break;case"date":if(q(new t(+n)))break;default:n=t.now()}var i,u=+n-+this,s=0>u?1:u>0?-1:0;return s?i=b(Math.abs(u),_(r)):(i=e.obj(),i.value=0),i.tense=s,i}function p(e,t,n,r){var i;return e.__ms__?e.excl[t[0]]?r[n+1]&&!e.excl[r[n+1][0]]||!(t=r[n-1])?e:(i=e.__ms__/t[1],e.__ms__=Math.round(i)*t[1]+e.__ms__/r[n][1]%1*r[n][1],p(e,t,n-1,[])):(e.__ms__>=t[1]&&(i=e.__ms__/t[1],t[0]in e.val?(i=Math.floor(i),e.__ms__-=i*t[1],e.val[t[0]]+=i):(e.__ms__=i%1*t[1],e.val[t[0]]=Math.floor(i))),e):e}function b(t,n){var r=Qt.reduce(p,{__ms__:t,excl:n,val:e.obj()}).val;return r.value=t,r}function _(t){var n=e.obj(),r=!0;if(t)switch(e.ntype(t)){case"object":r=!1;break;case"string":t=t.split(" ");case"array":t=t.reduce(k,n),r=!!e.len(n)}return Xt.map(function(e){e in this||(this[e]=!r)},n),n}function k(e,t){var n=(t=(t+"").toLowerCase()).substring(1);switch(t.charAt(0)){case"-":e[n]=!0;break;case"+":e[n]=!1;break;case">":Qt.map(M,{excl:e,prop:n,val:!0});break;case"<":Qt.slice().reverse().map(M,{excl:e,prop:n,val:!1});break;default:e[t]=!1}return e}function M(e){e[0]===this.prop&&(this.SET_VALID=!0),this.SET_VALID&&(this.excl[e[0]]=this.val)}function y(t){return t=e.copy(t),e.remove(t,"tense","value"),Object.keys(t).map(function(e){return[Xt.indexOf(e),e]}).sort(function(e,t){return e=e[0],t=t[0],e>t?1:-1}).pluck(1)}function v(e,n){return 12>(e=Number(e))&&r(n.ampm)==r(t.locale.PM)?e+=12:e}function N(e,t,n){return e.adjust(n,t)}function w(t){return Et.reduce(function(e,n,r){var i=parseFloat(t[r]);return isNaN(i)||0===i||(e[n]=i),e},e.obj())}function O(e){return Math.floor((e-C.call(e))/ft)}function Y(e){var t=!!e.indexOf("-"),n=e.match(Jt),r=3600*(Number(n[1])+n[2]/60);return t?r:-r}function j(e){return Math.floor(Math.abs(O(e)/7))}function D(e,t){return isNaN(t)?Number(e)-1:t==e?0:Number(t)}function S(n,r){var i,u,s,a=this;switch(e.ntype(n)){case"number":n=arguments;case"array":n=w(n);case"object":Object.reduce(n,N,a);break;case"string":u=Ht[n.toLowerCase()],u&&0!==r&&(t.locale.setLeapYear(a),u==Ht.month&&(i=a.getDate(),28>i||a.setDate(Math.min(i,U.call(H.call(a).adjust(t.MONTH,r)).getDate()))),u!=Ht.week||(s=a.getDay()),a[u[1]](a[u[0]]()+r),!s||a.setDate(a.getDate()+s))}return a}function x(e,t){return+this>=+e&&+t>=+this}function T(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this}function L(){return new t(this.getTime())}function F(){var e=t.locale;return e.setLeapYear(this),e.day_count.slice(0,this.getMonth()).reduce(o,0)+this.getDate()-1}function H(){return new t(this.getFullYear(),this.getMonth(),1)}function E(e){var t=this.getTimezoneOffset();return[t>0?"-":"+",a(Math.floor(Math.abs(t)/60),2),e?":":"",a(Math.abs(t%60),2)].join("")}function I(){return this.getDay()||7}function A(){return Math.ceil((C.call(new t(this.getFullYear()+1,0,1))-C.call(this))/ft)}function C(){var e=this.getFullYear();return new t(e,0,lt[new t(e,0,1).getDay()])}function z(){var e,n=this.getFullYear();return this>=C.call(new t(n+1,0,1))?1:(e=Math.floor((F.call(this)-I.call(this)+10)/7),0==e?R.call(new t(n-1,0,1))-j(this):e)}function R(){return Math.round((C.call(new t(this.getFullYear()+1,0,1))-C.call(this))/pt)}function U(){var e=t.locale,n=this.getMonth();return e.setLeapYear(this),new t(this.getFullYear(),n,e.day_count[n])}function W(){return Math.floor(F.call(this)/7)}function P(){return new t(this.getFullYear(),0,1).getTimezoneOffset()!=this.getTimezoneOffset()}function Z(){return t.locale.isLeapYear(this.getFullYear())}function G(e){return this.setMonth(0),this.setDate(1),this.adjust(t.DAY,7*e).getTime()}function K(){var e=(""+this).split(" ");return e.splice(4,e.length).join(" ").replace($t,"$1").replace(Bt,"")}function q(t){return"date"==e.ntype(t)&&!isNaN(+t)}function V(e){var n,r,i,u,s,a,o=t.locale.id;if(It[o][e])return It[o][e];for(n=[" var out=[];"],s=e.replace(Pt,Lt).replace(Wt,Ft).split(Vt),a=/^[^A-Za-z]*$/g,r=-1,i=s.length;i>++r;)u=s[r],u==Tt?(n.push(J(s[++r])),++r):a.test(u)?n.push(J(u)):n.push(B(u));return n.push('return out.join( "" );\n //@ sourceURL=d8/format/'+o+"/"+e),It[o][e]=Function("filter","date",n.join("\n\n "))}function $(e){return V(e)(ut,this)}function B(e){return e.replace(ct,function(e,t,n,r){return J(t+"', filter."+n+"( date ), '"+r)})}function J(e){return"out.push( '"+e+"' );"}function Q(e,n){q(e)||(q(new t(e))?e=new t(e):(n=e,e=t.now()));var r=t.locale.lexicon;return"function"!=typeof zt[n=(n+"").toLowerCase()]&&(n=r.DEFAULT),+e-+this?zt[n].call(r,this,e).replace(qt," "):r.just_now}function X(e){return e.join(" ")}function et(e,t){var n=e.pop();return(e.length?e.join(this.delim)+" "+this.and+" "+n:n)+" "+this[1>t.tense?"ago":"from_now"]}function tt(n){switch(e.ntype(n)){case"object":if(n.id){Rt[n.id]=n;break}case"string":if(n in Rt){n=Rt[n];break}default:n=null}return"object"==e.ntype(n)&&(e.defs(t,{locale:{value:n},getOrdinal:n.getOrdinal,isLeapYear:n.isLeapYear,setLeapYear:n.setLeapYear},"w",!0),n.id in It||(It[n.id]=e.obj()),n.id in At||(At[n.id]=e.obj()),ut=nt(n),at=rt(n),ot=it(n)),t}function nt(n){var u={d:function(e){return a(e.getDate(),2)},D:function(e){return n.days[e.getDay()].substring(0,3)},j:function(e){return e.getDate()},l:function(e){return n.days[e.getDay()]},N:function(e){return I.call(e)},S:function(e){return n.getOrdinal(e.getDate())},w:function(e){return e.getDay()},z:function(e){return e.getDayOfYear()},W:function(e){return z.call(e)},F:function(e){return n.months[e.getMonth()]},m:function(e){return a(e.getMonth()+1,2)},M:function(e){return n.months[e.getMonth()].substring(0,3)},n:function(e){return e.getMonth()+1},t:function(e){return n.setLeapYear(e),n.day_count[e.getMonth()]},L:function(e){return e.isLeapYear()?1:0},o:function(e){var t=e.getMonth(),n=z.call(e);return e.getFullYear()+(1==n&&t>0?1:n>=52&&11>t?-1:0)},Y:function(e){return e.getFullYear()},y:function(e){return(e.getFullYear()+"").substring(2,4)},a:function(e){return r(12>e.getHours()?n.AM:n.PM)},A:function(e){return i(12>e.getHours()?n.AM:n.PM)},g:function(e){return e.getHours()%12||12},G:function(e){return e.getHours()},h:function(e){return a(ut.g(e),2)},H:function(e){return a(ut.G(e),2)},i:function(e){return a(e.getMinutes(),2)},s:function(e){return a(e.getSeconds(),2)},u:function(e){return a(e.getMilliseconds(),3)},O:function(e){return E.call(e)},P:function(e){return E.call(e,!0)},T:function(e){return K.call(e)},Z:function(e){return-60*e.getTimezoneOffset()},c:function(e){return $.call(e,at.ISO_8601)},r:function(e){return $.call(e,at.RFC_2822)},U:function(e){return e.getTime()},e:function(e){return e.lexicalize("exact")},x:function(e){return e.lexicalize("approx")}};return st=Object.keys(u).sort().join(""),ct=RegExp("([^"+st+"]*)(["+st+"])([^"+st+"]*)","g"),e.def(t,"filters",{value:ut=u},"w",!0),u}function rt(n){var r=e.copy({ISO_8601:"Y-m-d<T>H:i:s.u<Z>",ISO_8601_SHORT:"Y-m-d",RFC_850:"l, d-M-y H:i:s T",RFC_2822:"D, d M Y H:i:s O",sortable:"Y-m-d H:i:sO"},n.formats);return r.atom=r.ISO_8601,r.cookie=r.RFC_850,r.rss=r.RFC_2822,e.def(t,"formats",{value:at=r},"w",!0),r}function it(u){var s={d:{k:kt,fn:Number,re:Gt},D:{k:Mt,fn:n.bind(null,u.days_short),re:"("+u.days_short.join("|")+")"},j:{k:kt,fn:Number,re:Zt},l:{k:Mt,fn:n.bind(null,u.days),re:"("+u.days.join("|")+")"},N:{k:Mt,fn:D.bind(null,7),re:"([1-7])"},S:{re:"(?:"+u.ordinal.join("|")+")"},w:{k:Mt,fn:Number,re:"([0-6])"},z:{k:yt,fn:Number,re:"([0-9]{1,3})"},W:{k:St,fn:Number,re:Gt},F:{k:Ot,fn:n.bind(null,u.months),re:"("+u.months.join("|")+")"},m:{k:Ot,fn:D,re:Gt},M:{k:Ot,fn:n.bind(null,u.months_short),re:"("+u.months_short.join("|")+")"},n:{k:Ot,fn:D,re:Zt},t:{re:"[0-9]{2}"},L:{re:"(?:0|1)"},o:{k:xt,fn:Number,re:Kt},Y:{k:xt,fn:Number,re:Kt},y:{k:xt,fn:function(e){return e=Number(e),e+=30>e?2e3:1900},re:Gt},a:{k:_t,fn:e,re:Ut},A:{k:_t,fn:r,re:i(Ut)},g:{k:vt,fn:v,re:Zt},G:{k:vt,fn:Number,re:Zt},h:{k:vt,fn:v,re:Gt},H:{k:vt,fn:Number,re:Gt},i:{k:wt,fn:Number,re:Gt},s:{k:Yt,fn:Number,re:Gt},u:{k:Nt,fn:Number,re:"([0-9]{1,})"},O:{k:jt,fn:Y,re:"([\\+-][0-9]{4})"},P:{k:jt,fn:Y,re:"([\\+-][0-9]{2}:[0-9]{2})"},T:{re:"[A-Z]{1,4}"},Z:{k:jt,fn:Number,re:"([\\+-]?[0-9]{5})"},U:{k:Dt,fn:Number,re:"(-?[0-9]{1,})"}};return s.c={combo:[s.Y,s.m,s.d,s.H,s.i,s.s,s.u,s.P],re:[s.Y.re,"-",s.m.re,"-",s.d.re,"T",s.H.re,":",s.i.re,":",s.s.re,"(?:\\.",s.u.re,"){0,1}",s.P.re,"{0,1}"].join("")},s.r={combo:[s.D,s.d,s.M,s.Y,s.H,s.i,s.s,s.O],re:[s.D.re,", ",s.d.re," ",s.M.re," ",s.Y.re," ",s.H.re,":",s.i.re,":",s.s.re," ",s.O.re].join("")},e.def(t,"parsers",{value:ot=s},"w",!0),s}var ut,st,at,ot,ct,lt=[9,1,0,-1,-2,4,3],ft=864e5,ht=36e5,mt=6e4,gt=2592e6,dt=1e3,pt=6048e5,bt=31536e6,_t="ampm",kt="day",Mt="dayweek",yt="dayyear",vt="hour",Nt="ms",wt="minute",Ot="month",Yt="second",jt="timezone",Dt="unix",St="week",xt="year",Tt="NOREPLACE",Lt="<"+Tt+"<",Ft=">END"+Tt+">",Ht={day:["getDate","setDate"],hr:["getHours","setHours"],min:["getMinutes","setMinutes"],month:["getMonth","setMonth"],ms:["getMilliseconds","setMilliseconds"],sec:["getSeconds","setSeconds"],week:["getWeek","setWeek"],year:["getFullYear","setFullYear"]},Et=[xt,Ot,St,kt,"hr",wt.substring(0,3),Yt.substring(0,3),Nt],It=e.obj(),At=e.obj(),Ct=[kt,Mt,yt,Ot,St,xt],zt=e.obj(),Rt=e.obj(),Ut="(am|pm)",Wt=/>/g,Pt=/</g,Zt="([0-9]{1,2})",Gt="([0-9]{2})",Kt="([0-9]{4})",qt=/\s{2,}/g,Vt=/[<>]/,$t=/[^\(]*\(([^\)]+)\)/g,Bt=/[^A-Z]+/g,Jt=/[\+-]?([0-9]{2}):?([0-9]{2})/,Qt=[[xt+"s",bt],[Ot+"s",gt],[St+"s",pt],[kt+"s",ft],[vt+"s",ht],[wt+"s",mt],[Yt+"s",dt],[Nt,1]],Xt=Qt.pluck(0);zt.approx=function(e,n){var r,i,u,s,a,o,c,l=this.a,f=e.diff(n),h=t.diffKeys(f),m=t.time_map,g=this.time_units;if(f.value<t.MS_MINUTE)return this.just_now;switch(h[0]){case"years":u=0;break;case"months":u=1;break;case"weeks":u=2;break;case"days":2>f.days&&(o=e.format("l")===n.format("l"),c=o||"hours"!=h[1]||25>f.hours),u=3;break;case"hours":o=e.format("l")===n.format("l"),c=f.hours/24>=.75,l=this.an,u=4;break;case"minutes":u=5}if(i=(f.value-m[u][1]*f[h[0]])/m[u][1],c)return o?this.today:f.tense>0?this.tomorrow:this.yesterday;if(s=[],a=f.tense>0?this.from_now:this.ago,.1>i)switch(h[0]){case"years":case"months":case"weeks":if(1===f[h[0]]){s.push(1>f.tense?this.last:this.next,g[u][0]);break}default:!i||s.push(this.about),s.push(f[h[0]],g[u][f[h[0]]>1?1:0],a)}else.74>i?.24>i?r=this.just_over:(r=i>.24&&.4>i?this.almost:this.about,s.push(this.and,this.a,this.half)):s.push(this.almost,f[h[0]]+1,g[u][1],a);return r&&(s.push(g[u][f[h[0]]>1||s.length?1:0],a),s.unshift(r,f[h[0]])),"function"==typeof this.approx?this.approx.call(this,s,f):X.call(this,s,f)},zt.exact=function(e,n){var r,i=e.diff(n),u=this.time_units;return r=t.time_map.reduce(function(e,t,n){var r=i[t[0]];return!r||!u[n]||e.push(r+" "+u[n][r>1?1:0]),e},[]),r.length?"function"==typeof this.exact?this.exact.call(this,r,i):et.call(this,r,i):this.just_now},e.defs(t.prototype,{adjust:S,between:x,clearTime:T,clone:L,diff:d,format:$,getDayOfYear:F,getFirstOfTheMonth:H,getGMTOffset:E,getISODay:I,getISODaysInYear:A,getISOFirstMondayOfYear:C,getISOWeek:z,getISOWeeksInYear:R,getLastOfTheMonth:U,getWeek:W,isDST:P,isLeapYear:Z,lexicalize:Q,setWeek:G,timezone:K,valid:function(){return t.valid(this)}},"r"),e.defs(t,{DAY:kt,HOUR:"hr",MINUTE:wt.substring(0,3),MILLISECOND:Nt,MONTH:Ot,SECOND:Yt.substring(0,3),WEEK:St,YEAR:xt,MS_DAY:ft,MS_HOUR:ht,MS_MINUTE:mt,MS_MONTH:gt,MS_SECOND:dt,MS_WEEK:pt,MS_YEAR:bt,lexicon:{value:zt},time_map:{value:Qt},time_props:{value:Xt},coerce:c,diffKeys:y,localize:tt,toDate:c,valid:q},"r")}).x(Date)}("undefined"!=typeof m8?m8:"undefined"!=typeof require?require("m8"):null); |
@@ -33,3 +33,3 @@ { | ||
}, | ||
"version" : "0.4.1" | ||
"version" : "0.4.2" | ||
} |
@@ -33,3 +33,3 @@ function lexicalize( now, precision ) { | ||
dkeys = Type.diffKeys( diff ), index, parts, tense, | ||
tm = Type.time_map, tu = this.time_units, use_noun; | ||
tm = Type.time_map, tu = this.time_units, today, use_noun; | ||
@@ -40,11 +40,15 @@ if ( diff.value < Type.MS_MINUTE ) | ||
switch ( dkeys[0] ) { | ||
case 'years' : index = 0; break; | ||
case 'months' : index = 1; break; | ||
case 'weeks' : index = 2; break; | ||
case 'days' : use_noun = diff.days === 1 && ( dkeys[1] != 'hours' || diff.hours / 24 < .25 ); | ||
index = 3; break; | ||
case 'hours' : use_noun = diff.hours / 24 >= .75; | ||
determiner = this.an; | ||
index = 4; break; | ||
case 'minutes' : index = 5; break; | ||
case 'years' : index = 0; break; | ||
case 'months' : index = 1; break; | ||
case 'weeks' : index = 2; break; | ||
case 'days' : if ( diff.days < 2 ) { | ||
today = date.format( 'l' ) === now.format( 'l' ); | ||
use_noun = today || dkeys[1] != 'hours' || diff.hours < 25; | ||
} | ||
index = 3; break; | ||
case 'hours' : today = date.format( 'l' ) === now.format( 'l' ); | ||
use_noun = diff.hours / 24 >= .75; | ||
determiner = this.an; | ||
index = 4; break; | ||
case 'minutes' : index = 5; break; | ||
} | ||
@@ -55,3 +59,3 @@ | ||
if ( use_noun ) | ||
return diff.tense > 0 ? this.tomorrow : index === 4 ? this.today : this.yesterday; | ||
return today ? this.today : diff.tense > 0 ? this.tomorrow : this.yesterday; | ||
@@ -58,0 +62,0 @@ parts = []; |
@@ -427,3 +427,5 @@ // 481 | ||
expect( ( new Date( 2012, 0, 1 ) ).adjust( Date.DAY, -1 ).lexicalize( new Date( 2012, 0, 1 ), 'approx' ) ).to.equal( 'yesterday' ); | ||
expect( ( new Date( 2012, 0, 1, 12 ) ).adjust( Date.HOUR, -18 ).lexicalize( new Date( 2012, 0, 1, 12 ), 'approx' ) ).to.equal( 'yesterday' ); | ||
expect( ( new Date( 2012, 0, 1 ) ).adjust( Date.DAY, 1 ).lexicalize( new Date( 2012, 0, 1 ), 'approx' ) ).to.equal( 'tomorrow' ); | ||
expect( ( new Date( 2012, 0, 1, 12 ) ).adjust( Date.HOUR, 18 ).lexicalize( new Date( 2012, 0, 1, 12 ), 'approx' ) ).to.equal( 'tomorrow' ); | ||
expect( ( new Date( 2012, 0, 1 ) ).adjust( Date.DAY, -2 ).adjust( Date.HOUR, -6 ).lexicalize( new Date( 2012, 0, 1 ), 'approx' ) ).to.equal( 'almost 2 and a half days ago' ); | ||
@@ -430,0 +432,0 @@ expect( ( new Date( 2012, 0, 1 ) ).adjust( Date.DAY, 2 ).adjust( Date.HOUR, 6 ).lexicalize( new Date( 2012, 0, 1 ), 'approx' ) ).to.equal( 'almost 2 and a half days from now' ); |
@@ -424,3 +424,5 @@ // 481 | ||
expect( ( new Date( 2012, 0, 1 ) ).adjust( Date.DAY, -1 ).lexicalize( new Date( 2012, 0, 1 ), 'approx' ) ).to.equal( 'yesterday' ); | ||
expect( ( new Date( 2012, 0, 1, 12 ) ).adjust( Date.HOUR, -18 ).lexicalize( new Date( 2012, 0, 1, 12 ), 'approx' ) ).to.equal( 'yesterday' ); | ||
expect( ( new Date( 2012, 0, 1 ) ).adjust( Date.DAY, 1 ).lexicalize( new Date( 2012, 0, 1 ), 'approx' ) ).to.equal( 'tomorrow' ); | ||
expect( ( new Date( 2012, 0, 1, 12 ) ).adjust( Date.HOUR, 18 ).lexicalize( new Date( 2012, 0, 1, 12 ), 'approx' ) ).to.equal( 'tomorrow' ); | ||
expect( ( new Date( 2012, 0, 1 ) ).adjust( Date.DAY, -2 ).adjust( Date.HOUR, -6 ).lexicalize( new Date( 2012, 0, 1 ), 'approx' ) ).to.equal( 'almost 2 and a half days ago' ); | ||
@@ -427,0 +429,0 @@ expect( ( new Date( 2012, 0, 1 ) ).adjust( Date.DAY, 2 ).adjust( Date.HOUR, 6 ).lexicalize( new Date( 2012, 0, 1 ), 'approx' ) ).to.equal( 'almost 2 and a half days from now' ); |
@@ -426,3 +426,5 @@ typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
expect( ( new Date( 2012, 0, 1 ) ).adjust( Date.DAY, -1 ).lexicalize( new Date( 2012, 0, 1 ), 'approx' ) ).to.equal( 'εχθές' ); | ||
expect( ( new Date( 2012, 0, 1, 12 ) ).adjust( Date.HOUR, -18 ).lexicalize( new Date( 2012, 0, 1, 12 ), 'approx' ) ).to.equal( 'εχθές' ); | ||
expect( ( new Date( 2012, 0, 1 ) ).adjust( Date.DAY, 1 ).lexicalize( new Date( 2012, 0, 1 ), 'approx' ) ).to.equal( 'αύριο' ); | ||
expect( ( new Date( 2012, 0, 1, 12 ) ).adjust( Date.HOUR, 18 ).lexicalize( new Date( 2012, 0, 1, 12 ), 'approx' ) ).to.equal( 'αύριο' ); | ||
expect( ( new Date( 2012, 0, 1 ) ).adjust( Date.DAY, -2 ).adjust( Date.HOUR, -6 ).lexicalize( new Date( 2012, 0, 1 ), 'approx' ) ).to.equal( 'σχεδόν 2 και μισή ημέρες πριν' ); | ||
@@ -429,0 +431,0 @@ expect( ( new Date( 2012, 0, 1 ) ).adjust( Date.DAY, 2 ).adjust( Date.HOUR, 6 ).lexicalize( new Date( 2012, 0, 1 ), 'approx' ) ).to.equal( 'σχεδόν 2 και μισή ημέρες από τώρα' ); |
241202
3062