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
Hashes for cs.dateutils-20230210-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfeabf1700b480c5c8a46eeb3c74786174606515ca31737041b20f794a60348f |
|
MD5 | 4af302a1ca3930cc50471edb586523b1 |
|
BLAKE2b-256 | 4c719aadbc5fc475a4d88750ec1e12d8280ad09288b3def60c796250b56adf2e |