randomtimestamp (v2.3)
Random timestamp generator
Installation
You know it:
pip install randomtimestamp
Usage
randomtimestamp can be used from the command line or imported as a python module.
Command line usage
To use the script from command line
$ randomtimestamp
30-08-1995 17:58:14
Python Module Usage
The module exposes the APIs randomtimestamp, random_time, and random_date.
- randomtimestamp() takes six optional arguments. A call without arguments returns a datetime between January 1st, 1950, 00:00:00 and ({today}, 23:59:59).
NOTE: start/end are resolved before start_year/end_year, therefore start_year/end_year have no effect if start/end have been provided.
randomtimestamp(
start_year: int = 1950,
end_year: int = None,
text: bool = False,
start: datetime.datetime = None,
end: datetime.datetime = None,
pattern: str = "%d-%m-%Y %H:%M:%S"
) -> Union[datetime, str]:
- random_time() takes four optional arguments. A call without arguments returns a time between between (00:00:00) and (23:59:59).
random_time(
start: datetime.time = time.min,
end: datetime.time = time.max,
text: bool = False,
pattern: str = "%H:%M:%S"
) -> Union[time, str]:
- random_date() takes four optional arguments. A call without arguments returns a date between (January 1, 1950) and today.
random_date(
start: datetime.date = date(1950, 1, 1),
end: datetime.date = datetime.today().date(),
text: bool = False,
pattern: str = "%d-%m-%Y"
) -> Union[date, str]:
In any of these function calls, start < end & start_year < end_year is mandatory. pattern has no effect if text = False.
Running tests
python -m unittest discover
Examples:
Here are some examples of the possible syntaxes:
>>> from randomtimestamp import randomtimestamp, random_date, random_time
>>> randomtimestamp()
datetime.datetime(1970, 6, 2, 23, 34, 10)
>>> randomtimestamp(start_year=2020, end_year=2021)
datetime.datetime(2021, 1, 10, 5, 6, 19)
>>> randomtimestamp(start_year=2020, end_year=2021, text=True)
'05-09-2021 17:24:28'
>>> random_time()
datetime.time(13, 18, 14)
>>> random_date()
datetime.date(1990, 6, 13)
>>> random_time(text=True, pattern='%I:%M:%S %p')
'08:06:27 PM'
In any case, if you ever feel stuck, use help(randomtimestamp) inside Python's REPL.
Footnote:
Type validation has been done, but it won't be required for most developers. If you're someone who likes to break the code with deliberately crafted inputs, you'd most likely receive a TypeError or a ValueError.
However, if you do find a bug, please report to make the experience better for other developers.
License
This project is released under GNU GENERAL PUBLIC LICENSE V3.
Metadata
Release files for randomtimestamp 2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| randomtimestamp-2.3.tar.gz | 18.8 kB | Without provenance | Details for randomtimestamp-2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| randomtimestamp-2.3-py3-none-any.whl | Python 3 | none | any | Details for randomtimestamp-2.3-py3-none-any.whl |
Total release size: 25.3 kB
Release files / randomtimestamp-2.3.tar.gz
| Download URL | randomtimestamp-2.3.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1fd5fcfa41ebd2dc95add20085da1d9345c213c42d2ad37e7a20ca5e9d98e33
|
|
BLAKE2b-256 checksum How to use checksums |
f58d96e2bff2cefcc80abc247b3876f4173798c6fbc4fdd445d8bed464c639d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / randomtimestamp-2.3-py3-none-any.whl
| Download URL | randomtimestamp-2.3-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3890844ac6015be5ca8bed18ffe4614aca0641c9f339dcb6fd52e61115292718
|
|
BLAKE2b-256 checksum How to use checksums |
e1b5484699a1f62ddc38f512100d093c42b4d036549b1a59cea9d76a4e44e1c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Security for randomtimestamp 2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.