1 .. title:: MochiKit.DateTime - "what time is it anyway?"
6 MochiKit.DateTime - "what time is it anyway?"
14 stringDate = toISOTimestamp(new Date());
15 dateObject = isoTimestamp(stringDate);
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.
38 :mochidef:`isoDate(str)`:
40 Convert an ISO 8601 date (YYYY-MM-DD) to a ``Date`` object.
43 Available in MochiKit 1.3.1+
46 :mochidef:`isoTimestamp(str)`:
48 Convert any ISO 8601 [1]_ timestamp (or something reasonably close
49 to it) to a ``Date`` object. Will accept the "de facto" form:
57 If a time zone designator ("Z" or "[+-]HH:MM") is not present,
58 then the local timezone is used.
61 Available in MochiKit 1.3.1+
64 :mochidef:`toISOTime(date)`:
66 Convert a ``Date`` object to a string in the form of hh:mm:ss
69 Available in MochiKit 1.3.1+
72 :mochidef:`toISOTimestamp(date, realISO=false)`:
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
80 However, we see junk in SQL and other places that looks like this:
84 So, this function returns the latter form, despite its name,
85 unless you pass ``true`` for ``realISO``.
88 Available in MochiKit 1.3.1+
91 :mochidef:`toISODate(date)`:
93 Convert a ``Date`` object to an ISO 8601 [1]_ date string
97 Available in MochiKit 1.3.1+
100 :mochidef:`americanDate(str)`:
102 Converts a MM/DD/YYYY date to a ``Date`` object
105 Available in MochiKit 1.3.1+
108 :mochidef:`toPaddedAmericanDate(date)`:
110 Converts a ``Date`` object to an MM/DD/YYYY date, e.g. 01/01/2001
113 Available in MochiKit 1.3.1+
116 :mochidef:`toAmericanDate(date)`:
118 Converts a ``Date`` object to an M/D/YYYY date, e.g. 1/1/2001
121 Available in MochiKit 1.3.1+
127 .. [1] W3C profile of ISO 8601: http://www.w3.org/TR/NOTE-datetime
133 - Bob Ippolito <bob@redivi.com>
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
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