1432 Commits

Author SHA1 Message Date
Lars Henriksen
d2791b046a Update import of basic recurrence rules
Conversion of COUNT to UNTIL was a simple calculation which assumed one
repetiton per period (day, week, month or year); it does not take exception
days and invalid dates into account. Solved by a new function which returns the
n'th occurrence of a recurrence rule.

In calcurse UNTIL is interpreted as a day (DATE), in RFC 5545 as a time of day
(DATE-TIME). This has implications when a recurrence rule has an occurrence on
the UNTIL day, see comment in ical.c

An "Import:" note is added when a multi-day event is imported and turned into a
calcurse all-day event.

Icalendar quotes in comments have been updated to RFC 5545.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-06-13 10:56:15 -04:00
Lars Henriksen
d8c1c48e78 Support import of time zones (RFC 5545)
The property parameter time zone identifier (TZID) is recognized in DTSTART,
DTEND and EXDATE and the DATE-TIME value converted to a local time. The time
zone identifier is logged in the note file.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-06-13 10:56:15 -04:00
Lars Henriksen
12514eab7f Let RETURN set frequency type to current value in repeat command UI
In addition, the prompt text is shortened.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-05-24 08:52:08 -04:00
Lars Henriksen
92dc069fc4 Include start day in error message for recurrence rule
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-05-24 08:52:08 -04:00
Lars Henriksen
61a743c56a Fix "next occurrence" for multi-day appointments
Better name: day for occur.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-05-24 08:52:08 -04:00
Lars Henriksen
bd238bfd7c Fix recurrence rule expansion with ordered weekday
When the order of a weekday in BYDAY rule expansion (like -5SA or 5SU
for monthly or 55WE for yearly) exceeds the number of available weekdays
in the period (month or year), rule expansion with negative order could
result in a floating point exception. The reason: the modified frequency
might become zero.

Solution. Check order against number of available weekdays and terminate
expansion early whenever possible (also for positive orders).

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-05-12 09:24:11 -04:00
Lars Henriksen
fabacecd16 Take value data type of event start into account in iCal import/export
The patch derives the item type (appointment or event) from the DTSTART
value type. It is then used to perform an extended check of date/time
values and reject non-conformant import files (like those reported in
Github issues #81, (calcurse) events.

The patch includes parsing and code corrections and minor refactoring.

Background:

Ical events are of two types, in calcurse called appointments and
events. RFC 5545 has no distinguishing names for them, but describes
them in section 3.6.1. The event type is derived from the value type of
the DTSTART property. The value type may be either DATE-TIME
(appointment) or DATE (event). If not specified by a VALUE property
parameter in DTSTART, the default value type is DATE-TIME. The value
type must be set explicitly to DATE to get an event. Other properties
and rrule parts must agree with the DTSTART value type (DTEND, DURATION,
EXDATE and UNTIL).

Previously the type of an imported event was derived from the format of
the DTSTART value. The DTSTART value type was not taken into account
when importing, and not specified for recurring events when exporting
(commit 0114289 solved it for events, see GitHub PR #97).

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-05-03 08:59:01 -04:00
Lars Henriksen
f2918b1700 Support interactive test of recurrence rule extensions
The generic command 'next' is introduced.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
f3779d5945 Help for recurrence rule extensions
The help command has been updated for "repeat".

Context dependent, very terse information is built into the repeat
command (edit command) for display in the status bar when editing the
Weekdays, Months and Monthdays lists.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
36f98382e7 Treat recurrent events and appointments alike
The day vector (or "day_items" vector) is used to load the appointments
panel with "day_items" (captions, appointments, events). A multi-day
appointment has several "day_items" in the day vector. This may also be
the case for a recurring item.

The day_item structure has a member "start", which for day_items for
recurring appointments is set to the occurrence found by
recur_item_find_occurrence(), and is used to tell days of a multi-day
appointment apart.

For day_items for recurring events it was set to "day" of the
recur_event structure (the same value for all occurrences) and not used.
The value is now the occurrence found by recur_event_find_occurrence().

The patch is backwards compatible and future-proof.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
852e363271 Fix preselection
The preselected item is not searched for if the range of days is changed
(day_changed = 1). The patch is meant to future-proof the
selected-item-algorithm and is backwards compatible.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
71c34ac7f9 Refactor the repeat command
Code duplication has been eliminated by calling update_rept() from the
repeat command ui_day_item_repeat().

The repeat command asks for simple or advanced repetition.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
dc161b3b67 User interface for recurrence rules
The function update_rept() is extended with editing of the three
recurrence rule lists for BYMONTH, BYMONTHDAY and BYDAY.

The integers of the bymonth and bymonthday lists are edited directly as
integers, while those of the bywday list are mapped to localized weekday
names (as they appear in the calendar panel) with an optional integer
prefix (in RFC5545 style: 1MO, -2SA).

The RFC5545 (icalendar) requirement that the start day must be the first
occurrence and must match the recurrence rule, is met by testing that an
occurrence indeed appears on the start day, in these circumstances:

- when a recurrent item is loaded from file
- when the recurrence rule of an item is edited interactively
- when a recurrent appointment gets a new start time
- when a recurrent appointment is moved

Copy and paste of a recurrent item will only retain the basic recurrence
properties of type, frequency, until and exception days.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
dd864316c6 Recurrence rule extensions
Terms and concepts are from RFC 5545 (the iCalendar specification).

Overall design
--------------

Calcurse is extended with full support for BYMONTH, BYDAY and BYMONTHDAY
recurrence rule (rrule) parts. The three rule parts are lists of,
respectively, months, weekdays and monthdays. The lists are added to
'struct rpt' as linked lists of integers, and the data file format is
extended accordingly (details below). Load and save of the lists follow
the pattern of the existing list of exception dates, also in 'struct
rpt'.

The function recur_item_find_occurence() is split into a front-end and a
back-end. The back-end, called find_occurrence(), is the original
function extended with rrule reductions; the front-end retains the
original name and performs rrule expansions. Front-end plus back-end are
backwards compatible and require no changes in calling functions.

There is no user interface in this patch.

Data file extensions
--------------------

The BYMONTH, BYDAY and BYMONTHDAY lists are added to that part of an
item line which describes the recurrence rule (the "{...}" part). Each
list is - like the list of exception days - a space-separated string of
values identified by the initial character.  Each list is optional and,
if present, must follow the until date and precede the exception day
list. The lists must appear in order BYMONTHDAY list, BYDAY list and
BYMONTH list.

The possible list values are

- BYMONTH: m1, m2, ..., m12
- BYDAY: w0, w1, ..., w6, w7, w-7, w8, w-8, ..., w377, w-377
- BYMONTHDAY: d1, d2, ..., d31, d-1, d-2, ..., d-31

which are interpreted as (cf. RFC 5545)

- BYMONTH: January, February, ..., December.
- BYDAY: SU, MO, ..., SA, +1SU, -1SU, +1MO, -1MO, ..., +53SA, -53SA
- BYMONTHDAY: the first, the second, ..., the 31st, the last,
  the last but one, ..., the last but 30 day of the month

Examples:

Thursday, TH, is w4; Saturday, SA, is w6.

The seventh Thursday, +7TH, is w53 (7 * 7 + 4 = 53); the last but second
Saturday, -2SA, is w-20 (2 * 7 + 6 = 20); the last day of the month is
d-1.

Note that the values w-1, w-2, ..., w-6 are not used.

A recurrent appointment with a BYDAY rule part:

06/23/2019 @ 12:00 -> 06/23/2019 @ 13:00 {1W w0 w6} |every week on Sunday and Saturday

An event with a BYDAY and a BYMONTH rule part:

10/27/2019 [1] {1Y w-7 m10} every year on last Sunday in October

An event with until date, a BYMONTH rule part and an exception day:

06/23/2019 [1] {1Y -> 08/31/2021 m5 m6 m7 !07/23/2020} every year on the 23rd in May, June and July for three years, starting on Sunday, 23 June 2019, but not on 23 July 2020.

Recurrence set expansion and reduction
---------------------------------------

In calcurse a recurrence rule is a quadruple (s, d, r, e) consisting of
start, duration, repetition pattern and exception days and is
implemented as:

	(time_t start, long dur, struct rpt *rpt, llist_t *exc)

In RFC 5545 parlance, a recurrence rule defines a recurrence set
consisting of all recurrence instances (occurrences) not earlier than
start which match the rule pattern. With this concept in mind,
recur_item_find_occurremce() may be thought of as a membership function
for a recurrence set. The call

	recur_item_find_occurrence(s, d, r, e, day, occurrence)

returns true if day belongs to the recurrence set of (s, d, r, e); if so
occurrence points to the recurrence instance (the set member).

For a recurrence rule with only the basic DAYLY, WEEKLY, MONTHLY or
YEARLY type and frequency the recurrence set consists of periodically
repeated instances.  The BYxxx rule parts modify the recurrence set by
reducing or expanding it as specified by RFC 5545.

Expansion is implemented in the front-end by modifications of start
and/or frequency of the rule (s, d, r, e), often several times, in such
a way that the desired recurrence instances are included in the
recurrence set. This is possible because the front-end as the very first
thing checks for early days (day < s). When day is known not to be
early, start (s) can safely be moved backwards. Likewise, if frequency
must be changed, the front-end checks whether the frequency repetition
applies to the week, month or year of day.

Reduction is easier and is performed in the back-end along with the
existing validity checks. It consists in checking whether month, day of
month or weekday of a found occurrence is on the appropriate list.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
23eb51456a Refactor edit of exception days
The patch contains no functional changes, but is a necessary
precondition for extensions of update_rept() (in ui-day.c) with further
recurrence rules.

The reason is that recurrence parameters must be treated as a whole: if
an edit session is cancelled at any point, no value should change, and
all parameters should remain as they were. Hence, the new values must
only be set after all of them have been determined. This was not the
case for the list of exception days, but as long as it was treated last,
it did not matter.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
bf3dba2ae2 Improve data load error reporting
The last part of loading appointments and events is performed by four
"scan" functions called from io_load_app(). Failure in this part of data
load does not use io_load_error().

The four "scan" functions are changed to return an error message on
failure and NULL otherwise (the previous return value was not used).

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
ce81c0fa63 Refactor function calls: recurrence parameters as a single argument
The recurrence parameters are type, frequency, until date and exception
list (in RFC 5545 parlance FREQ, INTERVAL, UNTIL and EXDATE's). When
these are passed in a function call, the argument list becomes long and
not very readable.  When support for extended recurrence rules is
implemented, the number of recurrence parameters increases, and function
signatures must be amended.

Solution: The "struct rpt" is extended with the exception list; any
future recurrence parameters are added here. A pointer to this structure
replaces the recurrence parameters in function calls.

Note: Each recurrent event and appoinment instance has (a pointer to) a
"struct rpt" and in addition an exception list. The latter is retained
to avoid the derived changes, and the exception list in the structure is
initialized to an empty list when the recurrent instance is created.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
3f7bd331c8 Use "struct rpt" to shorten argument lists
Also, prepare for extension of the structure, shorten names and
rearrange comments.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
e9deb6fff3 Extend use of note file for iCal import
iCal import to an item note file is extended from DESCRIPTION to
LOCATION, COMMENT and STATUS for both events and todos.

Addresses GitHub issue #9.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
214a761564 Accept empty DESCRIPTION in ical import
Adresses GitHub issue #274.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Jerem-K
37d326cbe1 Fix formatting of DTSTART for recurrent events
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-04-28 07:32:44 -04:00
Lars Henriksen
41ac4bd96f Fix missing EOL in imported note
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-03-27 13:41:07 -04:00
Lars Henriksen
ffbf714c9e Fix decoding of escaped characters in imported text
Stick strictly to RFC 5545, 3.3.11, Text, for SUMMARY and DESCRIPTION.
Adresses Github issue #271.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-03-22 13:40:28 -04:00
Lars Henriksen
1cb2691342 Fix ical import logging
The following issues have been fixed:

Functions ical_read_event() and ical_read__todo() do not check the return value
of functions which may fail, in which case an item is not skipped even though
a problem may have been logged by the called function.

Function ical_read_note() fails on empty DESCRIPTION, but does not log it.

Function ical_read_exdate() may log a failure, but cannot fail itself.

Function ical_read_summary() can fail, but not log a failure.

Function ical_read_todo() do not skip a todo with an invalid priority.

Additionally:

A safety check has been added to ical_get_value(), and log messages resulting
from failures have been made uniform.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-03-22 13:40:28 -04:00
Lars Henriksen
63c2d4d503 Fix display of interactively imported todos
Todos were imported (and saved), but not loaded into the listbox for display.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-03-22 13:40:28 -04:00
Lars Henriksen
467815d465 Improve ical import logging
The log file is not deleted if items were skipped (adresses Github issue #269).
The log file includes the import file name and time.
The import line numbers have been corrected (and tests amended).

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-03-22 13:40:28 -04:00
Kelvin Jackson
80b60d63cb Escape necessary characters in SUMMARY on export
Escape semicolons, commas, and backslashes when exporting a calendar
item to iCal format.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-03-22 13:40:28 -04:00
Lukas Fleischer
5ad76df5fe Update copyright ranges
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-01-30 19:22:23 +01:00
Lars Henriksen
12863ff7c0 Refactor cut and paste registers
Register REG_BLACK_HOLE can neither be copied into nor pasted from and
has been removed from the input routine.

Register 36 was not used.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-01-13 20:45:25 +01:00
Nitroretro
002cf305a5 Optimize error handling in io_check_dir()
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-12-29 13:22:57 +01:00
Nitroretro
19d2d9229e Change documentation to reflect the new file structure
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-12-23 13:16:39 -05:00
Nitroretro
04162de6dd Add XDG Base Directory Support
* Use "$XDG_DATA_HOME/calcurse" for data files
* Use "$XDG_CONFIG_HOME/calcurse" for config files
* "$XDG_DATA_HOME" defaults to "$HOME/.local/share"
* "$XDG_CONFIG_HOME" defaults to "$HOME/.config"
* If "$HOME/.calcurse" exists, then it will be used instead for backward
compatibility.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-12-23 13:16:39 -05:00
Nitroretro
250a233ff7 Make io_check_dir() create parent directories
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-12-23 13:16:39 -05:00
Lars Henriksen
a0129d6751 Fix next recurrent appointment deleted
If the notify bar displays a recurrent appointment after midnight as next
upcoming appointment, the bar is not updated when the appointment/occurrence is
deleted.  The problem is not seen in 4.3.0 because of the bug described in
commit 8cbd456, Fix next recurring appointment.  The problem and the solution is
the same, this time in the function notify_same_recur_item().

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-12-23 13:16:39 -05:00
Lars Henriksen
b7eb9a9e94 Fix empty string in updatestring()
If the update results in an empty string (return value GETSTRING_RET), the
original string remains whereas it should be empty.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-12-23 13:16:39 -05:00
Lars Henriksen
d8d7dce2b8 Make the text for empty days configurable
The default is "--"; a single space makes the text invisible.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-11-03 10:56:47 -05:00
Lukas Fleischer
f49ec4ad6e Allow discarding a todo item from the priority prompt
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-11-03 10:56:47 -05:00
Issam Maghni
ade5216f68 Support RET to set the todo item priority to 0
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-11-03 10:56:47 -05:00
Lars Henriksen
4aae26e601 Fix save of interactively imported data
Adresses Github issue #249.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-11-03 10:56:47 -05:00
Lars Henriksen
0e46881746 DST and recurrent items
The patch adresses two issues with the function recur_item_find
ocurrence(), one major: mktime(), and one minor: item duration. In
addition, some refactoring is done.

The following recurrent appointments demonstrate the problems (as
described in the message) and are used as test cases in the associated
test commit.

03/29/2019 @ 12:00 -> 03/30/2019 @ 11:00 {2D -> 04/03/2019} |two-day - every other day - not on 1/4
03/31/2019 @ 12:00 -> 03/31/2019 @ 13:00 {1D -> 04/01/2019} |daily - not on 31/3, twice on 1/4
03/31/2019 @ 04:00 -> 03/31/2019 @ 05:00 {1W} |weekly - appears after one week
03/31/2019 @ 12:00 -> 03/31/2019 @ 12:00 {1M} |monthly - never appears
03/31/2019 @ 12:00 -> 03/31/2019 @ 12:00 {1Y} |yearly - never appears
10/20/2019 @ 00:00 -> 10/21/2019 @ 01:00 {1W -> 11/03/2019} |25 hours - ends on 27th, but continues on 28th
03/24/2019 @ 00:00 -> 03/25/2019 @ 00:00 {1W -> 04/07/2019} |24 hours - does not continue on April 1

The root cause is two mktime() calls in recur_item_find_occurrence(),
both of which use an inherited tm_isdst value in the tm structure. In
such cases mktime() will "normalize" the tm stucture if tm_isdst is 0 or
1 and in disagreement with the rest of the tm contents (just like 32 May
will be normalized to 1 June).

Example. In 2019 DST started on 31/3 at 02:00:00 (in the European
Union). If the (local) time "31/3/2018 00:00:00" is passed to mktime()
with tm_isdst = 0, the return value is (say) T sec and the tm structure
is unchanged, because DST is not in effect at midnight. If the same call
is performed with tm_isdst = 1, the return value becomes (T - 3600) sec
and the tm structure is normalized to "30/3/2018 23:00:00", tm_isdst =
0.

In recur_item_find_occurrence(), the normalized tm structure with wrong
day and time is used in ensuing calculations, leading to wrong dates and
the errors observed.

The first mktime() call is used to calculate the "day span" of the
occurrence before the occurrence itself has been determined. But once
the occurence is known, the "day span" is easily determined, and there
is no need for the first mktime() call.

Events have no explicit duration. However, recur_event_find_occurrence()
and recur_event_inday() set the duration of an event to DAYINSEC before
passing it on to recur_item_find_occurrence(). The value is not correct
on the day when DST begins or ends. The interpretation of the daylength
should be left to the called function. Hence, duration is set to -1 to
signal no (explicit) duration.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-10-18 16:29:34 -04:00
Lars Henriksen
2ae30b223e Set time-of-day consistently to midnight for until day
A day begins on midnight (inclusive) and ends on midnight (exclusive). A
day as a whole is represented by the initial midnight, i.e. time-of-day
is 00:00.

On load of recurrent appointments (but not events) time-of-day for the
until day is set to 23:59. For a newly created recurrent appointment the
setting depends on the input method: time-of-day is set to 00:00 if
until day is given as a date (day, month and year), but to time-of-day
for the start day if given as an offset (+dd).

The resulting behaviour is only visible in interactive use of calcurse
as proved by the following scenario.

1) Create an appointment with start time 12:00, end time 11:59 (multi
   day).

2) Turn it into a recurrent appointment of type daily, frequency 3,
   until day +3.

The appointment is correctly displayed with two 2-day occurrences three
days apart.

3) Edit the appointment and select Repetition. Accept existing type,
   frequency and end day (now as a date).

The second day of the second occurrence disappears.

4) Repeat 3), but set the end day as an offset (+3).

The second day of the second occurrence reappears.

The inconsistencies have been eliminated, and time-of-day for the until
day is now always 00:00.

Also, until day may equal start day, so midnights should be compared.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-09-06 18:15:36 -04:00
Lars Henriksen
a0305d754f DST: fix date_change() thoroughly
Explicit setting of Daylight Saving Time should be avoided before as well as
after the mktime() call.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-09-06 18:15:36 -04:00
Lars Henriksen
5fbc499886 Fix monthly and yearly recurrence algorithms
The calculation of the year of the most recent occurrence for year dates before
the start date (disregarding the year) is incorrect for frequencies greater than
one. The most recent occurrence (for a date as mentioned) is either too far or
too close in the past. In most cases it does no harm because the most recent
ocurrence is in the past and does not span the date (i.e. there is no occurrence
on the day). But the following appointment shows the presence of the bug:

12/31/2019 @ 12:00 -> 01/01/2020 @ 12:00 {2Y} |new year

The occurence on 1 Jan 2020 is missing, because the most recent occurrence is
too far in the past (31 Dec 2018 instead of 31 Dec 2019). An occurrence appears
on 1 Jan 2021, because the most recent occurence is too close in the past (31
Dec 2020 instead of 31 Dec 2019).

A similar miscalculation affects the monthly rule as proved by

3/31/2019 @ 12:00 -> 4/1/2019 @ 11:00 {2M} |change of month

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-09-06 18:15:36 -04:00
Lars Henriksen
8a0354e6da Fix edit of empty exception day list
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-07-10 07:38:50 -04:00
Lars Henriksen
cc86516f64 Treat recurrence item parameters as a unit
An edit session, and in particular, a cancelled edit session should encompass
all parameters.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-06-16 15:03:02 -04:00
Lukas Fleischer
3216814be1 Use current value as default for periodic save
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-06-07 21:06:18 -04:00
Lukas Fleischer
4fb5eb4ce3 Disable view item/note bindings for dummy items
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-06-06 22:38:46 -04:00
Lukas Fleischer
d659a8e2ee Use empty end date instead of 0 when editing repetitions
Since commit 987fa9d (Allow to omit end date in repetitions,
2019-06-03), one can provide an empty date instead of using the value 0
to omit the end date of a repetition. Use this as default value when
editing repetitions without an end date.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-06-06 20:57:48 -04:00
Lukas Fleischer
987fa9d3e5 Allow to omit end date in repetitions
Addresses GitHub issue #213.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-06-03 18:43:42 -04:00
Lars Henriksen
e6099b2d59 Fix recurrent appointment end time when duration is zero
Fixes a regression introduced in 223810c (Major overhaul of
appointment/event input routines., 2017-11-06) and 16d3032 (Refactoring
update_duration/day_edit_duration., 2017-10-18).

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-06-03 18:42:52 -04:00