-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #479 from rcpch/staging
Staging
- Loading branch information
Showing
31 changed files
with
1,221 additions
and
485 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
from random import randrange | ||
from datetime import timedelta | ||
from datetime import timedelta, date | ||
|
||
|
||
def random_date(start, end): | ||
""" | ||
This function will return a random datetime between two datetime | ||
objects. | ||
Thanks to Boris Verkihovsky (https://stackoverflow.com/questions/553303/generate-a-random-date-between-two-other-dates) | ||
""" | ||
def random_date(start: date, end: date): | ||
delta = end - start | ||
int_delta = (delta.days * 24 * 60 * 60) + delta.seconds | ||
random_second = randrange(int_delta) | ||
return start + timedelta(seconds=random_second) | ||
random_days = randrange(0, delta.days) | ||
return start + timedelta(days=random_days) |
Oops, something went wrong.