Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

emiTime

The emiTime library is designed to simplify the work with objects describing calendar time points and intervals between them. All algorithms presented in the library are based on two entities Moment and Inerval. Each of them can be fired from anything that looks like a calendar time point or a time interval.

Installation

pip install emitime

Or from GitHub

git clone https://github.com/rilshok/emitime.git
cd emitime
pip install -e .

Usage

A Moment object can be created by a str, datetime module objects such as date and datetime, or another Moment. In turn, Interval can also be derived from a str, datetime.time or another Interval.

import datetime as dt

from emitime import Moment

d1 = Moment("1970-01-01")
d2 = Moment(dt.datetime(1970, 1, 1))
d3 = Moment(dt.date(1970, 1, 1))
d4 = Moment(d3)

print(f"{d1=}, {d2=}, {d3=}, {d4=}")
print(f"{d1 == d2 == d3 == d4 = }")
d1=1970-01-01, d2=1970-01-01, d3=1970-01-01, d4=1970-01-01
d1 == d2 == d3 == d4 = True
import datetime as dt

from emitime import Interval

t1 = Interval("2d")
t2 = Interval("12:00")
t3 = Interval(dt.timedelta(hours=5))
t4 = Interval(t3)

print(f"{t1=}, {t2=}, {t3=}, {t4=}")
print(f"{t1 > t2 > t3 >= t4 = }")
t1=+2^00:00, t2=+12:00, t3=+05:00, t4=+05:00
t1 > t2 > t3 >= t4 = True

Moment and Interval can participate in natural mathematical operations and be compared with each other. Also, whenever possible, depending on the context, emiTime promotes the type of one of the operands of the operation to Moment or Interval

import datetime as dt

from emitime import Interval, Moment

m1 = Moment("1970-01-01") + "2d"
m2 = dt.timedelta(hours=5) + Moment("01.01.1970")
m3 = "1970-01-01" + Interval("12:00")

i1 = Moment("2020-01-01") - "2019-01-01"
i2 = "12:00" - Interval("1d")
i3 = dt.date(2021, 1, 1) - Moment("2020-01-01")

print(f"{m1=}, {m2=}, {m3=}")
print(f"{i1=}, {i2=}, {i3=}")
print(f"{m1 > m2=}")
print(f"{m2 < m3 <= m1 =}")
print(f"{m3+i2 == m1 - i3+i1 - i3+i1 = }")
m1=1970-01-03, m2=1970-01-01d05:00, m3=1970-01-01d12:00
i1=+365^00:00, i2=-12:00, i3=+366^00:00
m1 > m2=True
m2 < m3 <= m1 =True
m3+i2 == m1 - i3+i1 - i3+i1 = True

Moment is based on the standard datetime.datetime and Interval is based on datetime.timedelta. Which can be accessed as follows.

from emitime import Interval, Moment

m = Moment("1970-01-01")
i = Interval("02:10")
mdt = m.datetime
itd = i.timedelta

print(f"{mdt = }")
print(f"{itd = }")
mdt = datetime.datetime(1970, 1, 1, 0, 0)
itd = datetime.timedelta(seconds=7800)

Emit and enjoy.

Metadata

Release files for emitime 0.2.13

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

Source distribution (sdist)

Source distribution for emitime 0.2.13
File Size Uploaded Provenance Actions
emitime-0.2.13.tar.gz 9.8 kB Without provenance Details for emitime-0.2.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for emitime 0.2.13
File Interpreter ABI Platform Actions
emitime-0.2.13-py3-none-any.whl Python 3 none any Details for emitime-0.2.13-py3-none-any.whl

Total release size: 20.2 kB

Release files / emitime-0.2.13.tar.gz

Download URL emitime-0.2.13.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
df8542c0bc5a352644ab7b8f9183360a2cfccf13b27f5bb75ebe11ed5977ed7b
BLAKE2b-256 checksum
How to use checksums
6d8b7f0b6fd314eac066d324cd272e9b19dbb0b9db9555640b5d135dba6abbbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.13

Release files / emitime-0.2.13-py3-none-any.whl

Download URL emitime-0.2.13-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a881e8c0c61a44095a20403f57ed2349a103c80ccb5073e3ce46041c66fb9e1f
BLAKE2b-256 checksum
How to use checksums
74a84a048bc9a767bee18e7ec94b917c0d84a7bceddffe7811e0d93b51de213b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.13

Security for emitime 0.2.13

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