summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rem.lua29
1 files changed, 23 insertions, 6 deletions
diff --git a/rem.lua b/rem.lua
index a696f83..ddee9a6 100644
--- a/rem.lua
+++ b/rem.lua
@@ -6,6 +6,8 @@
local inspect = require "ext.inspect"
+local iso8601dates = true --false --- write ISO 8601 dates
+
local pcall = pcall
local io = require "io"
@@ -155,8 +157,8 @@ local rem_of_vcalendars do
local parse_date_value = function (val)
local params = val.params
- local ptzid = get_param_value_1 (params, "TZID")
- local pdate = get_param_value_1 (params, "VALUE")
+ local ptzid = get_param_value_1 (params, "TZID")
+ local pdate = get_param_value_1 (params, "VALUE")
if pdate == nil or pdate == "DATE-TIME" then
return parse_date_value_DATE_TIME (val.value, ptzid)
@@ -169,20 +171,35 @@ local rem_of_vcalendars do
return nil
end
+ local fmt_date_jumble_loc = "%b %d %Y"
+ local fmt_date_iso8601_loc = "%F"
+ local fmt_date_time_jumble_loc = "%b %d %Y AT %H:%M"
+ local fmt_date_time_iso8601_loc = "%F AT %H:%M"
+
+ local fmt_date_jumble_utc = "!%b %d %Y"
+ local fmt_date_iso8601_utc = "!%F"
+ local fmt_date_time_jumble_utc = "!%b %d %Y AT %H:%M"
+ local fmt_date_time_iso8601_utc = "!%F AT %H:%M"
+
+ local fmt_date_loc = iso8601dates and fmt_date_iso8601_loc or fmt_date_jumble_loc
+ local fmt_date_utc = iso8601dates and fmt_date_iso8601_utc or fmt_date_jumble_utc
+ local fmt_date_time_loc = iso8601dates and fmt_date_time_iso8601_loc or fmt_date_time_jumble_loc
+ local fmt_date_time_utc = iso8601dates and fmt_date_time_iso8601_utc or fmt_date_time_jumble_utc
+
local rem_date_time = function (d, loctime)
if loctime == true then
- return osdate ("%b %d %Y AT %H:%M", d)
+ return osdate (fmt_date_time_loc, d)
end
- return osdate ("!%b %d %Y AT %H:%M", d)
+ return osdate (fmt_date_time_utc, d)
end
local rem_date = function (d, loctime)
if loctime == true then
- return osdate ("%b %d %Y", d)
+ return osdate (fmt_date_loc, d)
end
- return osdate ("!%b %d %Y", d)
+ return osdate (fmt_date_utc, d)
end
local rem_duration = function (dt)