X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/85c40964551cb74c3d6ef6bf61a12fd79013389b..cdaad9ec35371fcfc3b398b7302f1e8fe313b4f6:/luatz/strftime.lua?ds=sidebyside diff --git a/luatz/strftime.lua b/luatz/strftime.lua index 0f6a26f..a65a706 100644 --- a/luatz/strftime.lua +++ b/luatz/strftime.lua @@ -8,7 +8,8 @@ local c_locale = { abday = { "Sun" , "Mon" , "Tue" , "Wed" , "Thu" , "Fri" , "Sat" } ; day = { "Sunday" , "Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday" , "Saturday" } ; abmon = { "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec" } ; - mon = { "January" , "February" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December" } ; + mon = { "January" , "February" , "March" , "April" , "May" , "June" , + "July" , "August" , "September" , "October" , "November" , "December" } ; am_pm = { "AM" , "PM" } ; } @@ -24,7 +25,7 @@ end local iso_8601_week do -- Years that have 53 weeks according to ISO-8601 local long_years = { } - for i, v in ipairs { + for _, v in ipairs { 4, 9, 15, 20, 26, 32, 37, 43, 48, 54, 60, 65, 71, 76, 82, 88, 93, 99, 105, 111, 116, 122, 128, 133, 139, 144, 150, 156, 161, 167, 172, 178, 184, 189, 195, 201, 207, 212, 218, 224, 229, 235, 240, 246, 252, @@ -117,7 +118,7 @@ function t:M ( ) return "%02d" , self.min end -- New-line character ('\n') -function t:n ( ) +function t:n ( ) -- luacheck: ignore 212 return "\n" end function t:p ( locale ) @@ -140,7 +141,7 @@ function t:S ( ) return "%02d" , self.sec end -- Horizontal-tab character ('\t') -function t:t ( ) +function t:t ( ) -- luacheck: ignore 212 return "\t" end -- ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S @@ -176,14 +177,14 @@ function t:Y ( ) return "%d" , self.year end -- TODO timezones -function t:z ( ) +function t:z ( ) -- luacheck: ignore 212 return "+0000" end -function t:Z ( ) +function t:Z ( ) -- luacheck: ignore 212 return "GMT" end -- A literal '%' character. -t["%"] = function ( self ) +t["%"] = function ( self ) -- luacheck: ignore 212 return "%%" end @@ -198,6 +199,12 @@ local function strftime ( format_string , timetable ) end ) ) end +local function asctime ( timetable ) + -- Equivalent to the format string "%c\n" + return strformat ( t.c ( timetable , c_locale ) ) .. "\n" +end + return { strftime = strftime ; + asctime = asctime ; }