Skip to main content

sometime

Get timestamp, formatted date, and perform date/time operations.

Official Release

Sometime v1.2.0

pip install sometime -U

Basic Usage

from sometime import Sometime
# Default initialization
ts = Sometime()

# Custom initialization
ts = Sometime(1650614778, utc=True)

# Set timestamp in seconds
ts.timestamp(seconds)
ts["timestamp"] = seconds

# Set date/time based on date/time string
# https://help.gnome.org/users/gthumb/stable/gthumb-date-formats.html.en"
ts.from_iso("2022-04-22", "%Y-%m-%d")
print("Timestamp:", ts.timestamp())

Get Unix Timestamp

print("Timestamp:", ts.timestamp())

Get current Unix Timestamp

print("Current Timestamp:", ts.now())

Add or subtract years

ts = Sometime(seconds)
ts.year(years=-25)
ts.year(years=100)
print("Year:", ts.year())
print("Year:", ts["%Y"])

Get name of the month

ts = Sometime(seconds)
ts.name_of_month()
print("Date of the Month:", ts.name_of_month())

Add or subtract months

ts = Sometime(seconds)
ts.month(months=-1)
ts.month(months=12)
print("Month:", ts.month())

Add or subtract days

ts = Sometime(seconds)
ts.day(days=-7)
ts.day(days=14)
print("Day:", ts.day())

Add or subtract hours

ts = Sometime(seconds)
ts.hour(hours=-8)
ts.hour(hours=24)
hour = ts.hour()
print("Hour:", ts.hour())

Add or subtract minutes

ts = Sometime(seconds)
ts.minute(minutes=-5)
ts.minute(minutes=30)
minute = ts.minute()
print("Minute:", ts.minute())

Add or subtract seconds

ts = Sometime(seconds)
ts.second(seconds=-1)
ts.second(seconds=30)
second = ts.second()
print("Second:", ts.second())

Get if AM/PM

ts = Sometime(seconds)
ts.period()
print("Period:", ts.period())

Get the Day of the Week

ts = Sometime(seconds)
print("Day of the Week:", ts.day_of_week())

Add or subtract to date/time

ts = Sometime(seconds)
print("Timestamp:", ts.timestamp())
ts.add(years=1, months=2, days=3, hours=4, minutes=5, seconds=6)
print("Timestamp:", ts.timestamp())

Format date/time into string representation

ts = Sometime(seconds)
print("Timestamp:", ts.custom("%Y-%m-%d %H:%M:%S %p"))

Get yesterday's on custom formatting

ts = Sometime(seconds)
print("Yesterday:", ts.yesterday("%Y-%m-%d %H:%M:%S %p"))

Metadata

Release files for sometime 1.2.2

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

Source distribution (sdist)

Source distribution for sometime 1.2.2
File Size Uploaded Provenance Actions
sometime-1.2.2.tar.gz 3.4 kB Without provenance Details for sometime-1.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 7.5 kB

Release files / sometime-1.2.2.tar.gz

Download URL sometime-1.2.2.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
52e3869ca3aa31e1566e65058992bd8cca66fd3cb416f052b6761acea6b0fc15
BLAKE2b-256 checksum
How to use checksums
933c49f636b7856cf2d90c429e5d838f64feaa609e4cf4a9f5b8edf71674ddbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.0

Release files / sometime-1.2.2-py3-none-any.whl

Download URL sometime-1.2.2-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6a19431b62df6c7320fe01589571a96e86c95f9073e508c17d0bf759b9797e6
BLAKE2b-256 checksum
How to use checksums
76eeb0c9cefe512190caecd99aab9296cb337670b604ea670f8bbeb21896bd98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.0

Security for sometime 1.2.2

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