-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNAVFoundation.DateTimeUtils.h.axi
More file actions
374 lines (312 loc) · 11.7 KB
/
NAVFoundation.DateTimeUtils.h.axi
File metadata and controls
374 lines (312 loc) · 11.7 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
PROGRAM_NAME='NAVFoundation.DateTime.h'
/*
_ _ _ ___ __
| \ | | ___ _ __ __ _ __ _| |_ ___ / \ \ / /
| \| |/ _ \| '__/ _` |/ _` | __/ _ \ / _ \ \ / /
| |\ | (_) | | | (_| | (_| | || __// ___ \ V /
|_| \_|\___/|_| \__, |\__,_|\__\___/_/ \_\_/
|___/
MIT License
Copyright (c) 2010-2026 Norgate AV
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#IF_NOT_DEFINED __NAV_FOUNDATION_DATETIMEUTILS_H__
#DEFINE __NAV_FOUNDATION_DATETIMEUTILS_H__ 'NAVFoundation.DateTimeUtils.h'
DEFINE_CONSTANT
/**
* @constant NAV_DATETIME_SECONDS_IN_1_MINUTE
* @description Number of seconds in one minute
*/
constant long NAV_DATETIME_SECONDS_IN_1_MINUTE = 60
/**
* @constant NAV_DATETIME_SECONDS_IN_1_HOUR
* @description Number of seconds in one hour
*/
constant long NAV_DATETIME_SECONDS_IN_1_HOUR = 3600
/**
* @constant NAV_DATETIME_SECONDS_IN_1_DAY
* @description Number of seconds in one day
*/
constant long NAV_DATETIME_SECONDS_IN_1_DAY = 86400
/**
* @constant NAV_DATETIME_SECONDS_IN_1_WEEK
* @description Number of seconds in one week
*/
constant long NAV_DATETIME_SECONDS_IN_1_WEEK = 604800
/**
* @constant NAV_DATETIME_SECONDS_IN_1_MONTH_AVG
* @description Average number of seconds in one month (30.44 days)
*/
constant long NAV_DATETIME_SECONDS_IN_1_MONTH_AVG = 2629743 // 30.44 days
/**
* @constant NAV_DATETIME_SECONDS_IN_1_YEAR
* @description Number of seconds in one year (365 days)
*/
constant long NAV_DATETIME_SECONDS_IN_1_YEAR = 31536000 // 365 days
/**
* @constant NAV_DATETIME_SECONDS_IN_1_YEAR_AVG
* @description Average number of seconds in one year (365.24 days)
*/
constant long NAV_DATETIME_SECONDS_IN_1_YEAR_AVG = 31556926 // 365.24 days
/**
* @constant NAV_DATETIME_SECONDS_IN_1_LEAP_YEAR
* @description Number of seconds in one leap year (366 days)
*/
constant long NAV_DATETIME_SECONDS_IN_1_LEAP_YEAR = 31622400 // 366 days
/**
* @constant NAV_DATETIME_DAY_SUNDAY
* @description Day of week identifier for Sunday
*/
constant integer NAV_DATETIME_DAY_SUNDAY = 1
/**
* @constant NAV_DATETIME_DAY_MONDAY
* @description Day of week identifier for Monday
*/
constant integer NAV_DATETIME_DAY_MONDAY = 2
/**
* @constant NAV_DATETIME_DAY_TUESDAY
* @description Day of week identifier for Tuesday
*/
constant integer NAV_DATETIME_DAY_TUESDAY = 3
/**
* @constant NAV_DATETIME_DAY_WEDNESDAY
* @description Day of week identifier for Wednesday
*/
constant integer NAV_DATETIME_DAY_WEDNESDAY = 4
/**
* @constant NAV_DATETIME_DAY_THURSDAY
* @description Day of week identifier for Thursday
*/
constant integer NAV_DATETIME_DAY_THURSDAY = 5
/**
* @constant NAV_DATETIME_DAY_FRIDAY
* @description Day of week identifier for Friday
*/
constant integer NAV_DATETIME_DAY_FRIDAY = 6
/**
* @constant NAV_DATETIME_DAY_SATURDAY
* @description Day of week identifier for Saturday
*/
constant integer NAV_DATETIME_DAY_SATURDAY = 7
/**
* @constant NAV_DATETIME_MONTH_JANUARY
* @description Month identifier for January (0-based)
*/
constant integer NAV_DATETIME_MONTH_JANUARY = 0
/**
* @constant NAV_DATETIME_MONTH_FEBRUARY
* @description Month identifier for February (0-based)
*/
constant integer NAV_DATETIME_MONTH_FEBRUARY = 1
/**
* @constant NAV_DATETIME_MONTH_MARCH
* @description Month identifier for March (0-based)
*/
constant integer NAV_DATETIME_MONTH_MARCH = 2
/**
* @constant NAV_DATETIME_MONTH_APRIL
* @description Month identifier for April (0-based)
*/
constant integer NAV_DATETIME_MONTH_APRIL = 3
/**
* @constant NAV_DATETIME_MONTH_MAY
* @description Month identifier for May (0-based)
*/
constant integer NAV_DATETIME_MONTH_MAY = 4
/**
* @constant NAV_DATETIME_MONTH_JUNE
* @description Month identifier for June (0-based)
*/
constant integer NAV_DATETIME_MONTH_JUNE = 5
/**
* @constant NAV_DATETIME_MONTH_JULY
* @description Month identifier for July (0-based)
*/
constant integer NAV_DATETIME_MONTH_JULY = 6
/**
* @constant NAV_DATETIME_MONTH_AUGUST
* @description Month identifier for August (0-based)
*/
constant integer NAV_DATETIME_MONTH_AUGUST = 7
/**
* @constant NAV_DATETIME_MONTH_SEPTEMBER
* @description Month identifier for September (0-based)
*/
constant integer NAV_DATETIME_MONTH_SEPTEMBER = 8
/**
* @constant NAV_DATETIME_MONTH_OCTOBER
* @description Month identifier for October (0-based)
*/
constant integer NAV_DATETIME_MONTH_OCTOBER = 9
/**
* @constant NAV_DATETIME_MONTH_NOVEMBER
* @description Month identifier for November (0-based)
*/
constant integer NAV_DATETIME_MONTH_NOVEMBER = 10
/**
* @constant NAV_DATETIME_MONTH_DECEMBER
* @description Month identifier for December (0-based)
*/
constant integer NAV_DATETIME_MONTH_DECEMBER = 11
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_UTC
* @description Format timestamp as "MM/DD/YYYY @ HH:MMam/pm"
* @example 11/23/2023 @ 09:30pm
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_UTC = 1
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_ATOM
* @description Format timestamp using Atom standard
* @example 2023-11-23T21:30:00+00:00
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_ATOM = 2
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_COOKIE
* @description Format timestamp as used in HTTP cookies
* @example Friday, 23-Nov-2023 21:30:00 GMT
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_COOKIE = 3
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_ISO8601
* @description Format timestamp using ISO 8601 standard
* @example 2023-11-23T21:30:00+0000
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_ISO8601 = 4
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_RFC822
* @description Format timestamp according to RFC 822
* @example Thu, 23 Nov 23 21:30:00 +0000
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_RFC822 = 5
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_RFC850
* @description Format timestamp according to RFC 850
* @example Thursday, 23-Nov-23 21:30:00 GMT
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_RFC850 = 6
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_RFC1036
* @description Format timestamp according to RFC 1036
* @example Thu, 23 Nov 23 21:30:00 +0000
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_RFC1036 = 7
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_RFC1123
* @description Format timestamp according to RFC 1123
* @example Thu, 23 Nov 2023 21:30:00 +0000
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_RFC1123 = 8
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_RFC7231
* @description Format timestamp according to RFC 7231
* @example Thu, 23 Nov 2023 21:30:00 GMT
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_RFC7231 = 9
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_RFC2822
* @description Format timestamp according to RFC 2822
* @example Thu, 23 Nov 2023 21:30:00 +0000
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_RFC2822 = 10
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_RFC3339
* @description Format timestamp according to RFC 3339
* @example 2023-11-23T21:30:00+00:00
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_RFC3339 = 11
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_RFC3339EXT
* @description Format timestamp according to RFC 3339 with milliseconds
* @example 2023-11-23T21:30:00.000+00:00
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_RFC3339EXT = 12
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_RSS
* @description Format timestamp as used in RSS feeds
* @example Thu, 23 Nov 2023 21:30:00 +0000
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_RSS = 13
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_W3C
* @description Format timestamp as defined by W3C standards
* @example 2023-11-23T21:30:00+00:00
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_W3C = 14
/**
* @constant NAV_DATETIME_TIMESTAMP_FORMAT_DEFAULT
* @description Default timestamp format (ISO 8601)
* @example 2023-11-23T21:30:00+0000
*/
constant integer NAV_DATETIME_TIMESTAMP_FORMAT_DEFAULT = NAV_DATETIME_TIMESTAMP_FORMAT_ISO8601
DEFINE_TYPE
/**
* @struct _NAVTimespec
* @description Time specification structure containing date and time components.
* Similar to the C standard library's struct tm.
*
* @property {integer} Year - Years since 1900
* @property {integer} Month - Months since January (0-11)
* @property {integer} MonthDay - Day of the month (1-31)
* @property {integer} Hour - Hours since midnight (0-23)
* @property {integer} Minute - Minutes after the hour (0-59)
* @property {integer} Seconds - Seconds after the minute (0-59)
* @property {integer} WeekDay - Days since Sunday (0-6)
* @property {integer} YearDay - Days since January 1 (0-365)
* @property {char} IsLeapYear - Leap year flag (true if leap year, false otherwise)
* @property {char} IsDst - Daylight Saving Time flag (positive if DST in effect, zero if not, negative if unknown)
* @property {sinteger} GmtOffset - GMT offset in minutes (positive for east of UTC, negative for west)
* @property {char[]} Timezone - Timezone string (e.g., "UTC+01:00")
*
* @example
* stack_var _NAVTimespec timespec
* NAVDateTimeGetTimespecNow(timespec)
* // timespec now contains the current date and time information
*/
struct _NAVTimespec {
integer Year // Years since 1900
integer Month // Months since January - [0,11]
integer MonthDay // Day of the month - [1,31]
integer Hour // Hours since midnight - [0,23]
integer Minute // Minutes after the hour - [0,59]
integer Seconds // Seconds after the minute - [0,59]
integer WeekDay // Days since Sunday - [0,6]
integer YearDay // Days since January 1 - [0,365]
char IsLeapYear
char IsDst // Daylight Saving Time flag. The value is positive if DST is in effect, zero if not and negative if no information is available
sinteger GmtOffset // GMT offset in minutes (positive for east of UTC, negative for west of UTC)
char TimeZone[15]
}
/**
* @struct _NAVTimeServer
* @description Structure representing an NTP time server configuration.
*
* @property {char[15]} Ip - IP address of the time server
* @property {char[255]} Hostname - Hostname of the time server
* @property {char[255]} Description - Human readable description of the time server
*
* @example
* stack_var _NAVTimeServer customServer
* customServer.Ip = '132.163.97.2'
* customServer.Hostname = 'time-a.nist.gov'
* customServer.Description = 'NIST Internet Time Service'
*/
struct _NAVTimeServer {
char Ip[15]
char Hostname[255]
char Description[255]
}
#END_IF // __NAV_FOUNDATION_DATETIME_H__