Skip to content

Commit 0900a51

Browse files
committed
fix(commit): respect daylight saving when computing utc-offset
Related to #362
1 parent a929ab2 commit 0900a51

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Diff for: git/objects/commit.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727

2828
from time import (
2929
time,
30-
altzone
30+
daylight,
31+
altzone,
32+
timezone,
33+
localtime
3134
)
3235
import os
3336
from io import BytesIO
@@ -327,7 +330,8 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False,
327330

328331
# PARSE THE DATES
329332
unix_time = int(time())
330-
offset = altzone
333+
is_dst = daylight and localtime().tm_isdst > 0
334+
offset = altzone if is_dst else timezone
331335

332336
author_date_str = env.get(cls.env_author_date, '')
333337
if author_date:

0 commit comments

Comments
 (0)