How to use 'python datetime weekday' in Python

Every line of 'python datetime weekday' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
31def next_weekday(d, weekday):
32 """
33 Given a starting timestamp d and a weekday number d (0-6)
34 return the timestamp of the next time this weekday is going to happen
35 """
36 days_ahead = weekday - d.weekday()
37 if days_ahead <= 0: # Target day already happened this week
38 days_ahead += 7
39 return d + datetime.timedelta(days_ahead)

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

Related snippets