This repository was archived by the owner on Apr 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdevelopment_javascript_Date.html
More file actions
221 lines (172 loc) · 6.13 KB
/
development_javascript_Date.html
File metadata and controls
221 lines (172 loc) · 6.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mobile Widgets</title>
<link rel="stylesheet" href="style/style.css" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="js/StructureElts.js"></script>
<script type="text/javascript" src="js/Structure.js"></script>
<script type="text/javascript" src="js/DocElements.js"></script>
</head>
<body>
<script type="text/javascript">
<!--
idCurrentPage = "development_javascript_Date";
beginPage();
//-->
</script>
<h1 class="title">Date Javascript library</h1>
<script type="text/javascript">
<!--
addIndex();
//-->
</script>
<script type="text/javascript">addTitle("Description", 1);</script>
<p>
The Date class provides means to manipulate current date.
</p>
<h2>Timezones</h2>
<p>
When the timezone is not defined, the default timezone of the phone will be used.<br/>
However, the most commonly used timezone for "universal" UTC timestamps is the
"GMT" (Greenwich Meridian Time) timezone.<br/>
The "GMT" timezone is guaranteed to work on <i>all</i> phones. Some phones
<i>may</i> also support the "GTM+X:XX" or "GMT-X:XX" form.<br/>
A list of supported timezones can also be retrieved from the MeMo console using
the info command (key '3').
</p>
<br/>
<script type="text/javascript">addTitle("Since", 1);</script>
<h2>1.4.1</h2>
<p>
Since 1.4.1, all get* and to* methods (<b>Date.getYear()</b>,
<b>Date.getMonth()</b>, ...) accept two optional arguments a <b>timestamp</b>
and a <b>timezone</b>.<br/>
Only exception is <b>getTime()</b> that accepts multiple optional arguments to
define a timestamp from a list of values (year, month, day, etc.).
</p>
<p>
New methods: <b>getWeek()</b>, <b>parseDate()</b> and <b>toString()</b>.<br/>
New constants: <b>MIN</b>, <b>HOUR</b>, <b>DAY</b>, <b>WEEK</b>.
</p>
<br/>
<script type="text/javascript">addTitle("Methods", 1);</script>
<p>
<b>int getDay ([int timestamp, [String timezone]])</b>:<br/>
Returns the current day of the month, or the day of the month corresponding to
the given <b>timestamp</b>.
</p>
<p>
<b>int getDayOfWeek ([int timestamp, [String timezone]])</b>:<br/>
Returns day of the week (monday=1, sunday=7).
</p>
<p>
<b>int getHour ([int timestamp, [String timezone]])</b>:<br/>
Returns the current hour, or the hour corresponding to the given <b>timestamp</b>.
</p>
<p>
<b>int getMinute ([int timestamp, [String timezone]])</b>:<br/>
Returns the current minute, or the minute corresponding to the given <b>timestamp</b>.
</p>
<p>
<b>int getMonth ([int timestamp, [String timezone]])</b>:<br/>
Returns the current month number, or the month number corresponding to the given <b>timestamp</b>.
</p>
<p>
<b>int getSecond ([int timestamp, [String timezone]])</b>:<br/>
Returns the current second, or the year corresponding to the given <b>timestamp</b>.
</p>
<p>
<b>int getTime ([int year, [int month, [int day, [int hour, [int min, [int sec, [String timezone]]]]]]])</b>:<br/>
Returns the current time when no parameters are defined.<br/>
Returns the time given by the optional arguments in seconds since midnight, January 1, 1970 UTC, or 0 on error.<br/>
Default values of optional args: month is 1, day is 1, hour is 0, min is 0,
sec is 0 (e.g. timestamp returned for <b>Date.getTime(2009)</b> equals <b>Date.getTime(2009, 1, 1, 0, 0, 0)</b>)<br/>
Default timezone is the current phone timezone.
</p>
<p>
<b>int getWeek ([int timestamp, [String timezone]])</b>:<br/>
Returns the current week number, or the week number corresponding to the given <b>timestamp</b>.<br/>
<b>Since 1.4.1</b>
</p>
<p>
<b>int getYear ([int timestamp, [String timezone]])</b>:<br/>
Returns the current year, or the year corresponding to the given <b>timestamp</b>.
</p>
<p>
<b>int parseDate (String isoDate, [String timezone])</b>:<br/>
Returns a timestamp by parsing an <a href="http://wikipedia.org/wiki/ISO_8601" target="_blank">
ISO-8601 formated string</a>, or 0 on error.<br/>
Only the following two extended formats are supported:
</p>
<ul>
<li>for GMT/UTC times: YYYY-MM-DDTHH:MM:SSZ (20 chars)</li>
<li>for local times: YYYY-MM-DDTHH:MM:SS+XX:XX and YYYY-MM-DDTHH:MM:SS-XX:XX (25 chars)</li>
</ul>
<p class="note check">
<b>Note:</b><br/>
the presence of the separators ('-', 'T' and ':') between the numbers is
mandatory, but their value be changed (e.g. "2009 11 29 11!57!23Z" is a valid string).<br/>
If a <b>timezone</b> is given, the returned timestamp will be converted to it.<br/>
</p>
<p>
<b>Since 1.4.1</b>
</p>
<p>
<b>int time ()</b>:<br/>
</p>
<p class="note warning">
<b>DEPRECATED</b><br/>Use the <b>getTime()</b> method.
</p>
<p>
<b>String toString ([int timestamp, [int timezone]])</b>:<br/>
Returns a <a href="http://wikipedia.org/wiki/ISO_8601" target="_blank">
ISO-8601 formated string</a> using current time, or the given <b>timestamp</b> time.<br/>
<b>Since 1.4.1</b>
</p>
<br/>
<script type="text/javascript">addTitle("Constants", 1);</script>
<p>
<b>int DAY</b>:<br/>
Number of seconds in a day (86400).<br/>
<b>Since 1.4.1</b>
</p>
<p>
<b>int HOUR</b>:<br/>
Number of seconds in an hour (3600).<br/>
<b>Since 1.4.1</b>
</p>
<p>
<b>int MINUTE</b>:<br/>
Number of seconds in a minute (60).<br/>
<b>Since 1.4.1</b>
</p>
<p>
<b>int WEEK</b>:<br/>
Number of seconds in a week (604800).<br/>
<b>Since 1.4.1</b>
</p>
<br/>
<script type="text/javascript">addTitle("Examples", 1);</script>
<textarea wrap="off" readonly="readonly" rows="4" cols="80">
function test () {
// Display current date
Browser.print ( Date.getDay() + '/' + Date.getMonth() + '/' + Date.getYear() );
}
</textarea>
<br/>
<script type="text/javascript">
<!--
addBackPageNavigator('widgets_development_javascript_ref', '');
//-->
</script>
<script type="text/javascript">
<!--
endPage();
//-->
</script>
</body>
</html>