Share the untimed wall clock and zone checks, shift exceptions by days, review fixes (#101)

This commit is contained in:
makiolaj committed 2026-11-17 17:08:08 +01:00
1 parent d04ef3d612
commit d95fb9c5f9
13 files changed
+122 -35

No files matched your search

@@ -50,6 +50,19 @@ class StoredRemindersTest {
assertThat(stored(untimedStart, with = withTimes)).contains(TaskReminder(0, fromStart = true))
}
@Test
fun `an untouched untimed end from another zone does not count as moved`() {
val day = LocalDate.of(2026, 9, 3)
val current = testTask(id = 1, start = now - 30.days, due = untimedInstantOf(TaskEnd.DUE, day, ZoneId.of("America/New_York")))
.copy(untimed = TaskEnd.DUE, timeZone = "America/New_York")
val own = TaskReminder(0, fromStart = true)
val form = TaskForm(
title = "t", listId = 1, start = current.start, due = current.formValueOf(TaskEnd.DUE),
untimed = TaskEnd.DUE, reminders = listOf(own),
)
assertThat(stored(form, current)).containsExactly(own)
}
@Test
fun `a new task takes the defaults for the dates it has`() {
val form = TaskForm(title = "t", listId = 1, start = now + 2.days, due = now + 5.days)
@@ -6,6 +6,7 @@ import de.jeanlucmakiola.agendula.data.tasks.room.TaskAlarmEntity
import de.jeanlucmakiola.agendula.data.tasks.room.TaskEntity
import de.jeanlucmakiola.agendula.domain.PRIORITY_NONE
import de.jeanlucmakiola.agendula.domain.TaskEnd
import de.jeanlucmakiola.agendula.domain.untimedDate
import de.jeanlucmakiola.agendula.domain.TaskStatus
import de.jeanlucmakiola.agendula.domain.ical.ICalComponent
import de.jeanlucmakiola.agendula.domain.ical.ICalParser
@@ -554,11 +555,23 @@ class VTodoMapperTest {
@Test
fun `without a zone the untimed end is written floating, never as UTC`() {
val start = VTodoMapper.write(mixed.copy(timezone = null)).property("DTSTART")!!
assertThat(start.value).doesNotContain("Z")
assertThat(start.value).endsWith("T000000")
assertThat(start.param("TZID")).isNull()
assertThat(start.param(ICalValues.NO_TIME_PARAM)).isEqualTo("TRUE")
}
@Test
fun `a floating untimed start on a day without a midnight still reads as one`() {
val read = VTodoMapper.read(
vtodo(
"DTSTART;X-AGENDULA-NO-TIME=TRUE:20260906T000000",
"DUE;TZID=America/Santiago:20260906T170000",
),
).entity
assertThat(read.untimed).isEqualTo(TaskEnd.START)
assertThat(read.dtstart!!.untimedDate(read.timezone)).isEqualTo(java.time.LocalDate.of(2026, 9, 6))
}
@Test
fun `a mark on a DATE is ignored, the task is all-day`() {
val read = VTodoMapper.read(
@@ -145,4 +145,28 @@ class TaskFormWriterSeriesTest {
assertThat(edited.dtstart).isEqualTo(untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 1, 12), berlin))
assertThat(edited.untimed).isEqualTo(TaskEnd.START)
}
@Test
fun `its exceptions move by whole days with it`() {
val berlin = java.time.ZoneId.of("Europe/Berlin")
val untimed = master.copy(
dtstart = untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 3, 20), berlin),
due = null,
untimed = TaskEnd.START,
rrule = "FREQ=DAILY",
exdate = "20260327T000000",
)
val occurrence = untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 3, 28), berlin)
val form = TaskForm(
title = "Water plants",
listId = 1,
start = untimedInstantOf(TaskEnd.START, LocalDate.of(2026, 3, 30), berlin),
due = Instant.parse("2026-03-31T10:00:00Z"),
untimed = TaskEnd.START,
rrule = "FREQ=DAILY",
)
val edited = TaskFormWriter.seriesEdit(untimed, occurrence, null, form, now, "Europe/Berlin")
assertThat(edited.exdate).isEqualTo("20260329T000000")
}
}
@@ -153,6 +153,15 @@ class ICalendarWriterTest {
assertThat(lines).contains("DUE:20250802T120000Z")
}
@Test
fun `the untimed start of a series goes out timed, beside its UTC rule`() {
val start = Instant.parse("2025-08-01T22:00:00Z")
val lines = linesOf(
write(task(start = start, due = noon, untimed = TaskEnd.START, timeZone = "Europe/Berlin", rrule = "FREQ=DAILY;UNTIL=20250901T215959Z")),
)
assertThat(lines).contains("DTSTART:20250801T220000Z")
}
@Test
fun `an exported untimed end reads back as one, on its date`() {
val start = Instant.parse("2025-08-01T22:00:00Z")