Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tzdata dependency is required and its absence should be handled #1

Closed
mindseyeblind opened this issue Oct 3, 2019 · 2 comments
Closed

Comments

@mindseyeblind
Copy link

The function do_handle_datetime/3 uses DateTime.from_naive/3 to convert datetimes from naive to utc. Elixir by default does not ship with a timezone db, so attempting to use this function without a timezone database installed gives an error of {:error, :utc_only_time_zone_database} which then causes the function to crash.

Solutions to prevent crashing:

  • Add a clause to do_handle_datetime/3 handle the {:error, :utc_only_time_zone_database} output of DateTime.from_naive/3.
  • Add a clause to handle the likewise unhandled output {:error, :incompatible_calendars}

Solutions for timezone dependency:

  • Add a timezone database as strict dependency e.g. tzdata OR
  • Instruct the user to install a timezone dependency.
@LostKobrakai
Copy link
Owner

I guess the first one should stick to crashing as the library is not intended to be used without a timezone database configured (which should however be documented) and for the second one I guess it makes sense to use an optional callback. For as long as the input_datetime is cast by ecto I'm not sure it can even be in a calendar different to Calendar.ISO.

@LostKobrakai
Copy link
Owner

Implemented the changes like described.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants