root / trunk / web / dojo / dojox / date / relative.js @ 11
History | View | Annotate | Download (1.28 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.date.relative"]){ |
9 |
dojo._hasResource["dojox.date.relative"]=true; |
10 |
dojo.provide("dojox.date.relative");
|
11 |
dojo.require("dojo.date");
|
12 |
dojo.require("dojo.date.locale");
|
13 |
(function(d){
|
14 |
var _1=1000*60*60*24; |
15 |
var _2=6*_1; |
16 |
var _3=d.delegate;
|
17 |
var _4=d.date.locale;
|
18 |
var _5=_4._getGregorianBundle;
|
19 |
var _6=_4.format;
|
20 |
function _7(_8){ |
21 |
_8=dojo.clone(_8); |
22 |
_8.setHours(0);
|
23 |
_8.setMinutes(0);
|
24 |
_8.setSeconds(0);
|
25 |
_8.setMilliseconds(0);
|
26 |
return _8;
|
27 |
}; |
28 |
dojox.date.relative.format=function(_9,_a){ |
29 |
_a=_a||{}; |
30 |
var _b=_7(_a.relativeDate||new Date()); |
31 |
var _c=_b.getTime()-_7(_9).getTime();
|
32 |
var _d={locale:_a.locale}; |
33 |
if(_c===0){ |
34 |
return _6(_9,_3(_d,{selector:"time"})); |
35 |
}else{
|
36 |
if(_c<=_2&&_c>0&&_a.weekCheck!==false){ |
37 |
return _6(_9,_3(_d,{selector:"date",datePattern:"EEE"}))+" "+_6(_9,_3(_d,{selector:"time",formatLength:"short"})); |
38 |
}else{
|
39 |
if(_9.getFullYear()==_b.getFullYear()){
|
40 |
var _e=_5(dojo.i18n.normalizeLocale(_a.locale));
|
41 |
return _6(_9,_3(_d,{selector:"date",datePattern:_e["dateFormatItem-MMMd"]})); |
42 |
}else{
|
43 |
return _6(_9,_3(_d,{selector:"date",formatLength:"medium",locale:_a.locale})); |
44 |
} |
45 |
} |
46 |
} |
47 |
}; |
48 |
})(dojo); |
49 |
} |