diff options
author | Alexander Seiler <seileralex@gmail.com> | 2018-12-01 18:05:15 +0100 |
---|---|---|
committer | Sergey M <dstftw@gmail.com> | 2018-12-02 00:05:15 +0700 |
commit | aa374bc78e5e4dbb8453bd367ae0e3c0db702a7a (patch) | |
tree | 0f8fd1f1a7e3d9b7054422ab437a6f51476ba733 /youtube_dl/utils.py | |
parent | 3430ff9b07d4dc9dd39617af54aeffb381d88737 (diff) |
[utils] Fix random_birthday to generate existing dates only
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index e84d35d4d..0b1c7cd6c 100644 --- 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): + 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 { - 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), } |