python - Find the date for the first Monday after a given a date -


given particular date, 2011-07-02, how can find date of next monday (or weekday day matter) after date?

import datetime def next_weekday(d, weekday):     days_ahead = weekday - d.weekday()     if days_ahead <= 0: # target day happened week         days_ahead += 7     return d + datetime.timedelta(days_ahead)  d = datetime.date(2011, 7, 2) next_monday = next_weekday(d, 0) # 0 = monday, 1=tuesday, 2=wednesday... print(next_monday) 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -