-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
convert moment with timezone to UTC instead of raising an exception #29606
convert moment with timezone to UTC instead of raising an exception #29606
Conversation
elif not hasattr(moment.tzinfo, "offset") or moment.tzinfo.offset != 0: # type: ignore | ||
raise ValueError(f"The passed datetime must be using Pendulum's UTC, not {moment.tzinfo!r}") | ||
else: | ||
self.moment = moment | ||
self.moment = timezone.convert_to_utc(moment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Tests Police" here 🤣 , we need also test this one.
A guess we do not have unittests for this constructor except type checking.
The same valid for TimeDeltaTrigger
which based on DateTimeTrigger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just updated the test test_datetime_trigger_timing
to check if the logic remains valid with different timezones
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could check just in class constructor but this seems like even better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Taragolis looks like there are tests added. Do you think there should be more testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait till CI green
elif not hasattr(moment.tzinfo, "offset") or moment.tzinfo.offset != 0: # type: ignore | ||
raise ValueError(f"The passed datetime must be using Pendulum's UTC, not {moment.tzinfo!r}") | ||
else: | ||
self.moment = moment | ||
self.moment = timezone.convert_to_utc(moment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could check just in class constructor but this seems like even better
closes: #29576
Currently, when we provide a datetime with timezone different from UTC to
DateTimeTrigger
, it raises an exception. Instead, I convert the datetime to UTC.