projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[utils] Fix random_birthday to generate existing dates only
[youtube-dl]
/
youtube_dl
/
utils.py
diff --git
a/youtube_dl/utils.py
b/youtube_dl/utils.py
index e84d35d4dee2077faf89bbecb0083ca01e6273c4..0b1c7cd6c7a3b3229844fa4e53299bdf1139353a 100644
(file)
--- a/
youtube_dl/utils.py
+++ b/
youtube_dl/utils.py
@@
-3948,8
+3948,12
@@
def write_xattr(path, key, value):
def random_birthday(year_field, month_field, day_field):
def random_birthday(year_field, month_field, day_field):
+ start_date = datetime.date(1950, 1, 1)
+ end_date = datetime.date(1995, 12, 31)
+ offset = random.randint(0, (end_date - start_date).days)
+ random_date = start_date + datetime.timedelta(offset)
return {
return {
- year_field: str(random
.randint(1950, 1995)
),
- month_field: str(random
.randint(1, 12)
),
- day_field: str(random
.randint(1, 31)
),
+ year_field: str(random
_date.year
),
+ month_field: str(random
_date.month
),
+ day_field: str(random
_date.day
),
}
}