You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a configuration option to allow users to specify their preferred timezone for commit date processing. The default will be UTC, ensuring consistency and avoiding timezone-related issues, but users can adjust it to suit their needs.
Example
Referencing these comments
Consider finding a way to infer the timezone from the source data to avoid errors associated with timezone assumptions (UTC vs non-UTC calculations may not result in the same outcomes).
It's unfortunately not obvious from pygit2's documentation, but the commit_time field is a UNIX timestamp, which doesn't really have a timezone because it's the seconds since January 1st, 1970 UTC. The tz argument to datetime.fromtimestamp() is not the timezone of the source, but the timezone of the returned datetime object. (FWIW, this makes the result a 'timezone-aware' datetime object; you should be very careful to correctly interpret datetime objects that don't have a timezone, since as @d33bs mentioned this can lead to hard-to-debug issues.) In this case, I think it makes sense to use UTC as long it's being used consistently in the codebase.
You might consider pulling it out as a configuration option so the user can choose their own timezone, but default to UTC if it's unspecified.
Existing issue check
Description
Create a configuration option to allow users to specify their preferred timezone for commit date processing. The default will be UTC, ensuring consistency and avoiding timezone-related issues, but users can adjust it to suit their needs.
Example
Referencing these comments
Consider finding a way to infer the timezone from the source data to avoid errors associated with timezone assumptions (UTC vs non-UTC calculations may not result in the same outcomes).
Originally posted by @d33bs in #86 (comment)
It's unfortunately not obvious from pygit2's documentation, but the
commit_time
field is a UNIX timestamp, which doesn't really have a timezone because it's the seconds since January 1st, 1970 UTC. Thetz
argument todatetime.fromtimestamp()
is not the timezone of the source, but the timezone of the returneddatetime
object. (FWIW, this makes the result a 'timezone-aware' datetime object; you should be very careful to correctly interpretdatetime
objects that don't have a timezone, since as @d33bs mentioned this can lead to hard-to-debug issues.) In this case, I think it makes sense to use UTC as long it's being used consistently in the codebase.You might consider pulling it out as a configuration option so the user can choose their own timezone, but default to UTC if it's unspecified.
Originally posted by @falquaddoomi in #86 (comment)
Would you like to work on a solution for this?
The text was updated successfully, but these errors were encountered: