cs-dateutils


Namecs-dateutils JSON
Version 20250724 PyPI version JSON
download
home_pageNone
SummaryA few conveniences to do with dates and times.
upload_time2025-07-24 02:14:14
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords date time datetime python python3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            A few conveniences to do with dates and times.

*Latest release 20250724*:
* unixtime2datetime: default tz now UTC.
* Some doc updates.

There are some other PyPI modules providing richer date handling
than the stdlib `datetime` module.
This module mostly contains conveniences used in my other code;
you're welcome to it, but it does not pretend to be large or complete.

Short summary:
* `datetime2unixtime`: Convert a timezone aware `datetime` to a UNIX timestamp. *WARNING*: a naive datetime is assumed to be in UTC.
* `isodate`: Return a date in ISO8601 YYYY-MM-DD format, or YYYYMMDD if not `dashed`.
* `localdate2unixtime`: Convert a localtime `date` into a UNIX timestamp.
* `tzinfoHHMM`: tzinfo class based on +HHMM / -HHMM strings.
* `unixtime2datetime`: Convert a a UNIX timestamp to a `datetime` in the timezone `tz`. *Note*: the default timezone is UTC, not the local timezone.
* `UNIXTimeMixin`: A mixin for classes with a `.unixtime` attribute, a `float` storing a UNIX timestamp.

Module contents:
- <a name="datetime2unixtime"></a>`datetime2unixtime(dt)`: Convert a timezone aware `datetime` to a UNIX timestamp.
  *WARNING*: a naive datetime is assumed to be in UTC.
- <a name="isodate"></a>`isodate(when=None, dashed=True)`: Return a date in ISO8601 YYYY-MM-DD format, or YYYYMMDD if not `dashed`.

  Modern Pythons have a `datetime.isoformat` method, you should use that.
- <a name="localdate2unixtime"></a>`localdate2unixtime(d)`: Convert a localtime `date` into a UNIX timestamp.
- <a name="tzinfoHHMM"></a>`class tzinfoHHMM(datetime.tzinfo)`: tzinfo class based on +HHMM / -HHMM strings.
- <a name="unixtime2datetime"></a>`unixtime2datetime(unixtime, *, tz: datetime.tzinfo = datetime.timezone.utc)`: Convert a a UNIX timestamp to a `datetime` in the timezone `tz`.
  *Note*: the default timezone is UTC, not the local timezone.
- <a name="UNIXTimeMixin"></a>`class UNIXTimeMixin`: A mixin for classes with a `.unixtime` attribute,
  a `float` storing a UNIX timestamp.

*`UNIXTimeMixin.as_datetime(self, tz: datetime.tzinfo = datetime.timezone.utc)`*:
Return `self.unixtime` as a `datetime`
with the timezone `tz` (default `UTC`).

*`UNIXTimeMixin.datetime`*:
The `unixtime` as a UTC `datetime`.

# Release Log



*Release 20250724*:
* unixtime2datetime: default tz now UTC.
* Some doc updates.

*Release 20230210*:
* Drop Python 2 support.
* Make timezones mandatory where previously they were assumed.

*Release 20210306*:
Initial release, used by cs.sqltags.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cs-dateutils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "date, time, datetime, python, python3",
    "author": null,
    "author_email": "Cameron Simpson <cs@cskk.id.au>",
    "download_url": "https://files.pythonhosted.org/packages/50/09/1aeb4969c31c54452419e408d3607bc03e29df043449f30d8d099d649598/cs_dateutils-20250724.tar.gz",
    "platform": null,
    "description": "A few conveniences to do with dates and times.\n\n*Latest release 20250724*:\n* unixtime2datetime: default tz now UTC.\n* Some doc updates.\n\nThere are some other PyPI modules providing richer date handling\nthan the stdlib `datetime` module.\nThis module mostly contains conveniences used in my other code;\nyou're welcome to it, but it does not pretend to be large or complete.\n\nShort summary:\n* `datetime2unixtime`: Convert a timezone aware `datetime` to a UNIX timestamp. *WARNING*: a naive datetime is assumed to be in UTC.\n* `isodate`: Return a date in ISO8601 YYYY-MM-DD format, or YYYYMMDD if not `dashed`.\n* `localdate2unixtime`: Convert a localtime `date` into a UNIX timestamp.\n* `tzinfoHHMM`: tzinfo class based on +HHMM / -HHMM strings.\n* `unixtime2datetime`: Convert a a UNIX timestamp to a `datetime` in the timezone `tz`. *Note*: the default timezone is UTC, not the local timezone.\n* `UNIXTimeMixin`: A mixin for classes with a `.unixtime` attribute, a `float` storing a UNIX timestamp.\n\nModule contents:\n- <a name=\"datetime2unixtime\"></a>`datetime2unixtime(dt)`: Convert a timezone aware `datetime` to a UNIX timestamp.\n  *WARNING*: a naive datetime is assumed to be in UTC.\n- <a name=\"isodate\"></a>`isodate(when=None, dashed=True)`: Return a date in ISO8601 YYYY-MM-DD format, or YYYYMMDD if not `dashed`.\n\n  Modern Pythons have a `datetime.isoformat` method, you should use that.\n- <a name=\"localdate2unixtime\"></a>`localdate2unixtime(d)`: Convert a localtime `date` into a UNIX timestamp.\n- <a name=\"tzinfoHHMM\"></a>`class tzinfoHHMM(datetime.tzinfo)`: tzinfo class based on +HHMM / -HHMM strings.\n- <a name=\"unixtime2datetime\"></a>`unixtime2datetime(unixtime, *, tz: datetime.tzinfo = datetime.timezone.utc)`: Convert a a UNIX timestamp to a `datetime` in the timezone `tz`.\n  *Note*: the default timezone is UTC, not the local timezone.\n- <a name=\"UNIXTimeMixin\"></a>`class UNIXTimeMixin`: A mixin for classes with a `.unixtime` attribute,\n  a `float` storing a UNIX timestamp.\n\n*`UNIXTimeMixin.as_datetime(self, tz: datetime.tzinfo = datetime.timezone.utc)`*:\nReturn `self.unixtime` as a `datetime`\nwith the timezone `tz` (default `UTC`).\n\n*`UNIXTimeMixin.datetime`*:\nThe `unixtime` as a UTC `datetime`.\n\n# Release Log\n\n\n\n*Release 20250724*:\n* unixtime2datetime: default tz now UTC.\n* Some doc updates.\n\n*Release 20230210*:\n* Drop Python 2 support.\n* Make timezones mandatory where previously they were assumed.\n\n*Release 20210306*:\nInitial release, used by cs.sqltags.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A few conveniences to do with dates and times.",
    "version": "20250724",
    "project_urls": {
        "MonoRepo Commits": "https://bitbucket.org/cameron_simpson/css/commits/branch/main",
        "Monorepo Git Mirror": "https://github.com/cameron-simpson/css",
        "Monorepo Hg/Mercurial Mirror": "https://hg.sr.ht/~cameron-simpson/css",
        "Source": "https://github.com/cameron-simpson/css/blob/main/lib/python/cs/dateutils.py"
    },
    "split_keywords": [
        "date",
        " time",
        " datetime",
        " python",
        " python3"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "565e420e5a7d0667386082e84b53f570b57644d4083942207309bc5e1e65d724",
                "md5": "5fcca5ab353cfe42b2eaa5d47a1e83a3",
                "sha256": "b35fe82c6ff04418730b4795679c254f9744c58051cfcd3e942d410882d8bbb6"
            },
            "downloads": -1,
            "filename": "cs_dateutils-20250724-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5fcca5ab353cfe42b2eaa5d47a1e83a3",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 3600,
            "upload_time": "2025-07-24T02:14:12",
            "upload_time_iso_8601": "2025-07-24T02:14:12.707280Z",
            "url": "https://files.pythonhosted.org/packages/56/5e/420e5a7d0667386082e84b53f570b57644d4083942207309bc5e1e65d724/cs_dateutils-20250724-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "50091aeb4969c31c54452419e408d3607bc03e29df043449f30d8d099d649598",
                "md5": "564a245e2290b3fb8f70098d56f2b36a",
                "sha256": "7b9ebdcdd03044aba4a55ec772c602447d8a7249a111d746f3b61e25b818a0a5"
            },
            "downloads": -1,
            "filename": "cs_dateutils-20250724.tar.gz",
            "has_sig": false,
            "md5_digest": "564a245e2290b3fb8f70098d56f2b36a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 2898,
            "upload_time": "2025-07-24T02:14:14",
            "upload_time_iso_8601": "2025-07-24T02:14:14.059080Z",
            "url": "https://files.pythonhosted.org/packages/50/09/1aeb4969c31c54452419e408d3607bc03e29df043449f30d8d099d649598/cs_dateutils-20250724.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-24 02:14:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cameron-simpson",
    "github_project": "css",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cs-dateutils"
}
        
Elapsed time: 0.60140s