for a hobby project I have utc seconds since unix epoch and want to have a Ptime.t * int with correct timezone offset in a given timezone. Daylight saving makes it nasty. Currently I hack something with index (timedesc.index) and Ptime / Erratique but my approach doesn’t feel quite right. Also I want to be lean on dependencies and avoid Jane street’s core.
let tz = "Europe/Zurich" |> Timedesc.Time_zone.make_exn and of_rfc3339 (str : string) : (Ptime.t * int) = match str |> Ptime.of_rfc3339 with | Ok (t, Some tz_s, _) -> (t, tz_s) | _ -> (Ptime.min, 0) in let of_epoch utc_s = utc_s |> Timedesc.of_timestamp_float_s ~tz_of_date_time:tz |> Option.get |> Timedesc.to_rfc3339 |> Option.get |> of_rfc3339 in ...
How would I git rid of the rfc3339 string conversion steps?
P.S.: the real code is mro/internet-radio-recorder: 📻 Record internet radio broadcasts and turn them into RSS feeds (podcasts) with a raspberry pi a.k.a. raspi (or any other debian-like box) - pages/stations/b2/app/broadcast-scrape-cmd/lib/br.ml at develop - internet-radio-recorder - Codeberg.org