Timezone handling in Ash
I'm using https://github.com/madeitGmbH/tz_datetime to store user entered local datetime as UTC datetime in the table, and convert it back to local time when reading. Does Ash have a built-in solution for making this type of timezone conversion easier?
GitHub
GitHub - madeitGmbH/tz_datetime: Opinonated handling of datetimes a...
Opinonated handling of datetimes and their original timezone with ecto - GitHub - madeitGmbH/tz_datetime: Opinonated handling of datetimes and their original timezone with ecto
4 Replies
I don’t think we have anything dedicated to that, but that library looks like a great implementation and that using Ash with it should go nicely.
I think you could pair it nicely with
1. a calculation that depends on the three fields in question
2. A change that sets the fields in writes
Thank you! I will give it a try.
Here is my naive attempt that failed with the error message at the bottom. The issue probably is that I'm treating Ash Changeset as if it's Ecto changeset. Can you give me some pointers as to how/if this can be tweaked to work?
Ash changesets are structured very differently from ecto changesets
For example,
changeset.errors
is not a keyword list of field to errors, and .changes
is not a key
I don't know if we have a great way right off the bat for you to look for errors on a given field. I could write you a helper that would do it likely, for now
but to start off I'd suggest something as simple as this:
Thank you!!