feat: allow for a configurable time zone database - #41
Conversation
|
hi @benwilson512, First of all, thanks for your contribution. It's great learning that someone is using this package and takes care providing improvements. I've been thinking about your PR and, taking into account the current maintenance state of I'm wondering what's the best way of articulating the flexibility you're introducing with this change. Until now I'm not against introducing breaking changes, actually the opposite. This looks like a good change providing flexibility to the users so it can be a good moment for a first major release, however we need to figure out the best way to do so. |
|
An excellent point. While I think it's in practice extremely unlikely this would mess someone up I do think it's reasonable to make this a 0.4 release. This sort of change would be pretty expected in a pretty 1.0 library. Notably if for whatever reason a user did not want to configure Elixir itself or if they wanted to configure a different database for open hours, that is possible under this PR. I will update the PR to ensure the tests pass, as well as provide some changelog / readme entries to cover the full config story. |
|
That'd be awesome @benwilson512 I have just merged a change in the CI that will unblock the elixir 1.18 ci test. It was failing due to a Erlang certificate problem. So please rebase your branch :-) |
|
Synced with main and changelog / readme notes added. |
|
Ah there we go the CI should pass now. |
|
@hopsor any further changes I need to do here? |
|
hey @benwilson512, thanks for the changes. I'll properly review them during this week |
hopsor
left a comment
There was a problem hiding this comment.
Hey @benwilson512, first of all apologies for my super late feedback. I've been quite busy lately with different topics and I couldn't have a proper look earlier.
I have left you some feedback. Let me know wdyt
| use Mix.Project | ||
|
|
||
| @version "0.3.0" | ||
| @version "0.4.0" |
There was a problem hiding this comment.
please remove this change, it'll be automatically updated by release please
| ## [0.4.0](https://github.com/hopsor/open_hours/compare/v0.2.0...v0.4.0) (TBD) | ||
|
|
||
| * Potentialy breaking chaneg: Make the timezone database configurable ([#41](https://github.com/hopsor/open_hours/pull/41)) | ||
|
|
There was a problem hiding this comment.
this should be removed as well, CHANGELOG.md is maintained by release please
| """ | ||
| @spec database() :: module() | ||
| def database do | ||
| Application.get_env(:open_hours, :time_zone_database, Calendar.get_time_zone_database()) |
There was a problem hiding this comment.
I suggest to not call Calendar.get_time_zone_database(). If the OTP app isn't configuring any time zone database it'll return Calendar.UTCOnlyTimeZoneDatabase which I don't think we want. Instead I'd call Application.get_env(:elixir, :time_zone_database).
I'm using in a personal project astro package and it also relies in time zone databases:
https://github.com/kipcole9/astro/blob/main/lib/astro.ex#L106-L121
https://github.com/kipcole9/astro/blob/main/lib/astro.ex#L1612C7-L1612C56
I think what astro is doing is something we could follow as well. I mean the fallback to @compile_time_time_zone_db. That way if the user of the package doesn't have anything explicitly configured then open_hours should still work.
WDYT?
| end | ||
| ``` | ||
|
|
||
| If you do not already have a timezone database (eg tz or tzdata) configured for your Elixir application |
There was a problem hiding this comment.
If we follow my suggestions here I'd say that time zone database priority is:
config :open_hours, :time_zone_databaseconfig :elixir, :time_zone_databaseTz.TimeZoneDatabaseTzdata.TimeZoneDatabase
Hey folks!
We're in the middle of trying to minimize our dependency on Hackney, after a variety of recently released CVEs and the decision to only remediate them in
~ 4.0. Unfortunatelytzdatahas a direct dependency on hackney.That said we were already on a path to remove
tzdataastzhas a more rigorous overall approach, and this one library is the standout on our end.This PR makes
tzdataoptional, and allows the user to specify one for this library. If one is not specified it falls back to whatever is configured on Elixir itself.While I realize the motivation for this PR on our end is pretty tangential to this library's goals, I do think the approach of not binding to a specific timezone database is a good one.