Skip to content

Commit

Permalink
fix date_time on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
fcurella committed Jan 22, 2025
1 parent db222aa commit 264a8e2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions faker/providers/date_time/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2015,12 +2015,16 @@ def date_time(
:example: datetime('2005-08-16 20:39:21')
:return: datetime
"""
start = datetime(1970, 1, 1, tzinfo=tzinfo)
end = self._parse_end_datetime(start, end_datetime)
# NOTE: On windows, the lowest value you can get from windows is 86400
# on the first day. Known python issue:
# https://bugs.python.org/issue30684
start = datetime(1970, 1, 1, tzinfo=tzinfo)
end = self._parse_end_datetime(start, end_datetime)
return self.date_time_between(start.timestamp(), end, tzinfo)
try:
start_ts = start.timestamp()
except OSError:
start_ts = 86400
return self.date_time_between(start_ts, end, tzinfo)

def date_time_ad(
self,
Expand Down

0 comments on commit 264a8e2

Please sign in to comment.