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

Method dst

tests/test_code/py/pytz/tzinfo.py:427–464  ·  view source on GitHub ↗

See datetime.tzinfo.dst 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) >>> str(tz.dst(normal)) '1:00:00'

(self, dt, is_dst=None)

Source from the content-addressed store, hash-verified

425 return self._utcoffset
426
427 def dst(self, dt, is_dst=None):
428 '''See datetime.tzinfo.dst
429
430 The is_dst parameter may be used to remove ambiguity during DST
431 transitions.
432
433 >>> from pytz import timezone
434 >>> tz = timezone('America/St_Johns')
435
436 >>> normal = datetime(2009, 9, 1)
437
438 >>> str(tz.dst(normal))
439 '1:00:00'
440 >>> str(tz.dst(normal, is_dst=False))
441 '1:00:00'
442 >>> str(tz.dst(normal, is_dst=True))
443 '1:00:00'
444
445 >>> ambiguous = datetime(2009, 10, 31, 23, 30)
446
447 >>> str(tz.dst(ambiguous, is_dst=False))
448 '0:00:00'
449 >>> str(tz.dst(ambiguous, is_dst=True))
450 '1:00:00'
451 >>> try:
452 ... tz.dst(ambiguous)
453 ... except AmbiguousTimeError:
454 ... print('Ambiguous')
455 Ambiguous
456
457 '''
458 if dt is None:
459 return None
460 elif dt.tzinfo is not self:
461 dt = self.localize(dt, is_dst)
462 return dt.tzinfo._dst
463 else:
464 return self._dst
465
466 def tzname(self, dt, is_dst=None):
467 '''See datetime.tzinfo.tzname

Callers

nothing calls this directly

Calls 1

localizeMethod · 0.95

Tested by

no test coverage detected