X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/073b4c8333742320533a197f553980cc2f626011..79d2a9cf417c3eca2d94dac7a814a0d26fb96b68:/examples/os_date.lua 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