Keep an untimed series' zone when splitting it (#101)

This commit is contained in:
makiolaj committed 2026-11-20 12:37:25 +01:00
1 parent 22b95298e2
commit 7d7ce3d662
3 files changed
+96 -24

No files matched your search

@@ -279,4 +279,60 @@ class TaskFormWriterSeriesTest {
assertThat(edited.timezone).isEqualTo("Europe/Berlin")
assertThat(edited.exdate).isEqualTo("20260304T230000Z")
}
@Test
fun `a title-only split from another zone keeps an untimed tail where it was (#101)`() {
val berlin = java.time.ZoneId.of("Europe/Berlin")
val newYork = java.time.ZoneId.of("America/New_York")
val untimed = master.copy(
dtstart = untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 3, 2), berlin),
due = null,
untimed = TaskEnd.START,
rrule = "FREQ=DAILY",
exdate = "20260304T000000,20260312T000000",
)
val occurrence = untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 3, 10), berlin)
val form = TaskForm(
title = "Water all plants",
listId = 1,
start = untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 3, 10), newYork),
untimed = TaskEnd.START,
rrule = "FREQ=DAILY",
)
val tail = TaskFormWriter.splitTail(untimed, occurrence, occurrence, null, form, "FREQ=DAILY", "tail", now, "America/New_York")
assertThat(tail.title).isEqualTo("Water all plants")
assertThat(tail.timezone).isEqualTo("Europe/Berlin")
assertThat(tail.dtstart).isEqualTo(occurrence)
assertThat(tail.exdate).isEqualTo("20260312T000000")
assertThat(untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 3, 12), berlin)).isEqualTo(tail.dtstart!! + 2.days)
}
@Test
fun `a split moved a day from another zone moves the tail's start and exceptions in the series' zone (#101)`() {
val berlin = java.time.ZoneId.of("Europe/Berlin")
val newYork = java.time.ZoneId.of("America/New_York")
val untimed = master.copy(
dtstart = untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 3, 2), berlin),
due = null,
untimed = TaskEnd.START,
rrule = "FREQ=DAILY",
exdate = "20260303T230000Z,20260311T230000Z",
)
val occurrence = untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 3, 10), berlin)
val form = TaskForm(
title = "Water plants",
listId = 1,
start = untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 3, 11), newYork),
untimed = TaskEnd.START,
rrule = "FREQ=DAILY",
)
val tail = TaskFormWriter.splitTail(untimed, occurrence, occurrence, null, form, "FREQ=DAILY", "tail", now, "America/New_York")
assertThat(tail.dtstart).isEqualTo(untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 3, 11), berlin))
assertThat(tail.timezone).isEqualTo("Europe/Berlin")
assertThat(tail.exdate).isEqualTo("20260312T230000Z")
}
}