Skip to main content

A Random Timestamp Generator

Project description

random_timestamp

A Random Timestamp Generator

Usage

The function random_timestamp takes four optional arguments:

random_timestamp(year=1900, month=1, day=1, part='DATE/TIME')

If year and month and day are not inputed, the timestamp will be randomly generated between 1900 and today's date (datetime.now().date())).

If a later date after today is inputed, the output date will be today's date as well. The optional part parameter is to select only the date or time portion of the timestamp to output.

>>> from random_timestamp import random_timestamp

>>> random_timestamp()
datetime.datetime(1986, 5, 31, 2, 50, 5)

>>> random_timestamp(2020)
datetime.datetime(2020, 2, 11, 12, 4, 51)

>>> random_timestamp(month=1)
datetime.datetime(1914, 1, 15, 22, 3, 58)

>>> random_timestamp(2020, 4, 16, 'DATE')
datetime.date(2020, 4, 16)

>>> random_timestamp(part='TIME')
datetime.time(10, 59, 6)

License

This project is released under GNU GENERAL PUBLIC LICENSE V3.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

random_timestamp-1.0.1.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

random_timestamp-1.0.1-py3-none-any.whl (15.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page