ATFutures / calendar

R interface to iCal (.ics files)
https://atfutures.github.io/calendar/
Other
38 stars 10 forks source link

Save tzid of local time environment by default #22

Closed Robinlovelace closed 5 years ago

Robinlovelace commented 5 years ago

As discussed with @cmcaine, ic_write() does not save the time zone. This led to a meeting being scheduled for the wrong time!

Reprex illustrating the problem (no tzid is saved so it assumes we're in UTC):

library(ical)
now = Sys.time()
later = now + 60^2
later - now
#> Time difference of 1 hours
e1 = ic_event(start_time = now, end_time = later)
e1$DTSTART
#> [1] "2018-10-19 16:53:38 BST"
ic_write(e1, "e1.ics")
e1_txt = readLines("e1.ics")
any(grepl(pattern = "TZID", e1_txt))
#> [1] FALSE

Created on 2018-10-19 by the reprex package (v0.2.1)

2 options: 1) save the tzid by default or 2) convert everything to UTC. I suggest 1) is better - agreed @cmcaine ? Give it a bosh if you fancy, otherwise I'm on it.

layik commented 5 years ago

(1) is best.

Read would also take locale tzid.

cmcaine commented 5 years ago

I don't think it matters, but if you do (1) you don't have to deal with BST boundaries yourself - you just need a way of picking a TZID from e.g. the name of the time offset or geolocation or whatever.

Geolocation providers if you want to use them: https://wiki.archlinux.org/index.php/time#Time_zone

Robinlovelace commented 5 years ago

Turns out adding TZID didn't solve it. Removing the Z by default from the time did. Heads-up @layik on the imperfect solution.