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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Time" inherits="Object" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Time singleton for working with time.
</brief_description>
<description>
The Time singleton allows converting time between various formats and also getting time information from the system.
This class conforms with as many of the ISO 8601 standards as possible. All dates follow the Proleptic Gregorian calendar. As such, the day before [code]1582-10-15[/code] is [code]1582-10-14[/code], not [code]1582-10-04[/code]. The year before 1 AD (aka 1 BC) is number [code]0[/code], with the year before that (2 BC) being [code]-1[/code], etc.
Conversion methods assume "the same timezone", and do not handle timezone conversions or DST automatically. Leap seconds are also not handled, they must be done manually if desired. Suffixes such as "Z" are not handled, you need to strip them away manually.
When getting time information from the system, the time can either be in the local timezone or UTC depending on the [code]utc[/code] parameter. However, the [method get_unix_time_from_system] method always returns the time in UTC.
[b]Important:[/b] The [code]_from_system[/code] methods use the system clock that the user can manually set. [b]Never use[/b] this method for precise time calculation since its results are subject to automatic adjustments by the user or the operating system. [b]Always use[/b] [method get_ticks_usec] or [method get_ticks_msec] for precise time calculation instead, since they are guaranteed to be monotonic (i.e. never decrease).
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_date_dict_from_system" qualifiers="const">
<return type="Dictionary" />
<argument index="0" name="utc" type="bool" default="false" />
<description>
Returns the current date as a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]weekday[/code], and [code]dst[/code] (Daylight Savings Time).
The returned values are in the system's local time when [code]utc[/code] is false, otherwise they are in UTC.
</description>
</method>
<method name="get_date_dict_from_unix_time" qualifiers="const">
<return type="Dictionary" />
<argument index="0" name="unix_time_val" type="int" />
<description>
Converts the given Unix timestamp to a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], and [code]weekday[/code].
</description>
</method>
<method name="get_date_string_from_system" qualifiers="const">
<return type="String" />
<argument index="0" name="utc" type="bool" default="false" />
<description>
Returns the current date as an ISO 8601 date string (YYYY-MM-DD).
The returned values are in the system's local time when [code]utc[/code] is false, otherwise they are in UTC.
</description>
</method>
<method name="get_date_string_from_unix_time" qualifiers="const">
<return type="String" />
<argument index="0" name="unix_time_val" type="int" />
<description>
Converts the given Unix timestamp to an ISO 8601 date string (YYYY-MM-DD).
</description>
</method>
<method name="get_datetime_dict_from_string" qualifiers="const">
<return type="Dictionary" />
<argument index="0" name="datetime" type="String" />
<argument index="1" name="weekday" type="bool" />
<description>
Converts the given ISO 8601 date and time string (YYYY-MM-DDTHH:MM:SS) to a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]weekday[/code], [code]hour[/code], [code]minute[/code], and [code]second[/code].
If [code]weekday[/code] is false, then the [code]weekday[/code] entry is excluded (the calculation is relatively expensive).
</description>
</method>
<method name="get_datetime_dict_from_system" qualifiers="const">
<return type="Dictionary" />
<argument index="0" name="utc" type="bool" default="false" />
<description>
Returns the current date as a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]weekday[/code], [code]hour[/code], [code]minute[/code], and [code]second[/code].
</description>
</method>
<method name="get_datetime_dict_from_unix_time" qualifiers="const">
<return type="Dictionary" />
<argument index="0" name="unix_time_val" type="int" />
<description>
Converts the given Unix timestamp to a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], and [code]weekday[/code].
The returned Dictionary's values will be the same as the [method get_datetime_dict_from_system] if the Unix timestamp is the current time, with the exception of Daylight Savings Time as it cannot be determined from the epoch.
</description>
</method>
<method name="get_datetime_string_from_dict" qualifiers="const">
<return type="String" />
<argument index="0" name="datetime" type="Dictionary" />
<argument index="1" name="use_space" type="bool" />
<description>
Converts the given dictionary of keys to an ISO 8601 date and time string (YYYY-MM-DDTHH:MM:SS).
The given dictionary can be populated with the following keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]hour[/code], [code]minute[/code], and [code]second[/code]. Any other entries (including [code]dst[/code]) are ignored.
If the dictionary is empty, [code]0[/code] is returned. If some keys are omitted, they default to the equivalent values for the Unix epoch timestamp 0 (1970-01-01 at 00:00:00).
If [code]use_space[/code] is true, use a space instead of the letter T in the middle.
</description>
</method>
<method name="get_datetime_string_from_system" qualifiers="const">
<return type="String" />
<argument index="0" name="utc" type="bool" default="false" />
<argument index="1" name="use_space" type="bool" default="false" />
<description>
Returns the current date and time as an ISO 8601 date and time string (YYYY-MM-DDTHH:MM:SS).
The returned values are in the system's local time when [code]utc[/code] is false, otherwise they are in UTC.
If [code]use_space[/code] is true, use a space instead of the letter T in the middle.
</description>
</method>
<method name="get_datetime_string_from_unix_time" qualifiers="const">
<return type="String" />
<argument index="0" name="unix_time_val" type="int" />
<argument index="1" name="use_space" type="bool" default="false" />
<description>
Converts the given Unix timestamp to an ISO 8601 date and time string (YYYY-MM-DDTHH:MM:SS).
If [code]use_space[/code] is true, use a space instead of the letter T in the middle.
</description>
</method>
<method name="get_offset_string_from_offset_minutes" qualifiers="const">
<return type="String" />
<argument index="0" name="offset_minutes" type="int" />
<description>
Converts the given timezone offset in minutes to a timezone offset string. For example, -480 returns "-08:00", 345 returns "+05:45", and 0 returns "+00:00".
</description>
</method>
<method name="get_ticks_msec" qualifiers="const">
<return type="int" />
<description>
Returns the amount of time passed in milliseconds since the engine started.
Will always be positive or 0 and uses a 64-bit value (it will wrap after roughly 500 million years).
</description>
</method>
<method name="get_ticks_usec" qualifiers="const">
<return type="int" />
<description>
Returns the amount of time passed in microseconds since the engine started.
Will always be positive or 0 and uses a 64-bit value (it will wrap after roughly half a million years).
</description>
</method>
<method name="get_time_dict_from_system" qualifiers="const">
<return type="Dictionary" />
<argument index="0" name="utc" type="bool" default="false" />
<description>
Returns the current time as a dictionary of keys: [code]hour[/code], [code]minute[/code], and [code]second[/code].
The returned values are in the system's local time when [code]utc[/code] is false, otherwise they are in UTC.
</description>
</method>
<method name="get_time_dict_from_unix_time" qualifiers="const">
<return type="Dictionary" />
<argument index="0" name="unix_time_val" type="int" />
<description>
Converts the given time to a dictionary of keys: [code]hour[/code], [code]minute[/code], and [code]second[/code].
</description>
</method>
<method name="get_time_string_from_system" qualifiers="const">
<return type="String" />
<argument index="0" name="utc" type="bool" default="false" />
<description>
Returns the current time as an ISO 8601 time string (HH:MM:SS).
The returned values are in the system's local time when [code]utc[/code] is false, otherwise they are in UTC.
</description>
</method>
<method name="get_time_string_from_unix_time" qualifiers="const">
<return type="String" />
<argument index="0" name="unix_time_val" type="int" />
<description>
Converts the given Unix timestamp to an ISO 8601 time string (HH:MM:SS).
</description>
</method>
<method name="get_time_zone_from_system" qualifiers="const">
<return type="Dictionary" />
<description>
Returns the current time zone as a dictionary of keys: [code]bias[/code] and [code]name[/code]. The [code]bias[/code] value is the offset from UTC in minutes, since not all time zones are multiples of an hour from UTC.
</description>
</method>
<method name="get_unix_time_from_datetime_dict" qualifiers="const">
<return type="int" />
<argument index="0" name="datetime" type="Dictionary" />
<description>
Converts a dictionary of time values to a Unix timestamp.
The given dictionary can be populated with the following keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]hour[/code], [code]minute[/code], and [code]second[/code]. Any other entries (including [code]dst[/code]) are ignored.
If the dictionary is empty, [code]0[/code] is returned. If some keys are omitted, they default to the equivalent values for the Unix epoch timestamp 0 (1970-01-01 at 00:00:00).
You can pass the output from [method get_datetime_dict_from_unix_time] directly into this function and get the same as what was put in.
[b]Note:[/b] Unix timestamps are often in UTC. This method does not do any timezone conversion, so the timestamp will be in the same timezone as the given datetime dictionary.
</description>
</method>
<method name="get_unix_time_from_datetime_string" qualifiers="const">
<return type="int" />
<argument index="0" name="datetime" type="String" />
<description>
Converts the given ISO 8601 date and/or time string to a Unix timestamp. The string can contain a date only, a time only, or both.
[b]Note:[/b] Unix timestamps are often in UTC. This method does not do any timezone conversion, so the timestamp will be in the same timezone as the given datetime string.
</description>
</method>
<method name="get_unix_time_from_system" qualifiers="const">
<return type="float" />
<description>
Returns the current Unix timestamp in seconds based on the system time in UTC. This method is implemented by the operating system and always returns the time in UTC.
</description>
</method>
</methods>
<constants>
<constant name="MONTH_JANUARY" value="1" enum="Month">
The month of January, represented numerically as [code]01[/code].
</constant>
<constant name="MONTH_FEBRUARY" value="2" enum="Month">
The month of February, represented numerically as [code]02[/code].
</constant>
<constant name="MONTH_MARCH" value="3" enum="Month">
The month of March, represented numerically as [code]03[/code].
</constant>
<constant name="MONTH_APRIL" value="4" enum="Month">
The month of April, represented numerically as [code]04[/code].
</constant>
<constant name="MONTH_MAY" value="5" enum="Month">
The month of May, represented numerically as [code]05[/code].
</constant>
<constant name="MONTH_JUNE" value="6" enum="Month">
The month of June, represented numerically as [code]06[/code].
</constant>
<constant name="MONTH_JULY" value="7" enum="Month">
The month of July, represented numerically as [code]07[/code].
</constant>
<constant name="MONTH_AUGUST" value="8" enum="Month">
The month of August, represented numerically as [code]08[/code].
</constant>
<constant name="MONTH_SEPTEMBER" value="9" enum="Month">
The month of September, represented numerically as [code]09[/code].
</constant>
<constant name="MONTH_OCTOBER" value="10" enum="Month">
The month of October, represented numerically as [code]10[/code].
</constant>
<constant name="MONTH_NOVEMBER" value="11" enum="Month">
The month of November, represented numerically as [code]11[/code].
</constant>
<constant name="MONTH_DECEMBER" value="12" enum="Month">
The month of December, represented numerically as [code]12[/code].
</constant>
<constant name="WEEKDAY_SUNDAY" value="0" enum="Weekday">
The day of the week Sunday, represented numerically as [code]0[/code].
</constant>
<constant name="WEEKDAY_MONDAY" value="1" enum="Weekday">
The day of the week Monday, represented numerically as [code]1[/code].
</constant>
<constant name="WEEKDAY_TUESDAY" value="2" enum="Weekday">
The day of the week Tuesday, represented numerically as [code]2[/code].
</constant>
<constant name="WEEKDAY_WEDNESDAY" value="3" enum="Weekday">
The day of the week Wednesday, represented numerically as [code]3[/code].
</constant>
<constant name="WEEKDAY_THURSDAY" value="4" enum="Weekday">
The day of the week Thursday, represented numerically as [code]4[/code].
</constant>
<constant name="WEEKDAY_FRIDAY" value="5" enum="Weekday">
The day of the week Friday, represented numerically as [code]5[/code].
</constant>
<constant name="WEEKDAY_SATURDAY" value="6" enum="Weekday">
The day of the week Saturday, represented numerically as [code]6[/code].
</constant>
</constants>
</class>
|