thojanssens1

thojanssens1

Correct me if I’m wrong: the tzdata library seems to generate a huge number of periods based on tz iana zone rules.

You can see the module attribute in the first few lines of this module which seems to indicate that (and all the calc_periods functions):
https://github.com/lau/tzdata/blob/master/lib/tzdata/period_builder.ex#L1

So maybe really dumb question: why isn’t it possible to simply use the rules in order to have the correct local date?

For example, in Belgium, 28th January 2030, at 16:30 UTC will be 17:30 local time (gmt+1) according to the iana tz rule data.

Not sure what’s going on. Any idea?

Showing Posts 1 to 3

NobbZ

NobbZ

You can’t know yet. During the next year europe will get rid of DST. And only at the end of 2020, we will know if a state stays in “summer” or “winter” time.

Also, Belgium might perhaps to decide to leave EU until then and joins the Peoples Republic of China and join their timezone… Unlikely, but who knows?

The actual timezone is only known for events in the past.

I’m pretty sure someone else in this forum might be able to explain in more detail…

There has been a lot of discussion in the threads about introducing the time related modules Calendar, NaiveDateTime, Time, Date, etc…

thojanssens1

thojanssens1 OP

I am aware of that, thank you for pointing that out; I posted this right before sleeping and my head was “too much in the code” and lost clarity.

Nevertheless tzdata allows you to compute a local date in the future (for example from a utc date) with the current known rules, even though there are chances that it will be incorrect (and it will certainly be for European countries):

{:ok, datetime, 0} = DateTime.from_iso8601("2019-03-29T00:00:00Z")
DateTime.shift_zone(datetime, "Europe/Brussels") |> IO.inspect()
# {:ok, #DateTime<2019-03-29 01:00:00+01:00 CET Europe/Brussels>}

{:ok, datetime, 0} = DateTime.from_iso8601("2019-04-02T00:00:00Z")
DateTime.shift_zone(datetime, "Europe/Brussels") |> IO.inspect()
# {:ok, #DateTime<2019-04-02 02:00:00+02:00 CEST Europe/Brussels>}

{:ok, datetime, 0} = DateTime.from_iso8601("2030-03-29T00:00:00Z")
DateTime.shift_zone(datetime, "Europe/Brussels") |> IO.inspect()
# {:ok, #DateTime<2030-03-29 01:00:00+01:00 CET Europe/Brussels>}

{:ok, datetime, 0} = DateTime.from_iso8601("2030-04-02T00:00:00Z")
DateTime.shift_zone(datetime, "Europe/Brussels") |> IO.inspect()
# {:ok, #DateTime<2030-04-02 02:00:00+02:00 CEST Europe/Brussels>}

Above in 2030 in Belgium, DST still applies according to tzdata (because tzdata ofc can’t predict the future).

Anyway, the question is why tzdata generates some kind of table with periods computed from the iana rules, as seen in the github link above. I think it does so also for past dates; so we can forget about dates in the future, because these dates cannot be guaranteed indeed from a UTC date as rules/laws are changing; it was a terrible reference for my question.

Marcus

Marcus

I think the data is precalculated to get faster runtime behavior. Other libraries in other languages are going the same way.
JS: Moment Timezone | Home
.NET: https://nodatime.org/tzvalidate/generate?version=2019c

The calculation for time zone states is not so simple as it looks at first sight. There are many edge cases and some strange rules in the IANA rule set.

You can compute dates in the future. But it is not guaranteed that this will be the correct date forever. The rules can change over time.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews