Skip to main content

django-chrono

django-chrono is a helper class for date and time operations in Django projects.

Usage Examples

1. String ↔ Datetime

from django_chrono import ChronoUtils

dt = ChronoUtils.str_to_datetime("2025-06-07 16:30:00")
dt_str = ChronoUtils.datetime_to_str(dt, fmt="%d.%m.%Y %H:%M")
# Result: '07.06.2025 16:30'

2. Date ↔ Datetime

import datetime
from django_chrono import ChronoUtils

d = datetime.date(2025, 6, 7)
dt = ChronoUtils.date_to_datetime(d)  # 2025-06-07 00:00:00
d2 = ChronoUtils.datetime_to_date(dt) # 2025-06-07

3. Timestamps

dt = ChronoUtils.timestamp_to_datetime(1759991100)
ts = ChronoUtils.datetime_to_timestamp(dt)

4. Time Zone Conversion

import pytz
from django.utils import timezone

dt = ChronoUtils.str_to_datetime("2025-06-07 12:00:00", tz=pytz.timezone('Europe/Sofia'))
dt_utc = ChronoUtils.to_utc(dt)            # Convert to UTC
dt_local = ChronoUtils.from_utc(dt_utc, pytz.timezone('Europe/Sofia'))  # Convert back

5. ISO Format

dt = ChronoUtils.parse_iso("2025-06-07T14:15:00")
iso_str = ChronoUtils.to_iso(dt)

6. Day/Week Boundaries

today = datetime.date.today()
start_day, end_day = ChronoUtils.get_day_bounds(today)
start_week, end_week = ChronoUtils.get_week_bounds(today, start_of_week=0)  # Monday

7. Add/Subtract Weeks, Months, Years

from django_chrono import ChronoUtils

dt = datetime.date(2025, 6, 7)
dt_plus_2w = ChronoUtils.add_weeks(dt, 2)   # +2 weeks
dt_minus_1m = ChronoUtils.sub_months(dt, 1) # -1 month
dt_plus_3y = ChronoUtils.add_years(dt, 3)   # +3 years

8. Calculate Difference

d1 = datetime.date(2024, 6, 7)
d2 = datetime.date(2025, 6, 7)
w_diff = ChronoUtils.diff_in_weeks(d2, d1)    # 52
m_diff = ChronoUtils.diff_in_months(d2, d1)   # 12
y_diff = ChronoUtils.diff_in_years(d2, d1)    # 1

Metadata

Release files for django-chrono 0.1.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 django-chrono 0.1.2
File Size Uploaded Provenance Actions
django_chrono-0.1.2.tar.gz 4.0 kB Without provenance Details for django_chrono-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-chrono 0.1.2
File Interpreter ABI Platform Actions
django_chrono-0.1.2-py3-none-any.whl Python 3 none any Details for django_chrono-0.1.2-py3-none-any.whl

Total release size: 8.9 kB

Release files / django_chrono-0.1.2.tar.gz

Download URL django_chrono-0.1.2.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2c2ba3d4baad57907a4326d70ee8b8eee408509891a85c829eec15a7d4be9b03
BLAKE2b-256 checksum
How to use checksums
f9c18f9a13cc28f4d8e3a765f6e9729565ae205628518530d9d7ad1f1e2685df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release files / django_chrono-0.1.2-py3-none-any.whl

Download URL django_chrono-0.1.2-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b16346cbc8787b4b6b1f854d071ef37aa896f7bf0a5fd39e58fb556bfce93fc
BLAKE2b-256 checksum
How to use checksums
0d14f069afe2d4c538ffe8ef2efd7327c7616825c36ab5cc954c88b0cc62478b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Security for django-chrono 0.1.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