massivefermion / birl

datetime handling for gleam
https://hex.pm/packages/birl
Apache License 2.0
72 stars 9 forks source link

Naive date time type #9

Closed lpil closed 1 year ago

lpil commented 1 year ago

Hello!

Chatting with @nicd today about datetime libraries and he raised a good point about the Elixir date time module- it provides a NaiveDateTime struct in addition to the others.

This functionality is very useful, I think there's something to gain here. I'm not entirely sure what the ideal API should be, but it could be good to explore.

Cheers, Louis

massivefermion commented 1 year ago

I did some digging and it seems there are two use cases for a naive datetime type:

  1. Allowing datetime values that are not affected by daylight saving
  2. Only allowing utc datetime values.

The first use case doesn't apply to birl because it doesn't have a timezone database yet so the developer has complete control over offsets. And if their use case does not involve offsets, they can just ignore the fact that offsets exist! The second use case can be easily handled by validating datetime values using the get_offset function.

Of course I may have missed something.