1 <?xml version=
"1.0" encoding=
"utf-8" ?>
2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en" lang=
"en">
6 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
7 <meta name=
"generator" content=
"Docutils 0.4: http://docutils.sourceforge.net/" />
8 <title>MochiKit.DateTime -
"what time is it anyway?
"</title>
10 <link rel=
"stylesheet" href=
"../../../include/css/documentation.css" type=
"text/css" />
11 <script type=
"text/javascript" src=
"../../../packed/MochiKit/MochiKit.js"></script>
12 <script type=
"text/javascript" src=
"../../js/toc.js"></script>
15 <div class=
"document">
17 <h1><a id=
"name" name=
"name">Name
</a></h1>
18 <p>MochiKit.DateTime -
"what time is it anyway?
"</p>
21 <h1><a id=
"synopsis" name=
"synopsis">Synopsis
</a></h1>
22 <pre class=
"literal-block">
23 stringDate = toISOTimestamp(new Date());
24 dateObject = isoTimestamp(stringDate);
28 <h1><a id=
"description" name=
"description">Description
</a></h1>
29 <p>Remote servers don't give you JavaScript Date objects, and they
30 certainly don't want them from you, so you need to deal with string
31 representations of dates and timestamps. MochiKit.Date does that.
</p>
34 <h1><a id=
"dependencies" name=
"dependencies">Dependencies
</a></h1>
38 <h1><a id=
"api-reference" name=
"api-reference">API Reference
</a></h1>
40 <h2><a id=
"functions" name=
"functions">Functions
</a></h2>
42 <a name=
"fn-isodate"></a>
43 <a class=
"mochidef reference" href=
"#fn-isodate">isoDate(str)
</a>:
</p>
45 <p>Convert an ISO
8601 date (YYYY-MM-DD) to a
<tt class=
"docutils literal"><span class=
"pre">Date
</span></tt> object.
</p>
47 <dt><em>Availability
</em>:
</dt>
48 <dd>Available in MochiKit
1.3.1+
</dd>
52 <a name=
"fn-isotimestamp"></a>
53 <a class=
"mochidef reference" href=
"#fn-isotimestamp">isoTimestamp(str)
</a>:
</p>
55 <p>Convert any ISO
8601 <a class=
"footnote-reference" href=
"#id3" id=
"id1" name=
"id1">[
1]
</a> timestamp (or something reasonably close
56 to it) to a
<tt class=
"docutils literal"><span class=
"pre">Date
</span></tt> object. Will accept the
"de facto
" form:
</p>
58 YYYY-MM-DD hh:mm:ss
</blockquote>
59 <p>or (the proper form):
</p>
61 YYYY-MM-DDThh:mm:ssZ
</blockquote>
62 <p>If a time zone designator (
"Z
" or
"[+-]HH:MM
") is not present,
63 then the local timezone is used.
</p>
65 <dt><em>Availability
</em>:
</dt>
66 <dd>Available in MochiKit
1.3.1+
</dd>
70 <a name=
"fn-toisotime"></a>
71 <a class=
"mochidef reference" href=
"#fn-toisotime">toISOTime(date)
</a>:
</p>
73 <p>Convert a
<tt class=
"docutils literal"><span class=
"pre">Date
</span></tt> object to a string in the form of hh:mm:ss
</p>
75 <dt><em>Availability
</em>:
</dt>
76 <dd>Available in MochiKit
1.3.1+
</dd>
80 <a name=
"fn-toisotimestamp"></a>
81 <a class=
"mochidef reference" href=
"#fn-toisotimestamp">toISOTimestamp(date, realISO=false)
</a>:
</p>
83 <p>Convert a
<tt class=
"docutils literal"><span class=
"pre">Date
</span></tt> object to something that's ALMOST but not quite
84 an ISO
8601 [
1]_timestamp. If it was a proper ISO timestamp it
87 YYYY-MM-DDThh:mm:ssZ
</blockquote>
88 <p>However, we see junk in SQL and other places that looks like this:
</p>
90 YYYY-MM-DD hh:mm:ss
</blockquote>
91 <p>So, this function returns the latter form, despite its name,
92 unless you pass
<tt class=
"docutils literal"><span class=
"pre">true
</span></tt> for
<tt class=
"docutils literal"><span class=
"pre">realISO
</span></tt>.
</p>
94 <dt><em>Availability
</em>:
</dt>
95 <dd>Available in MochiKit
1.3.1+
</dd>
99 <a name=
"fn-toisodate"></a>
100 <a class=
"mochidef reference" href=
"#fn-toisodate">toISODate(date)
</a>:
</p>
102 <p>Convert a
<tt class=
"docutils literal"><span class=
"pre">Date
</span></tt> object to an ISO
8601 <a class=
"footnote-reference" href=
"#id3" id=
"id2" name=
"id2">[
1]
</a> date string
104 <dl class=
"docutils">
105 <dt><em>Availability
</em>:
</dt>
106 <dd>Available in MochiKit
1.3.1+
</dd>
110 <a name=
"fn-americandate"></a>
111 <a class=
"mochidef reference" href=
"#fn-americandate">americanDate(str)
</a>:
</p>
113 <p>Converts a MM/DD/YYYY date to a
<tt class=
"docutils literal"><span class=
"pre">Date
</span></tt> object
</p>
114 <dl class=
"docutils">
115 <dt><em>Availability
</em>:
</dt>
116 <dd>Available in MochiKit
1.3.1+
</dd>
120 <a name=
"fn-topaddedamericandate"></a>
121 <a class=
"mochidef reference" href=
"#fn-topaddedamericandate">toPaddedAmericanDate(date)
</a>:
</p>
123 <p>Converts a
<tt class=
"docutils literal"><span class=
"pre">Date
</span></tt> object to an MM/DD/YYYY date, e.g.
01/
01/
2001</p>
124 <dl class=
"docutils">
125 <dt><em>Availability
</em>:
</dt>
126 <dd>Available in MochiKit
1.3.1+
</dd>
130 <a name=
"fn-toamericandate"></a>
131 <a class=
"mochidef reference" href=
"#fn-toamericandate">toAmericanDate(date)
</a>:
</p>
133 <p>Converts a
<tt class=
"docutils literal"><span class=
"pre">Date
</span></tt> object to an M/D/YYYY date, e.g.
1/
1/
2001</p>
134 <dl class=
"docutils">
135 <dt><em>Availability
</em>:
</dt>
136 <dd>Available in MochiKit
1.3.1+
</dd>
141 <div class=
"section">
142 <h1><a id=
"see-also" name=
"see-also">See Also
</a></h1>
143 <table class=
"docutils footnote" frame=
"void" id=
"id3" rules=
"none">
144 <colgroup><col class=
"label" /><col /></colgroup>
146 <tr><td class=
"label"><a name=
"id3">[
1]
</a></td><td><em>(
<a class=
"fn-backref" href=
"#id1">1</a>,
<a class=
"fn-backref" href=
"#id2">2</a>)
</em> W3C profile of ISO
8601:
<a class=
"reference" href=
"http://www.w3.org/TR/NOTE-datetime">http://www.w3.org/TR/NOTE-datetime
</a></td></tr>
150 <div class=
"section">
151 <h1><a id=
"authors" name=
"authors">Authors
</a></h1>
153 <li>Bob Ippolito
<<a class=
"reference" href=
"mailto:bob@redivi.com">bob
@redivi.com
</a>></li>
156 <div class=
"section">
157 <h1><a id=
"copyright" name=
"copyright">Copyright
</a></h1>
158 <p>Copyright
2005 Bob Ippolito
<<a class=
"reference" href=
"mailto:bob@redivi.com">bob
@redivi.com
</a>>. This program is
159 dual-licensed free software; you can redistribute it and/or modify it
160 under the terms of the
<a class=
"reference" href=
"http://www.opensource.org/licenses/mit-license.php">MIT License
</a> or the
<a class=
"reference" href=
"http://www.opensource.org/licenses/afl-2.1.php">Academic Free License