Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def utcnow(cls):
result = cls._time_to_freeze() or real_datetime.utcnow()
return datetime_to_fakedatetime(result)
@staticmethod
def _time_to_freeze():
if freeze_factories:
return get_current_time()
@classmethod
def _tz_offset(cls):
return tz_offsets[-1]
FakeDatetime.min = datetime_to_fakedatetime(real_datetime.min)
FakeDatetime.max = datetime_to_fakedatetime(real_datetime.max)
def convert_to_timezone_naive(time_to_freeze):
"""
Converts a potentially timezone-aware datetime to be a naive UTC datetime
"""
if time_to_freeze.tzinfo:
time_to_freeze -= time_to_freeze.utcoffset()
time_to_freeze = time_to_freeze.replace(tzinfo=None)
return time_to_freeze
def pickle_fake_date(datetime_):
# A pickle function for FakeDate
return FakeDate, (
datetime_.year,