Keep an untimed series' zone on an edit for all occurrences (#101)

This commit is contained in:
makiolaj committed 2026-11-20 12:28:37 +01:00
1 parent d6425124ee
commit fd28ffc451
2 files changed
+79 -14

No files matched your search

@@ -223,4 +223,60 @@ class TaskFormWriterSeriesTest {
assertThat(edited.exdate).isEqualTo("20260329T000000")
}
@Test
fun `a title-only edit from another zone keeps an untimed series 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 = Instant.parse("2026-03-02T16:00:00Z"),
untimed = TaskEnd.START,
rrule = "FREQ=DAILY",
exdate = "20260304T000000,20260305T000000",
)
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),
due = Instant.parse("2026-03-10T16:00:00Z"),
untimed = TaskEnd.START,
rrule = "FREQ=DAILY",
)
val edited = TaskFormWriter.seriesEdit(untimed, occurrence, Instant.parse("2026-03-10T16:00:00Z"), form, now, "America/New_York")
assertThat(edited.title).isEqualTo("Water all plants")
assertThat(edited.dtstart).isEqualTo(untimed.dtstart)
assertThat(edited.due).isEqualTo(untimed.due)
assertThat(edited.timezone).isEqualTo("Europe/Berlin")
assertThat(edited.exdate).isEqualTo(untimed.exdate)
}
@Test
fun `moving it a day from another zone moves 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",
)
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),
due = Instant.parse("2026-03-12T16:00:00Z"),
untimed = TaskEnd.START,
rrule = "FREQ=DAILY",
)
val edited = TaskFormWriter.seriesEdit(untimed, occurrence, null, form, now, "America/New_York")
assertThat(edited.dtstart).isEqualTo(untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 3, 3), berlin))
assertThat(edited.timezone).isEqualTo("Europe/Berlin")
assertThat(edited.exdate).isEqualTo("20260304T230000Z")
}
}