-
Notifications
You must be signed in to change notification settings - Fork 11
/
os_time.lua
47 lines (38 loc) · 1.01 KB
/
os_time.lua
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
if istable(os.time) then return end
local old = os.time
local time = {}
time.second = 1
time.sec = time.second
time.minute = time.second * 60
time.min = time.minute
time.hour = time.minute * 60
time.day = time.hour * 24
time.week = time.day * 7
time.month = time.day * 30
time.year = time.day * 365
time.epoh = os.time({
year = 1970,
month = 1,
day = 1,
hour = 0
})
local cur = {}
cur.wday = function() return os.date("*t").wday end
cur.yday = function() return os.date("*t").yday end
cur.sec = function() return os.date("*t").sec end
cur.min = function() return os.date("*t").min end
cur.hour = function() return os.date("*t").hour end
cur.day = function() return os.date("*t").day end
cur.month = function() return os.date("*t").month end
cur.year = function() return os.date("*t").year end
time.cur = setmetatable(cur, {
__call = function(_, dateData)
return old(dateData)
end
})
time.old = old
os.time = setmetatable(time, {
__call = function(_, dateData)
return old(dateData)
end
})