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

Method tzname

tests/test_code/py/pytz/tzinfo.py:466–502  ·  view source on GitHub ↗

See datetime.tzinfo.tzname The is_dst parameter may be used to remove ambiguity during DST transitions. >>> from pytz import timezone >>> tz = timezone('America/St_Johns') >>> normal = datetime(2009, 9, 1) >>> tz.tzname(normal) 'NDT'

(self, dt, is_dst=None)

Source from the content-addressed store, hash-verified

464 return self._dst
465
466 def tzname(self, dt, is_dst=None):
467 '''See datetime.tzinfo.tzname
468
469 The is_dst parameter may be used to remove ambiguity during DST
470 transitions.
471
472 >>> from pytz import timezone
473 >>> tz = timezone('America/St_Johns')
474
475 >>> normal = datetime(2009, 9, 1)
476
477 >>> tz.tzname(normal)
478 'NDT'
479 >>> tz.tzname(normal, is_dst=False)
480 'NDT'
481 >>> tz.tzname(normal, is_dst=True)
482 'NDT'
483
484 >>> ambiguous = datetime(2009, 10, 31, 23, 30)
485
486 >>> tz.tzname(ambiguous, is_dst=False)
487 'NST'
488 >>> tz.tzname(ambiguous, is_dst=True)
489 'NDT'
490 >>> try:
491 ... tz.tzname(ambiguous)
492 ... except AmbiguousTimeError:
493 ... print('Ambiguous')
494 Ambiguous
495 '''
496 if dt is None:
497 return self.zone
498 elif dt.tzinfo is not self:
499 dt = self.localize(dt, is_dst)
500 return dt.tzinfo._tzname
501 else:
502 return self._tzname
503
504 def __repr__(self):
505 if self._dst:

Callers

nothing calls this directly

Calls 1

localizeMethod · 0.95

Tested by

no test coverage detected