A few conveniences to do with dates and times.
Project description
A few conveniences to do with dates and times.
Latest release 20230210:
- Drop Python 2 support.
- Make timezones mandatory where previously they were assumed.
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.
Function datetime2unixtime(dt)
Convert a timezone aware datetime
to a UNIX timestamp.
Function 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 use that.
Function localdate2unixtime(d)
Convert a localtime date
into a UNIX timestamp.
Class tzinfoHHMM(datetime.tzinfo)
tzinfo class based on +HHMM / -HHMM strings.
Function unixtime2datetime(unixtime, *, tz: datetime.tzinfo)
Convert a a UNIX timestamp to a datetime
in the timezone tz
.
Class UNIXTimeMixin
A mixin for classes with a .unixtime
attribute,
a float
storing a UNIX timestamp.
Release Log
Release 20230210:
- Drop Python 2 support.
- Make timezones mandatory where previously they were assumed.
Release 20210306: Initial release, used by cs.sqltags.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cs.dateutils-20230210.tar.gz
.
File metadata
- Download URL: cs.dateutils-20230210.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7f2add547da96c0f885a9c6420b52296c22caf0cf77d950a817bdecf26a9e88 |
|
MD5 | f28b2933524ce04f36a9e6d4f03bed4a |
|
BLAKE2b-256 | 8897a11c57fe1a6bc9f060163f5a7ec538dd8571798a554650e8e1bab6a5b689 |
File details
Details for the file cs.dateutils-20230210-py3-none-any.whl
.
File metadata
- Download URL: cs.dateutils-20230210-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfeabf1700b480c5c8a46eeb3c74786174606515ca31737041b20f794a60348f |
|
MD5 | 4af302a1ca3930cc50471edb586523b1 |
|
BLAKE2b-256 | 4c719aadbc5fc475a4d88750ec1e12d8280ad09288b3def60c796250b56adf2e |