X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/073b4c8333742320533a197f553980cc2f626011..26599a049c52f4ccb71940f825d9d966a32ec2df:/examples/os_date.lua?ds=inline diff --git a/examples/os_date.lua b/examples/os_date.lua index 0164780..ad254ce 100644 --- a/examples/os_date.lua +++ b/examples/os_date.lua @@ -6,19 +6,19 @@ local gettime = require "luatz.gettime".gettime local new_from_timestamp = require "luatz.timetable".new_from_timestamp local get_tz = require "luatz.tzcache".get_tz -local function os_date ( format_string , timestamp ) +local function os_date(format_string, timestamp) format_string = format_string or "%c" - timestamp = timestamp or gettime ( ) - if format_string:sub ( 1 , 1 ) == "!" then -- UTC - format_string = format_string:sub ( 2 ) + timestamp = timestamp or gettime() + if format_string:sub(1, 1) == "!" then -- UTC + format_string = format_string:sub(2) else -- Localtime - timestamp = get_tz ( ):localise ( timestamp ) + timestamp = get_tz():localise(timestamp) end - local tt = new_from_timestamp ( timestamp ):normalise ( ) + local tt = new_from_timestamp(timestamp) if format_string == "*t" then return tt else - return tt:strftime ( format_string ) + return tt:strftime(format_string) end end