-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatetime.lua
44 lines (36 loc) · 1023 Bytes
/
datetime.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
-- functions related to lookups of date and time
function LookupTimes()
display_values.time=time.format("%H:%M:%S")
display_values.date=time.format("%Y/%m/%d")
display_values.day_name=time.format("%a")
display_values.month_name=time.format("%b")
display_values.hour=time.format("%H")
display_values.minutes=time.format("%M")
display_values.seconds=time.format("%S")
display_values.year=time.format("%Y")
display_values.month=time.format("%m")
display_values.day=time.format("%d")
LookupTimezones()
end
function LookupTimezones()
local toks, str
local parts={}
toks=strutil.TOKENIZER(settings.display, "$(|^(|:|)", "ms")
str=toks:next()
while str ~= nil
do
if str=="$(" or str=="^("
then
str=toks:next()
if str=="tztime" or str=="tzdate"
then
str=toks:next() --consume the ':'
str=toks:next()
display_values["tzdate:"..str]=time.format("%Y/%m:%d", str)
display_values["tztime:"..str]=time.format("%H:%M:%S", str)
end
end
str=toks:next()
end
return parts
end