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

DateTime with time zones #192

Open
rgreinho opened this issue Sep 29, 2020 · 1 comment
Open

DateTime with time zones #192

rgreinho opened this issue Sep 29, 2020 · 1 comment

Comments

@rgreinho
Copy link
Contributor

As a developer, I would like to have the ability to store the time zone associated to my DateTime objects.

Currently, they look like this in the Alembic migrations:

sa.Column("created_at", sa.DateTime(), nullable=True),

But I would like to see:

sa.Column("created_at", sa.DateTime(timezone=True), nullable=True),
@jdkandersson
Copy link
Owner

I need to think about this more, I'll just explain why this works in a particular way at the moment and some ideas I have.

In the from_dict function, the DateTime is constructed using datetime.datetime.fromisoformat which does not support timezone information on the back of a format string.

The other thing that comes to mind is that SQLAlchemy doesn't recommend the use of timezone on DateTime, they recommend TIMESTAMP when timezone information is required instead. What comes to mind at the moment would be something like x-timestamp as a boolean and then to also include something like x-timezone as a boolean also. This would impact from_dict and to_dict as well as the autogenerated models file. My feeling is that this should be supported and that it would be a non-trivial change.

Pull requests welcome 😛. Happy to help and it would get you a very thorough understanding of the complete code base.

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