Skip to content

Commit

Permalink
added tztime and tzdate
Browse files Browse the repository at this point in the history
  • Loading branch information
ColumPaget committed Feb 13, 2023
1 parent 3345031 commit 0b5bac2
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ seconds
year
month
day
tztime:<zone> lookup curr time in timezone. e.g. '$(tztime:America/Chicago)'
tzdate:<zone> lookup curr date in timezone. e.g. '$(tzdate:CET)
hostname system hostname
arch system architecture
os system os type
Expand Down
33 changes: 30 additions & 3 deletions barmaid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SHELL_OKAY=0
SHELL_CLOSED=1
SHELL_CLS=2

version="6.2"
version="6.3"
settings={}
lookup_counter=0
lookup_values={}
Expand Down Expand Up @@ -1226,6 +1226,8 @@ print("seconds")
print("year")
print("month")
print("day")
print("tztime:<zone> time in timezone 'zone'")
print("tzdate:<zone> date in timezone 'zone'")
print("hostname system hostname")
print("arch system architecture")
print("os system os type")
Expand Down Expand Up @@ -2062,10 +2064,36 @@ function LookupTimes()
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


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

Expand Down Expand Up @@ -2165,7 +2193,7 @@ end
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}


if check_names[name] ~= nil
if check_names[name] ~= nil or string.sub(name, 1, 6) == "tztime" or string.sub(name, 1, 6) == "tzdate"
then
table.insert(lookups, LookupTimes)
end
Expand All @@ -2175,7 +2203,6 @@ then
table.insert(lookups, LookupBatteries)
end


if string.sub(name, 1,3) == "fs:"
then
table.insert(lookups, LookupPartitions)
Expand Down
2 changes: 1 addition & 1 deletion common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SHELL_OKAY=0
SHELL_CLOSED=1
SHELL_CLS=2

version="6.3"
version="6.4"
settings={}
lookup_counter=0
lookup_values={}
Expand Down
26 changes: 26 additions & 0 deletions datetime.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,34 @@ function LookupTimes()
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


2 changes: 2 additions & 0 deletions help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ print("seconds")
print("year")
print("month")
print("day")
print("tztime:<zone> time in timezone 'zone'")
print("tzdate:<zone> date in timezone 'zone'")
print("hostname system hostname")
print("arch system architecture")
print("os system os type")
Expand Down
3 changes: 1 addition & 2 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ end
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}


if check_names[name] ~= nil
if check_names[name] ~= nil or string.sub(name, 1, 6) == "tztime" or string.sub(name, 1, 6) == "tzdate"
then
table.insert(lookups, LookupTimes)
end
Expand All @@ -76,7 +76,6 @@ then
table.insert(lookups, LookupBatteries)
end


if string.sub(name, 1,3) == "fs:"
then
table.insert(lookups, LookupPartitions)
Expand Down

0 comments on commit 0b5bac2

Please sign in to comment.