Initial check-in
[dygraphs.git] / mochikit_v14 / doc / rst / MochiKit / DateTime.rst
1 .. title:: MochiKit.DateTime - "what time is it anyway?"
2
3 Name
4 ====
5
6 MochiKit.DateTime - "what time is it anyway?"
7
8
9 Synopsis
10 ========
11
12 ::
13
14    stringDate = toISOTimestamp(new Date());
15    dateObject = isoTimestamp(stringDate);
16
17
18 Description
19 ===========
20
21 Remote servers don't give you JavaScript Date objects, and they
22 certainly don't want them from you, so you need to deal with string
23 representations of dates and timestamps. MochiKit.Date does that.
24
25
26 Dependencies
27 ============
28
29 None.
30
31
32 API Reference
33 =============
34
35 Functions
36 ---------
37
38 :mochidef:`isoDate(str)`:
39
40     Convert an ISO 8601 date (YYYY-MM-DD) to a ``Date`` object.
41
42     *Availability*:
43         Available in MochiKit 1.3.1+
44
45
46 :mochidef:`isoTimestamp(str)`:
47
48     Convert any ISO 8601 [1]_ timestamp (or something reasonably close
49     to it) to a ``Date`` object. Will accept the "de facto" form:
50
51         YYYY-MM-DD hh:mm:ss
52
53     or (the proper form):
54
55         YYYY-MM-DDThh:mm:ssZ
56
57     If a time zone designator ("Z" or "[+-]HH:MM") is not present,
58     then the local timezone is used.
59
60     *Availability*:
61         Available in MochiKit 1.3.1+
62
63
64 :mochidef:`toISOTime(date)`:
65
66     Convert a ``Date`` object to a string in the form of hh:mm:ss
67
68     *Availability*:
69         Available in MochiKit 1.3.1+
70
71
72 :mochidef:`toISOTimestamp(date, realISO=false)`:
73
74     Convert a ``Date`` object to something that's ALMOST but not quite
75     an ISO 8601 [1]_timestamp. If it was a proper ISO timestamp it
76     would be:
77
78         YYYY-MM-DDThh:mm:ssZ
79
80     However, we see junk in SQL and other places that looks like this:
81
82         YYYY-MM-DD hh:mm:ss
83
84     So, this function returns the latter form, despite its name,
85     unless you pass ``true`` for ``realISO``.
86
87     *Availability*:
88         Available in MochiKit 1.3.1+
89
90
91 :mochidef:`toISODate(date)`:
92
93     Convert a ``Date`` object to an ISO 8601 [1]_ date string
94     (YYYY-MM-DD)
95
96     *Availability*:
97         Available in MochiKit 1.3.1+
98
99
100 :mochidef:`americanDate(str)`:
101
102     Converts a MM/DD/YYYY date to a ``Date`` object
103
104     *Availability*:
105         Available in MochiKit 1.3.1+
106
107
108 :mochidef:`toPaddedAmericanDate(date)`:
109
110     Converts a ``Date`` object to an MM/DD/YYYY date, e.g. 01/01/2001
111
112     *Availability*:
113         Available in MochiKit 1.3.1+
114
115
116 :mochidef:`toAmericanDate(date)`:
117
118     Converts a ``Date`` object to an M/D/YYYY date, e.g. 1/1/2001
119
120     *Availability*:
121         Available in MochiKit 1.3.1+
122
123
124 See Also
125 ========
126
127 .. [1] W3C profile of ISO 8601: http://www.w3.org/TR/NOTE-datetime
128
129
130 Authors
131 =======
132
133 - Bob Ippolito <bob@redivi.com>
134
135
136 Copyright
137 =========
138
139 Copyright 2005 Bob Ippolito <bob@redivi.com>. This program is
140 dual-licensed free software; you can redistribute it and/or modify it
141 under the terms of the `MIT License`_ or the `Academic Free License
142 v2.1`_.
143
144 .. _`MIT License`: http://www.opensource.org/licenses/mit-license.php
145 .. _`Academic Free License v2.1`: http://www.opensource.org/licenses/afl-2.1.php