Skip to content

Commit

Permalink
Add days_from_now
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinityyi committed Oct 28, 2020
1 parent 37ed120 commit 7b576c1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions snippets/days_from_now.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: days_from_now
tags: date,intermediate
---

Calculates the date of `n` days from today.

- Use `datetime.date.today()` to get the current day.
- Use `datetime.timedelta` to add `n` days from today's date.

```py
from datetime import timedelta, date

def days_from_now(n):
return date.today() + timedelta(n)
```

```py
days_from_now(5) # date(2020, 11, 02)
```

0 comments on commit 7b576c1

Please sign in to comment.