summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2018-07-06 15:03:42 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2018-09-08 16:12:35 +0200
commit76a4936f065ef0f84ff61c74c8f5c800ca019011 (patch)
tree12acbd3ccc0d978105b86ea0ce0ae2bf5fe423e5
parent9f418d6206e30b67b6fef9b916fd228b5228b5ed (diff)
downloadcaldr-76a4936f065ef0f84ff61c74c8f5c800ca019011.tar.gz
rem: distinguish between dates with day and minute granularity
-rw-r--r--rem.lua29
1 files changed, 19 insertions, 10 deletions
diff --git a/rem.lua b/rem.lua
index 3dd1aeb..a696f83 100644
--- a/rem.lua
+++ b/rem.lua
@@ -169,7 +169,7 @@ local rem_of_vcalendars do
return nil
end
- local rem_date = function (d, loctime)
+ local rem_date_time = function (d, loctime)
if loctime == true then
return osdate ("%b %d %Y AT %H:%M", d)
end
@@ -177,6 +177,14 @@ local rem_of_vcalendars do
return osdate ("!%b %d %Y AT %H:%M", d)
end
+ local rem_date = function (d, loctime)
+ if loctime == true then
+ return osdate ("%b %d %Y", d)
+ end
+
+ return osdate ("!%b %d %Y", d)
+ end
+
local rem_duration = function (dt)
--[[-- remind(1): Note that duration is specified in hours and minutes. --]]--
@@ -196,27 +204,28 @@ local rem_of_vcalendars do
return stringformat ("%0.2d:%s", dt, ret)
end
- local repeat_of_duration = function (te)
+ local repeat_of_duration = function (t0, te)
+ local from = rem_date (t0)
local till = rem_date (te)
- return stringformat ("*1 UNTIL %s", till)
+ return stringformat ("%s *1 UNTIL %s", from, till)
end
local rem_date_duration = function (t0, te, loctime)
local dt = te - t0
- local s_t0 = rem_date (t0, loctime)
if dt == 0 or dt == time_f_day then
- return s_t0
+ --- no duration or exactly 1d β†’ no β€œat” clause
+ return rem_date (t0, loctime)
end
- if dt > time_f_day then --- needs repeat claus
- local rep = repeat_of_duration (te)
-
- return stringformat ("%s %s", s_t0, rep)
+ if dt > time_f_day then
+ --- duration of multiple days β†’ needs repeat clause
+ return repeat_of_duration (t0, te)
end
+ local s_t0 = rem_date_time (t0, loctime)
local s_dt = rem_duration (dt)
return stringformat ("%s DURATION %s", s_t0, s_dt)
@@ -228,7 +237,7 @@ local rem_of_vcalendars do
if t0 ~= nil then
if te ~= nil then return rem_date_duration (t0, te, loctime) end
- return rem_date (t0, loctime)
+ return rem_date_time (t0, loctime)
end
return nil