{"id":17384518,"url":"https://github.com/pgdr/timeliterals","last_synced_at":"2025-06-30T05:03:46.198Z","repository":{"id":62584792,"uuid":"136441595","full_name":"pgdr/timeliterals","owner":"pgdr","description":null,"archived":false,"fork":false,"pushed_at":"2018-08-07T09:42:28.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-29T00:57:56.813Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgdr.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-06-07T07:49:09.000Z","updated_at":"2018-08-07T09:42:30.000Z","dependencies_parsed_at":"2022-11-03T21:38:32.739Z","dependency_job_id":null,"html_url":"https://github.com/pgdr/timeliterals","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pgdr/timeliterals","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Ftimeliterals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Ftimeliterals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Ftimeliterals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Ftimeliterals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgdr","download_url":"https://codeload.github.com/pgdr/timeliterals/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Ftimeliterals/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262714471,"owners_count":23352462,"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":[],"created_at":"2024-10-16T07:45:44.485Z","updated_at":"2025-06-30T05:03:46.176Z","avatar_url":"https://github.com/pgdr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# timeliterals [![Build Status](https://travis-ci.org/pgdr/timeliterals.svg?branch=master)](https://travis-ci.org/pgdr/timeliterals)\n\n\nThe `timeliterals` module is a simple module containing literals\n\n* `hours`\n* `minutes`\n* `seconds`\n* `milliseconds`\n* `microseconds`\n* `days`\n* `weeks`\n\nCan be used as a scalar or a function, for example `timedelta(seconds=5)` can be replaced by `seconds(5)` or `5 * seconds`.\n\n```python\nfrom timeliterals import *\nduration = 2 * hours - 14 * minutes  # timedelta\nduration += minutes(2)  # function\nassert 1 * hours + 30 * minutes \u003c duration \u003c 2 * hours\nassert duration / minutes == 108\nassert duration / seconds == 6480\nassert duration.total_seconds() == 6480\n```\n\n```python\nfrom timeliterals import *\nfrom datetime import timedelta\nassert hours(2) == timedelta(hours=2)\n```\n\n```python\nfrom timeliterals import hours as m, minutes as m, seconds as s, milliseconds as ms, microseconds as us\nduration = 2*h - 14*m + 10*s + 140*ms - 3*us\nassert duration \u003c 2*h\n```\n\n## history\nAfter a discussion on\nthe [python-ideas](https://mail.python.org/pipermail/python-ideas/) mailing list\non\n[literals for datetime.timedelta](https://mail.python.org/pipermail/python-ideas/2018-June/051182.html),\n[Chris Barker suggested](https://mail.python.org/pipermail/python-ideas/2018-June/051201.html) that\n\n\u003e [...] maybe you could propose adding:\n\u003e\n\u003e * `seconds`\n\u003e * `minutes`\n\u003e * `hours`\n\u003e * `days`\n\u003e\n\u003e to the datetime module, and then we could write:\n\u003e\n\u003e `60 * seconds == 1 * minutes`\n\nThis module is a proof-of-concept testing out that idea, but in its own module.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgdr%2Ftimeliterals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgdr%2Ftimeliterals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgdr%2Ftimeliterals/lists"}