-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
How can I specify a time zone #335
Comments
Ah... Somehow we haven't gotten to timezone-aware datetimes :-( I can't find the ticket now, so I'm leaving this as the issue to work towards. There was an abandoned attempt #103 but it appeared to have beem forgotten. Thank you for bringing it up again. This is important. |
@long2ice I think this PR brings breaking change. If I use old config which has no
As above, setting |
Yes, so changelog said that, be careful to upgrade. |
I tend to this is a breaking change, maybe 0.17.0 version number will be more suitable. And the worst part is if I don't specified |
You are right, maybe default UTC timezone setted is not suitable, so in version 0.16.18 you can specify your local timezone to resolve that. |
OK, I have pined 0.16.17 to resolve the problem. To be more clear, here is the situation we are facing. Look forward to getting a better solution: ❯ python
Python 3.8.2 (default, May 13 2020, 11:47:24)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> from datetime import datetime
>>> datetime.now()
datetime.datetime(2020, 11, 21, 14, 14, 50, 253867)
>>> os.environ['TZ'] = 'UTC'
>>> datetime.now()
datetime.datetime(2020, 11, 21, 6, 14, 58, 217979) |
Read the complete docs maybe helpful, https://tortoise-orm.readthedocs.io/en/latest/timezone.html |
I said "here is the situation we are facing" means "you and me and Tortoise ORM"... I have already read manual and source code, fixed my case before I commenting this issue, thanks for your reminding. 😄 So... The problem is not I don't know how to use new params If I have time, I maybe commit a PR to fix this behavior. (But I think I have no time... 🤣) |
Yes, set |
Appreciate it! |
@long2ice @mookrs sorry, any possibility I can get back to same behavior in See example: import datetime
from tortoise import fields, models
class DatetimeModel(models.Model):
id = fields.IntField(pk=True, null=False)
created_at = fields.DatetimeField(null=True)
await DatetimeModel.create(created_at=datetime.datetime.utcnow())
created = await DatetimeModel.get(id=1)
assert created.tzinfo is None # Good on 0.16.17, fails on 0.16.18 PS: +1 to that it should be at least |
try set |
The text was updated successfully, but these errors were encountered: