summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2018-07-06 14:54:54 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2018-09-08 16:12:34 +0200
commit9f418d6206e30b67b6fef9b916fd228b5228b5ed (patch)
tree0d81f0e9845d98c9e215419d6df313628f68a33f
parent7ee925a9b4a01b3e5e8cd67fcc98b92ddf691f2c (diff)
downloadcaldr-9f418d6206e30b67b6fef9b916fd228b5228b5ed.tar.gz
rem: encode durations longer than a day as repetitions
-rw-r--r--rem.lua62
1 files changed, 21 insertions, 41 deletions
diff --git a/rem.lua b/rem.lua
index 1c0887a..3dd1aeb 100644
--- a/rem.lua
+++ b/rem.lua
@@ -79,47 +79,12 @@ local get_param_value_1 = function (params, name)
return nil
end
-local rem_of_vcalendars do
-
- local f_sec = 1
- local f_min = 60 * f_sec
- local f_hour = 60 * f_min
- local f_day = 24 * f_hour
- local l_month = { [00] = 0
- , [01] = 31
- , [02] = 30
- , [03] = 31
- , [04] = 30
- , [05] = 31
- , [06] = 30
- , [07] = 31
- , [08] = 31
- , [09] = 30
- , [10] = 31
- , [11] = 30
- , [12] = 31
- }
-
- local time_of_month = function (m, y)
- local r = 0
-
- for i = 0, m - 1 do
- local f = l_month [i]
-
- if i == 2 and y % 4 == 0 and y % 100 ~= 0 then
- f = f + 1
- end
-
- r = r + f * f_day
- end
+local time_f_sec = 1
+local time_f_min = 60 * time_f_sec
+local time_f_hour = 60 * time_f_min
+local time_f_day = 24 * time_f_hour
- return r
- end
-
- local time_of_year = function (y)
- if y % 4 == 0 and y % 100 ~= 0 then
- end
- end
+local rem_of_vcalendars do
--[[--
@@ -231,11 +196,26 @@ local rem_of_vcalendars do
return stringformat ("%0.2d:%s", dt, ret)
end
+ local repeat_of_duration = function (te)
+ local till = rem_date (te)
+
+ return stringformat ("*1 UNTIL %s", till)
+ end
+
+
local rem_date_duration = function (t0, te, loctime)
local dt = te - t0
local s_t0 = rem_date (t0, loctime)
- if dt == 0 then return s_t0 end
+ if dt == 0 or dt == time_f_day then
+ return s_t0
+ end
+
+ if dt > time_f_day then --- needs repeat claus
+ local rep = repeat_of_duration (te)
+
+ return stringformat ("%s %s", s_t0, rep)
+ end
local s_dt = rem_duration (dt)