Created
November 28, 2016 08:07
-
-
Save ecarreras/6a4b258c3320fbc7d8a32175efb092ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import calendar | |
def canvi_hora(year, month): | |
for d in range(calendar.monthrange(year, month)[1], 1, -1): | |
if datetime(year, month, d).weekday() == calendar.SUNDAY: | |
return d | |
def get_canvis_hora(year): | |
return {'S': datetime(year, 3, canvi_hora(year, 3), 3), 'W': datetime(year, 10, canvi_hora(year, 10), 2)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment