Skip to content

Instantly share code, notes, and snippets.

@dafma
Created September 7, 2017 17:34
Show Gist options
  • Save dafma/8e07d280f27e64e343f815f494ffe1b1 to your computer and use it in GitHub Desktop.
Save dafma/8e07d280f27e64e343f815f494ffe1b1 to your computer and use it in GitHub Desktop.
el próximo martes a partir de una fecha
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