Debian Codegraph @

dojox/dtl/filter/dates.js

raw symbols SCIP
1 define([
2 "dojo/_base/lang",
3 "../_base",
4 "../utils/date"
5 ], function(lang,dd,ddud){
6
7 var ddfd = lang.getObject("filter.dates", true, dd);
8 /*=====
9 ddfd = {
10 // TODO: summary
11 };
12 =====*/
13
14 lang.mixin(ddfd, {
15 _toDate: function(value){
16 if(value instanceof Date){
17 return value;
18 }
19 value = new Date(value);
20 if(value.getTime() == new Date(0).getTime()){
21 return "";
22 }
23 return value;
24 },
25 date: function(value, arg){
26 // summary:
27 // Formats a date according to the given format
28 value = ddfd._toDate(value);
29 if(!value){
30 return "";
31 }
32 arg = arg || "N j, Y";
33 return ddud.format(value, arg);
34 },
35 time: function(value, arg){
36 // summary:
37 // Formats a time according to the given format
38 value = ddfd._toDate(value);
39 if(!value){
40 return "";
41 }
42 arg = arg || "P";
43 return ddud.format(value, arg);
44 },
45 timesince: function(value, arg){
46 // summary:
47 // Formats a date as the time since that date (i.e. "4 days, 6 hours")
48 value = ddfd._toDate(value);
49 if(!value){
50 return "";
51 }
52 var timesince = ddud.timesince;
53 if(arg){
54 return timesince(arg, value);
55 }
56 return timesince(value);
57 },
58 timeuntil: function(value, arg){
59 // summary:
60 // Formats a date as the time until that date (i.e. "4 days, 6 hours")
61 value = ddfd._toDate(value);
62 if(!value){
63 return "";
64 }
65 var timesince = ddud.timesince;
66 if(arg){
67 return timesince(arg, value);
68 }
69 return timesince(new Date(), value);
70 }
71 });
72
73 return ddfd;
74 });