X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/94c5a08ebdc03125f84e7fed814a1599c788a09e..bdbbf89c38126a71b17049469e8f976c571b9392:/examples/os_date.lua diff --git a/examples/os_date.lua b/examples/os_date.lua index deac08b..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 ) + 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