mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-14 00:47:39 +00:00
[utils] Fix random_birthday to generate existing dates only
This commit is contained in:
parent
3430ff9b07
commit
aa374bc78e
1 changed files with 7 additions and 3 deletions
|
@ -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)),
|
year_field: str(random_date.year),
|
||||||
month_field: str(random.randint(1, 12)),
|
month_field: str(random_date.month),
|
||||||
day_field: str(random.randint(1, 31)),
|
day_field: str(random_date.day),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue