@quenty/time 2.4.2 → 2.4.3-canary.92429ac.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +2 -2
- package/src/Shared/Time.lua +148 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.4.3-canary.92429ac.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/time@2.4.2...@quenty/time@2.4.3-canary.92429ac.0) (2025-05-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/time
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [2.4.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/time@2.4.0...@quenty/time@2.4.2) (2025-04-07)
|
|
7
15
|
|
|
8
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/time",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3-canary.92429ac.0",
|
|
4
4
|
"description": "Library handles time based parsing / operations. Untested. Based off of PHP's time system. Note: This library is out of date, and does not necessarily work. I recommend using os.time()",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "92429acbf2365d8445bdbe618d38e9008c8a99f6"
|
|
31
31
|
}
|
package/src/Shared/Time.lua
CHANGED
|
@@ -48,30 +48,65 @@ function Time.getDaysMonthTable(year: number): { [number]: number }
|
|
|
48
48
|
return copy
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
--[=[
|
|
52
|
+
Returns the second of the given time.
|
|
53
|
+
@param currentTime number
|
|
54
|
+
@return number
|
|
55
|
+
]=]
|
|
51
56
|
function Time.getSecond(currentTime: number): number
|
|
52
57
|
return math.floor(currentTime % 60)
|
|
53
58
|
end
|
|
54
59
|
|
|
60
|
+
--[=[
|
|
61
|
+
Returns the minute of the given time.
|
|
62
|
+
@param currentTime number
|
|
63
|
+
@return number
|
|
64
|
+
]=]
|
|
55
65
|
function Time.getMinute(currentTime: number): number
|
|
56
66
|
return math.floor(currentTime / 60 % 60)
|
|
57
67
|
end
|
|
58
68
|
|
|
69
|
+
--[=[
|
|
70
|
+
Returns the hour of the given time in 24-hour format.
|
|
71
|
+
@param currentTime number
|
|
72
|
+
@return number
|
|
73
|
+
]=]
|
|
59
74
|
function Time.getHour(currentTime: number): number
|
|
60
75
|
return math.floor(currentTime / 3600 % 24)
|
|
61
76
|
end
|
|
62
77
|
|
|
78
|
+
--[=[
|
|
79
|
+
Returns the day of the year for the given time.
|
|
80
|
+
@param currentTime number
|
|
81
|
+
@return number
|
|
82
|
+
]=]
|
|
63
83
|
function Time.getDay(currentTime: number): number
|
|
64
84
|
return math.ceil(currentTime / 60 / 60 / 24 % 365.25)
|
|
65
85
|
end
|
|
66
86
|
|
|
87
|
+
--[=[
|
|
88
|
+
Returns the year for the given time.
|
|
89
|
+
@param currentTime number
|
|
90
|
+
@return number
|
|
91
|
+
]=]
|
|
67
92
|
function Time.getYear(currentTime: number): number
|
|
68
93
|
return math.floor(currentTime / 60 / 60 / 24 / 365.25 + 1970)
|
|
69
94
|
end
|
|
70
95
|
|
|
96
|
+
--[=[
|
|
97
|
+
Returns the last two digits of the year for the given time.
|
|
98
|
+
@param currentTime number
|
|
99
|
+
@return number
|
|
100
|
+
]=]
|
|
71
101
|
function Time.getYearShort(currentTime: number): number
|
|
72
102
|
return Time.getYear(currentTime) % 100
|
|
73
103
|
end
|
|
74
104
|
|
|
105
|
+
--[=[
|
|
106
|
+
Returns the last two digits of the year formatted as a string.
|
|
107
|
+
@param currentTime number
|
|
108
|
+
@return string
|
|
109
|
+
]=]
|
|
75
110
|
function Time.getYearShortFormatted(currentTime: number): string
|
|
76
111
|
local shortYear = Time.getYearShort(currentTime)
|
|
77
112
|
if shortYear < 10 then
|
|
@@ -80,6 +115,11 @@ function Time.getYearShortFormatted(currentTime: number): string
|
|
|
80
115
|
return shortYear
|
|
81
116
|
end
|
|
82
117
|
|
|
118
|
+
--[=[
|
|
119
|
+
Returns the month of the given time.
|
|
120
|
+
@param currentTime number
|
|
121
|
+
@return number?
|
|
122
|
+
]=]
|
|
83
123
|
function Time.getMonth(currentTime: number): number?
|
|
84
124
|
local year = Time.getYear(currentTime)
|
|
85
125
|
local day = Time.getDay(currentTime)
|
|
@@ -97,6 +137,11 @@ function Time.getMonth(currentTime: number): number?
|
|
|
97
137
|
return nil
|
|
98
138
|
end
|
|
99
139
|
|
|
140
|
+
--[=[
|
|
141
|
+
Returns the month formatted as a two-digit string.
|
|
142
|
+
@param currentTime number
|
|
143
|
+
@return string
|
|
144
|
+
]=]
|
|
100
145
|
function Time.getFormattedMonth(currentTime: number): string
|
|
101
146
|
local month = Time.getMonth(currentTime)
|
|
102
147
|
if month < 10 then
|
|
@@ -106,6 +151,11 @@ function Time.getFormattedMonth(currentTime: number): string
|
|
|
106
151
|
return month
|
|
107
152
|
end
|
|
108
153
|
|
|
154
|
+
--[=[
|
|
155
|
+
Returns the day of the month for the given time.
|
|
156
|
+
@param currentTime number
|
|
157
|
+
@return number?
|
|
158
|
+
]=]
|
|
109
159
|
function Time.getDayOfTheMonth(currentTime: number): number?
|
|
110
160
|
local year = Time.getYear(currentTime)
|
|
111
161
|
local day = Time.getDay(currentTime)
|
|
@@ -123,6 +173,11 @@ function Time.getDayOfTheMonth(currentTime: number): number?
|
|
|
123
173
|
return nil
|
|
124
174
|
end
|
|
125
175
|
|
|
176
|
+
--[=[
|
|
177
|
+
Returns the day of the month formatted as a two-digit string.
|
|
178
|
+
@param currentTime number
|
|
179
|
+
@return string
|
|
180
|
+
]=]
|
|
126
181
|
function Time.getFormattedDayOfTheMonth(currentTime: number): string
|
|
127
182
|
local dayOfTheMonth = Time.getDayOfTheMonth(currentTime)
|
|
128
183
|
|
|
@@ -133,6 +188,11 @@ function Time.getFormattedDayOfTheMonth(currentTime: number): string
|
|
|
133
188
|
return dayOfTheMonth
|
|
134
189
|
end
|
|
135
190
|
|
|
191
|
+
--[=[
|
|
192
|
+
Returns the full name of the month for the given time.
|
|
193
|
+
@param currentTime number
|
|
194
|
+
@return string
|
|
195
|
+
]=]
|
|
136
196
|
function Time.getMonthName(currentTime: number): string
|
|
137
197
|
local month = Time.getMonth(currentTime)
|
|
138
198
|
if month == nil then
|
|
@@ -142,6 +202,11 @@ function Time.getMonthName(currentTime: number): string
|
|
|
142
202
|
return MONTH_NAMES[month]
|
|
143
203
|
end
|
|
144
204
|
|
|
205
|
+
--[=[
|
|
206
|
+
Returns the abbreviated name of the month for the given time.
|
|
207
|
+
@param currentTime number
|
|
208
|
+
@return string
|
|
209
|
+
]=]
|
|
145
210
|
function Time.getMonthNameShort(currentTime: number): string
|
|
146
211
|
local month = Time.getMonth(currentTime)
|
|
147
212
|
if month == nil then
|
|
@@ -151,6 +216,11 @@ function Time.getMonthNameShort(currentTime: number): string
|
|
|
151
216
|
return MONTH_NAMES_SHORT[month]
|
|
152
217
|
end
|
|
153
218
|
|
|
219
|
+
--[=[
|
|
220
|
+
Calculates the Julian date for the given time.
|
|
221
|
+
@param currentTime number
|
|
222
|
+
@return number
|
|
223
|
+
]=]
|
|
154
224
|
function Time.getJulianDate(currentTime: number)
|
|
155
225
|
local month = Time.getMonth(currentTime)
|
|
156
226
|
local year = Time.getYear(currentTime)
|
|
@@ -173,21 +243,37 @@ function Time.getJulianDate(currentTime: number)
|
|
|
173
243
|
return julianDay
|
|
174
244
|
end
|
|
175
245
|
|
|
246
|
+
--[=[
|
|
247
|
+
Returns the day of the week as a number (0-6) for the given time.
|
|
248
|
+
@param currentTime number
|
|
249
|
+
@return number
|
|
250
|
+
]=]
|
|
176
251
|
function Time.getDayOfTheWeek(currentTime: number): number
|
|
177
252
|
return math.floor(Time.getJulianDate(currentTime)) % 7
|
|
178
253
|
end
|
|
179
254
|
|
|
255
|
+
--[=[
|
|
256
|
+
Returns the full name of the day of the week for the given time.
|
|
257
|
+
@param currentTime number
|
|
258
|
+
@return string
|
|
259
|
+
]=]
|
|
180
260
|
function Time.getDayOfTheWeekName(currentTime: number): string
|
|
181
261
|
return DAYS_OF_WEEK[Time.getDayOfTheWeek(currentTime)]
|
|
182
262
|
end
|
|
183
263
|
|
|
264
|
+
--[=[
|
|
265
|
+
Returns the abbreviated name of the day of the week for the given time.
|
|
266
|
+
@param currentTime number
|
|
267
|
+
@return string
|
|
268
|
+
]=]
|
|
184
269
|
function Time.getDayOfTheWeekNameShort(currentTime: number): string
|
|
185
270
|
return DAYS_OF_WEEK_SHORT[Time.getDayOfTheWeek(currentTime)]
|
|
186
271
|
end
|
|
187
272
|
|
|
188
273
|
--[=[
|
|
274
|
+
Returns the ordinal suffix (e.g., "st", "nd", "rd", "th") for a given number.
|
|
189
275
|
@param number number
|
|
190
|
-
@return string
|
|
276
|
+
@return string
|
|
191
277
|
]=]
|
|
192
278
|
function Time.getOrdinalOfNumber(number: number): string
|
|
193
279
|
local tenRemainder = number % 10
|
|
@@ -208,6 +294,11 @@ function Time.getOrdinalOfNumber(number: number): string
|
|
|
208
294
|
end
|
|
209
295
|
end
|
|
210
296
|
|
|
297
|
+
--[=[
|
|
298
|
+
Returns the ordinal suffix for the day of the month for the given time.
|
|
299
|
+
@param currentTime number
|
|
300
|
+
@return string?
|
|
301
|
+
]=]
|
|
211
302
|
function Time.getDayOfTheMonthOrdinal(currentTime: number): string?
|
|
212
303
|
local dayOfMonth = Time.getDayOfTheMonth(currentTime)
|
|
213
304
|
if dayOfMonth == nil then
|
|
@@ -217,6 +308,11 @@ function Time.getDayOfTheMonthOrdinal(currentTime: number): string?
|
|
|
217
308
|
return Time.getOrdinalOfNumber(dayOfMonth)
|
|
218
309
|
end
|
|
219
310
|
|
|
311
|
+
--[=[
|
|
312
|
+
Returns the second formatted as a two-digit string.
|
|
313
|
+
@param currentTime number
|
|
314
|
+
@return string
|
|
315
|
+
]=]
|
|
220
316
|
function Time.getFormattedSecond(currentTime: number): string
|
|
221
317
|
local currentSecond = Time.getSecond(currentTime)
|
|
222
318
|
if currentSecond < 10 then
|
|
@@ -225,6 +321,11 @@ function Time.getFormattedSecond(currentTime: number): string
|
|
|
225
321
|
return currentSecond
|
|
226
322
|
end
|
|
227
323
|
|
|
324
|
+
--[=[
|
|
325
|
+
Returns the minute formatted as a two-digit string.
|
|
326
|
+
@param currentTime number
|
|
327
|
+
@return string
|
|
328
|
+
]=]
|
|
228
329
|
function Time.getFormattedMinute(currentTime: number): string
|
|
229
330
|
local currentMinute = Time.getMinute(currentTime)
|
|
230
331
|
if currentMinute < 10 then
|
|
@@ -233,6 +334,11 @@ function Time.getFormattedMinute(currentTime: number): string
|
|
|
233
334
|
return currentMinute
|
|
234
335
|
end
|
|
235
336
|
|
|
337
|
+
--[=[
|
|
338
|
+
Returns the hour in 12-hour format.
|
|
339
|
+
@param currentTime number
|
|
340
|
+
@return number
|
|
341
|
+
]=]
|
|
236
342
|
function Time.getRegularHour(currentTime: number): number
|
|
237
343
|
local hour = Time.getHour(currentTime)
|
|
238
344
|
if hour > 12 then
|
|
@@ -241,6 +347,11 @@ function Time.getRegularHour(currentTime: number): number
|
|
|
241
347
|
return hour
|
|
242
348
|
end
|
|
243
349
|
|
|
350
|
+
--[=[
|
|
351
|
+
Returns the hour formatted as a two-digit string in 24-hour format.
|
|
352
|
+
@param currentTime number
|
|
353
|
+
@return string
|
|
354
|
+
]=]
|
|
244
355
|
function Time.getHourFormatted(currentTime): string
|
|
245
356
|
local hour = Time.getHour(currentTime)
|
|
246
357
|
if hour < 10 then
|
|
@@ -249,6 +360,11 @@ function Time.getHourFormatted(currentTime): string
|
|
|
249
360
|
return hour
|
|
250
361
|
end
|
|
251
362
|
|
|
363
|
+
--[=[
|
|
364
|
+
Returns the hour formatted as a two-digit string in 12-hour format.
|
|
365
|
+
@param currentTime number
|
|
366
|
+
@return string
|
|
367
|
+
]=]
|
|
252
368
|
function Time.getRegularHourFormatted(currentTime: number): string
|
|
253
369
|
local hour = Time.getRegularHour(currentTime)
|
|
254
370
|
if hour < 10 then
|
|
@@ -257,6 +373,11 @@ function Time.getRegularHourFormatted(currentTime: number): string
|
|
|
257
373
|
return hour
|
|
258
374
|
end
|
|
259
375
|
|
|
376
|
+
--[=[
|
|
377
|
+
Returns "am" or "pm" based on the given time.
|
|
378
|
+
@param currentTime number
|
|
379
|
+
@return "am" | "pm"
|
|
380
|
+
]=]
|
|
260
381
|
function Time.getamOrpm(currentTime: number): "am" | "pm"
|
|
261
382
|
local hour = Time.getHour(currentTime)
|
|
262
383
|
|
|
@@ -267,6 +388,11 @@ function Time.getamOrpm(currentTime: number): "am" | "pm"
|
|
|
267
388
|
end
|
|
268
389
|
end
|
|
269
390
|
|
|
391
|
+
--[=[
|
|
392
|
+
Returns "AM" or "PM" based on the given time.
|
|
393
|
+
@param currentTime number
|
|
394
|
+
@return "AM" | "PM"
|
|
395
|
+
]=]
|
|
270
396
|
function Time.getAMorPM(currentTime: number): "AM" | "PM"
|
|
271
397
|
local hour = Time.getHour(currentTime)
|
|
272
398
|
|
|
@@ -277,6 +403,11 @@ function Time.getAMorPM(currentTime: number): "AM" | "PM"
|
|
|
277
403
|
end
|
|
278
404
|
end
|
|
279
405
|
|
|
406
|
+
--[=[
|
|
407
|
+
Reports the time in 24-hour format as a two-digit string.
|
|
408
|
+
@param currentTime number
|
|
409
|
+
@return string
|
|
410
|
+
]=]
|
|
280
411
|
function Time.getMilitaryHour(currentTime: number): string
|
|
281
412
|
local hour = Time.getHour(currentTime)
|
|
282
413
|
if hour < 10 then
|
|
@@ -285,6 +416,11 @@ function Time.getMilitaryHour(currentTime: number): string
|
|
|
285
416
|
return hour
|
|
286
417
|
end
|
|
287
418
|
|
|
419
|
+
--[=[
|
|
420
|
+
Determines if the year of the given time is a leap year.
|
|
421
|
+
@param currentTime number
|
|
422
|
+
@return boolean
|
|
423
|
+
]=]
|
|
288
424
|
function Time.isLeapYear(currentTime: number): boolean
|
|
289
425
|
local year = Time.getYear(currentTime)
|
|
290
426
|
if year % 4 == 0 and (year % 100 ~= 0 or year % 400 == 0) then
|
|
@@ -294,6 +430,11 @@ function Time.isLeapYear(currentTime: number): boolean
|
|
|
294
430
|
end
|
|
295
431
|
end
|
|
296
432
|
|
|
433
|
+
--[=[
|
|
434
|
+
Returns the number of days in the month for the given time.
|
|
435
|
+
@param currentTime number
|
|
436
|
+
@return number
|
|
437
|
+
]=]
|
|
297
438
|
function Time.getDaysInMonth(currentTime: number): number
|
|
298
439
|
local month = Time.getMonth(currentTime)
|
|
299
440
|
local year = Time.getYear(currentTime)
|
|
@@ -355,6 +496,12 @@ do
|
|
|
355
496
|
matchString ..= "]"
|
|
356
497
|
end
|
|
357
498
|
|
|
499
|
+
--[=[
|
|
500
|
+
Formats the given time based on the provided format string.
|
|
501
|
+
@param format string
|
|
502
|
+
@param currentTime number
|
|
503
|
+
@return string
|
|
504
|
+
]=]
|
|
358
505
|
function Time.getFormattedTime(format: string, currentTime: number)
|
|
359
506
|
currentTime = currentTime or tick()
|
|
360
507
|
|