Created
September 7, 2017 17:34
-
-
Save dafma/8e07d280f27e64e343f815f494ffe1b1 to your computer and use it in GitHub Desktop.
el próximo martes a partir de una fecha
This file contains hidden or 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
import datetime | |
d = datetime.date(2017, 9, 9) | |
def next_weekday(d, weekday): | |
days_ahead = weekday - d.weekday() | |
if days_ahead <= 0: | |
days_ahead += 7 | |
return d + datetime.timedelta(days_ahead) | |
next_monday = next_weekday(d, 1) | |
print(next_monday) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment