Skip to content

Commit 0b5bac2

Browse files
committed
added tztime and tzdate
1 parent 3345031 commit 0b5bac2

File tree

6 files changed

+62
-6
lines changed

6 files changed

+62
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ seconds
125125
year
126126
month
127127
day
128+
tztime:<zone> lookup curr time in timezone. e.g. '$(tztime:America/Chicago)'
129+
tzdate:<zone> lookup curr date in timezone. e.g. '$(tzdate:CET)
128130
hostname system hostname
129131
arch system architecture
130132
os system os type

barmaid.lua

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SHELL_OKAY=0
1212
SHELL_CLOSED=1
1313
SHELL_CLS=2
1414

15-
version="6.2"
15+
version="6.3"
1616
settings={}
1717
lookup_counter=0
1818
lookup_values={}
@@ -1226,6 +1226,8 @@ print("seconds")
12261226
print("year")
12271227
print("month")
12281228
print("day")
1229+
print("tztime:<zone> time in timezone 'zone'")
1230+
print("tzdate:<zone> date in timezone 'zone'")
12291231
print("hostname system hostname")
12301232
print("arch system architecture")
12311233
print("os system os type")
@@ -2062,10 +2064,36 @@ function LookupTimes()
20622064
display_values.year=time.format("%Y")
20632065
display_values.month=time.format("%m")
20642066
display_values.day=time.format("%d")
2067+
LookupTimezones()
20652068
end
20662069

20672070

20682071

2072+
function LookupTimezones()
2073+
local toks, str
2074+
local parts={}
2075+
2076+
toks=strutil.TOKENIZER(settings.display, "$(|^(|:|)", "ms")
2077+
str=toks:next()
2078+
while str ~= nil
2079+
do
2080+
if str=="$(" or str=="^("
2081+
then
2082+
str=toks:next()
2083+
if str=="tztime" or str=="tzdate"
2084+
then
2085+
str=toks:next() --consume the ':'
2086+
str=toks:next()
2087+
display_values["tzdate:"..str]=time.format("%Y/%m:%d", str)
2088+
display_values["tztime:"..str]=time.format("%H:%M:%S", str)
2089+
end
2090+
end
2091+
str=toks:next()
2092+
end
2093+
2094+
return parts
2095+
end
2096+
20692097

20702098
-- these functions relate to loading modules that add features or otherwise change the behavior of barmaid
20712099

@@ -2165,7 +2193,7 @@ end
21652193
check_names={["time"]=1, ["date"]=1, ["day_name"]=1, ["day"]=1, ["month"]=1, ["month_name"]=1, ["year"]=1, ["hours"]=1, ["minutes"]=1, ["mins"]=1, ["seconds"]=1, ["secs"]=1}
21662194

21672195

2168-
if check_names[name] ~= nil
2196+
if check_names[name] ~= nil or string.sub(name, 1, 6) == "tztime" or string.sub(name, 1, 6) == "tzdate"
21692197
then
21702198
table.insert(lookups, LookupTimes)
21712199
end
@@ -2175,7 +2203,6 @@ then
21752203
table.insert(lookups, LookupBatteries)
21762204
end
21772205

2178-
21792206
if string.sub(name, 1,3) == "fs:"
21802207
then
21812208
table.insert(lookups, LookupPartitions)

common.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SHELL_OKAY=0
1212
SHELL_CLOSED=1
1313
SHELL_CLS=2
1414

15-
version="6.3"
15+
version="6.4"
1616
settings={}
1717
lookup_counter=0
1818
lookup_values={}

datetime.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,34 @@ function LookupTimes()
1111
display_values.year=time.format("%Y")
1212
display_values.month=time.format("%m")
1313
display_values.day=time.format("%d")
14+
LookupTimezones()
1415
end
1516

1617

1718

19+
function LookupTimezones()
20+
local toks, str
21+
local parts={}
22+
23+
toks=strutil.TOKENIZER(settings.display, "$(|^(|:|)", "ms")
24+
str=toks:next()
25+
while str ~= nil
26+
do
27+
if str=="$(" or str=="^("
28+
then
29+
str=toks:next()
30+
if str=="tztime" or str=="tzdate"
31+
then
32+
str=toks:next() --consume the ':'
33+
str=toks:next()
34+
display_values["tzdate:"..str]=time.format("%Y/%m:%d", str)
35+
display_values["tztime:"..str]=time.format("%H:%M:%S", str)
36+
end
37+
end
38+
str=toks:next()
39+
end
40+
41+
return parts
42+
end
43+
1844

help.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ print("seconds")
100100
print("year")
101101
print("month")
102102
print("day")
103+
print("tztime:<zone> time in timezone 'zone'")
104+
print("tzdate:<zone> date in timezone 'zone'")
103105
print("hostname system hostname")
104106
print("arch system architecture")
105107
print("os system os type")

main.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ end
6666
check_names={["time"]=1, ["date"]=1, ["day_name"]=1, ["day"]=1, ["month"]=1, ["month_name"]=1, ["year"]=1, ["hours"]=1, ["minutes"]=1, ["mins"]=1, ["seconds"]=1, ["secs"]=1}
6767

6868

69-
if check_names[name] ~= nil
69+
if check_names[name] ~= nil or string.sub(name, 1, 6) == "tztime" or string.sub(name, 1, 6) == "tzdate"
7070
then
7171
table.insert(lookups, LookupTimes)
7272
end
@@ -76,7 +76,6 @@ then
7676
table.insert(lookups, LookupBatteries)
7777
end
7878

79-
8079
if string.sub(name, 1,3) == "fs:"
8180
then
8281
table.insert(lookups, LookupPartitions)

0 commit comments

Comments
 (0)