Write a series' untimed start without a zone in the device's zone (#101)
This commit is contained in:
1 parent
a82fa01b71
commit
2ce375bb85
2 files changed
+26
-2
No files matched your search
@@ -606,10 +606,13 @@ object VTodoMapper {
|
||||
if (untimed?.propertyName == name) {
|
||||
// A UTC value says nothing about its day: without a zone, the wall clock alone.
|
||||
val mark = ICalParam(ICalValues.NO_TIME_PARAM, "TRUE")
|
||||
return if (tzid == null) {
|
||||
// Not a series' start, beside UTC UNTIL and EXDATE (RFC 5545 §3.3.10): that one takes this device's zone.
|
||||
val series = untimed == TaskEnd.START && (!entity.rrule.isNullOrBlank() || !entity.rdate.isNullOrBlank())
|
||||
val zone = tzid ?: ZoneId.systemDefault().id.takeIf { series }
|
||||
return if (zone == null) {
|
||||
ICalProperty(name, listOf(mark), ICalValues.formatFloating(untimedWall(untimed, instant.untimedDate(null))))
|
||||
} else {
|
||||
ICalProperty(name, listOf(mark, ICalParam("TZID", tzid)), ICalValues.formatDateTime(instant, tzid))
|
||||
ICalProperty(name, listOf(mark, ICalParam("TZID", zone)), ICalValues.formatDateTime(instant, zone))
|
||||
}
|
||||
}
|
||||
val params = if (tzid == null) emptyList() else listOf(ICalParam("TZID", tzid))
|
||||
|
||||
@@ -487,6 +487,27 @@ class VTodoMapperTest {
|
||||
assertThat(VTodoMapper.read(written).entity.untimed).isEqualTo(TaskEnd.DUE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a series' untimed start without a zone is not written floating beside its UTC UNTIL`() {
|
||||
val device = java.time.ZoneId.systemDefault()
|
||||
val floating = mixed.copy(
|
||||
dtstart = de.jeanlucmakiola.agendula.domain.untimedInstantOf(TaskEnd.START, java.time.LocalDate.of(2026, 9, 1), device),
|
||||
timezone = null,
|
||||
)
|
||||
val oneOff = VTodoMapper.write(floating).property("DTSTART")!!
|
||||
assertThat(oneOff.param("TZID")).isNull()
|
||||
assertThat(oneOff.value).isEqualTo("20260901T000000")
|
||||
|
||||
val series = floating.copy(rrule = "FREQ=DAILY;UNTIL=20260930T220000Z")
|
||||
val start = VTodoMapper.write(series).property("DTSTART")!!
|
||||
assertThat(start.param("TZID")).isEqualTo(device.id)
|
||||
assertThat(start.param(ICalValues.NO_TIME_PARAM)).isEqualTo("TRUE")
|
||||
assertThat(start.value).isEqualTo("20260901T000000")
|
||||
val read = VTodoMapper.read(VTodoMapper.write(series)).entity
|
||||
assertThat(read.untimed).isEqualTo(TaskEnd.START)
|
||||
assertThat(read.dtstart).isEqualTo(series.dtstart)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a value another client rewrote without the mark has a time again`() {
|
||||
val read = VTodoMapper.read(
|
||||
|
||||
Reference in new issue
Block a user