Compare commits
No commits in common. "d4ecf243ae7f1610ec1590d4b8acdf1935873fb4" and "2377e5e325b3ef620a018a33c601fa137f9dfd6f" have entirely different histories.
d4ecf243ae
...
2377e5e325
1 changed files with 20 additions and 0 deletions
20
timezone.py
Normal file
20
timezone.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from datetime import datetime, tzinfo, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class TZMadrid(tzinfo):
|
||||||
|
def utcoffset(self, dt):
|
||||||
|
return timedelta(hours=1) + self.dst(dt)
|
||||||
|
|
||||||
|
def dst(self, dt):
|
||||||
|
dston = datetime.date(dt.year, 4, 1)
|
||||||
|
dstoff = datetime.date(dt.year, 10, 27)
|
||||||
|
# Code to set dston and dstoff to the time zone's DST
|
||||||
|
# transition times based on the input dt.year, and expressed
|
||||||
|
# in standard local time.
|
||||||
|
|
||||||
|
if dston <= dt.replace(tzinfo=None) < dstoff:
|
||||||
|
return timedelta(hours=1)
|
||||||
|
else:
|
||||||
|
return timedelta(0)
|
Loading…
Reference in a new issue