MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / _FixedOffset

Class _FixedOffset

tests/test_code/py/pytz/__init__.py:398–435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396# Time-zone info based solely on fixed offsets
397
398class _FixedOffset(datetime.tzinfo):
399
400 zone = None # to match the standard pytz API
401
402 def __init__(self, minutes):
403 if abs(minutes) >= 1440:
404 raise ValueError("absolute offset is too large", minutes)
405 self._minutes = minutes
406 self._offset = datetime.timedelta(minutes=minutes)
407
408 def utcoffset(self, dt):
409 return self._offset
410
411 def __reduce__(self):
412 return FixedOffset, (self._minutes, )
413
414 def dst(self, dt):
415 return ZERO
416
417 def tzname(self, dt):
418 return None
419
420 def __repr__(self):
421 return 'pytz.FixedOffset(%d)' % self._minutes
422
423 def localize(self, dt, is_dst=False):
424 '''Convert naive time to local time'''
425 if dt.tzinfo is not None:
426 raise ValueError('Not naive datetime (tzinfo is already set)')
427 return dt.replace(tzinfo=self)
428
429 def normalize(self, dt, is_dst=False):
430 '''Correct the timezone information on the given datetime'''
431 if dt.tzinfo is self:
432 return dt
433 if dt.tzinfo is None:
434 raise ValueError('Naive time - no tzinfo set')
435 return dt.astimezone(self)
436
437
438def FixedOffset(offset, _tzinfos={}):

Callers 1

FixedOffsetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected