1

I have seen several questions / answers here on stackoverflow regarding the question how to detect whether a certain (timezone aware) datetime value is a daylight saving time value.

As this is a little bit inconvenient for my use case:

Is there any functionality in Python where I supply

  • the year and
  • the timezone

as input and get something back like:

  • datetime (tuple) representing the start of the DST period
  • datetime (tuple) representing the end of the DST period
user7468395
  • 1,299
  • 2
  • 10
  • 23

1 Answers1

1

There is nothing in the standard tzinfo object that will return what you're looking for. However it's possible to test a particular date with tzinfo.dst() to see whether it's part of the daylight saving period, so you can do a binary search to find the transition.

Mark Ransom
  • 299,747
  • 42
  • 398
  • 622