Skip to main content

A few conveniences to do with dates and times.

Latest release 20210306: Initial release, used by cs.sqltags.

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 datetime to a UNIX timestamp.

Note: unlike datetime.timestamp, if the datetime is naive it is presumed to be in UTC rather than the local timezone.

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, 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=None)

Convert a a UNIX timestamp to a datetime.

Note: unlike datetime.fromtimestamp, if tz is None the UTC timezone is used.

Class UNIXTimeMixin

A mixin for classes with a .unixtime attribute, a float storing a UNIX timestamp.

Method UNIXTimeMixin.as_datetime(self, tz=None)

Return self.unixtime as a datetime with the timezone tz.

Note: unlike datetime.fromtimestamp, if tz is None the UTC timezone is used.

Property UNIXTimeMixin.datetime

The unixtime as a UTC datetime.

Release Log

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

Metadata

Release files for cs-dateutils 20210306

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cs-dateutils 20210306
File Size Uploaded Provenance
cs.dateutils-20210306.tar.gz 3.4 kB Without provenance Details

Release files / cs.dateutils-20210306.tar.gz

Download URL cs.dateutils-20210306.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
535705c2b4ae2fec629e767fb6f14fc40f728a6a88f9f4e1bb61135cad2a4869
BLAKE2b-256 checksum
How to use checksums
976cf4cc1b91747252c131797b33833ac104d63f9cd674c0f0ad993bc1c5c2ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.2

Security for cs-dateutils 20210306

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page