{"id":19429172,"url":"https://github.com/bytebaker/randomtimestamp","last_synced_at":"2025-04-24T18:32:12.700Z","repository":{"id":57459930,"uuid":"150586016","full_name":"ByteBaker/randomtimestamp","owner":"ByteBaker","description":"Files for the RandomTimeStamp module","archived":false,"fork":false,"pushed_at":"2023-03-28T17:02:19.000Z","size":38,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-10-05T22:47:24.005Z","etag":null,"topics":["datetime","python","random-time","timestamp"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/randomtimestamp/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ByteBaker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-27T12:49:29.000Z","updated_at":"2022-12-18T02:55:50.000Z","dependencies_parsed_at":"2022-08-30T17:10:37.178Z","dependency_job_id":null,"html_url":"https://github.com/ByteBaker/randomtimestamp","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteBaker%2Frandomtimestamp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteBaker%2Frandomtimestamp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteBaker%2Frandomtimestamp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteBaker%2Frandomtimestamp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ByteBaker","download_url":"https://codeload.github.com/ByteBaker/randomtimestamp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223961517,"owners_count":17232313,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datetime","python","random-time","timestamp"],"created_at":"2024-11-10T14:18:15.269Z","updated_at":"2024-11-10T14:18:16.547Z","avatar_url":"https://github.com/ByteBaker.png","language":"Python","readme":"![PyPI - Python Version](https://img.shields.io/pypi/pyversions/randomtimestamp?label=Python) ![PyPI - License](https://img.shields.io/pypi/l/randomtimestamp?label=License\u0026color=red) ![Maintenance](https://img.shields.io/maintenance/yes/2022?label=Maintained) ![PyPI](https://img.shields.io/pypi/v/randomtimestamp?label=PyPi) ![PyPI - Status](https://img.shields.io/pypi/status/randomtimestamp?label=Status) ![PyPI - Format](https://img.shields.io/pypi/format/randomtimestamp?label=Format) ![PyPI - Downloads](https://img.shields.io/pypi/dm/randomtimestamp?label=Downloads\u0026color=yellow) \n\n# randomtimestamp \u003csup\u003e (v2.2)\u003c/sup\u003e\nRandom timestamp generator\n## Installation\nYou know it:\n```\npip install randomtimestamp\n```\n## Usage\nrandomtimestamp can be used from the command line or imported as a python module.\n\n#### Command line usage\nTo use the script from command line\n```\n  $ randomtimestamp\n  30-08-1995 17:58:14\n```\n\n#### Python Module Usage\n\nIn v2.2, the functions **randomtimestamp**, **random_time**, and **random_date** are available.\n\n1.  **randomtimestamp()** takes six optional arguments. A call without arguments returns a datetime between **January 1st, 1950, 00:00:00** and **({today}, 23:59:59)**.\n\n **NOTE**: **start/end** are resolved before **start_year/end_year**, therefore **start_year/end_year** have no effect if **start/end** have been provided. \n **WARNING [breaking changes]** : Order of arguments to **randomtimestamp** has been changed in v2.1. If you're passing parameters as positionals, be careful before upgrading. The function also returns a *datetime* object rather than a string. \n```\nrandomtimestamp(\n    start_year: int = 1950,\n    end_year: int = None,\n    text: bool = False,\n    start: datetime.datetime = None,\n    end: datetime.datetime = None,\n    pattern: str = \"%d-%m-%Y %H:%M:%S\"\n    ) -\u003e Union[datetime, str]:\n```\n2.  **random_time()** takes four optional arguments. A call without arguments returns a time between **between (00:00:00)** and **(23:59:59)**.\n \n```\nrandom_time(\n    start: datetime.time = time.min,\n    end: datetime.time = time.max,\n    text: bool = False,\n    pattern: str = \"%H:%M:%S\"\n    ) -\u003e Union[time, str]:\n```\n3.  **random_date()** takes four optional arguments. A call without arguments returns a date between **(January 1, 1950)** and **today**.\n \n```\nrandom_date(\n    start: datetime.date = date(1950, 1, 1),\n    end: datetime.date = datetime.today().date(),\n    text: bool = False,\n    pattern: str = \"%d-%m-%Y\"\n    ) -\u003e Union[date, str]:\n```\nIn any of these function calls, **start \u003c end** \u0026 **start_year \u003c end_year** is mandatory. **pattern** has no effect if **text = False**.\n\n---\n\n## Changelog:\n\n##### v2.2\n- Fixed microsecond handling bug in datetime range. Closes [issue](https://github.com/ByteBaker/ubuntu21-btfix/issues/1).\n##### v2.1 \n- Dropped a minor version identifier to account for the small size of module. Only 2 digits to be used hereafter.\n- [Breaking change] Order of arguments to randomtimestamp() changed. Code using older versions without keyword arguments breaks.\n- [Breaking change] By default **randomtimestamp()** now generates datetime objects. **text = False** by default.\n- Introduced **random_time() \u0026 random_date()** to generate only time or date if needed.\n##### v2.0.0\n- Ability to provide **start/end** as datetime objects to randomtimestamp() for more precise control.\n- Lower limit of **start_year = 1950** removed.\n- Ability to use custom datetime pattern as described in [datetime documentation](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes).\n##### v1.0.0\n- Randomtimestamp released. Timestamps can be generated between 1950 and current_year.\n- The timestamp can be generated as a string (by default) or a datetime object.\n\n---\n\n\n## Examples:\nHere are some examples of the possible syntaxes:\n```\n  \u003e\u003e\u003e from randomtimestamp import randomtimestamp, random_date, random_time\n\n  \u003e\u003e\u003e randomtimestamp()\n  datetime.datetime(1970, 6, 2, 23, 34, 10)\n\n  \u003e\u003e\u003e randomtimestamp(start_year=2020, end_year=2021)\n  datetime.datetime(2021, 1, 10, 5, 6, 19)\n\n  \u003e\u003e\u003e randomtimestamp(start_year=2020, end_year=2021, text=True)\n  '05-09-2021 17:24:28'\n\n  \u003e\u003e\u003e random_time()\n  datetime.time(13, 18, 14)\n\n  \u003e\u003e\u003e random_date()\n  datetime.date(1990, 6, 13)\n  \n  \u003e\u003e\u003e random_time(text=True, pattern='%I:%M:%S %p')\n  '08:06:27 PM'\n```\nIn any case, if you ever feel stuck, use **help(randomtimestamp)** inside Python's REPL. \n\n---\n\n#### Footnote:\nType 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**.\n\nHowever, if you do find a bug, please report to make the experience better for other developers.\n\n\n## License\nThis project is released under [GNU GENERAL PUBLIC LICENSE V3](https://www.gnu.org/licenses/gpl-3.0.en.html).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytebaker%2Frandomtimestamp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytebaker%2Frandomtimestamp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytebaker%2Frandomtimestamp/lists"}