Registry / data / datetime-quarter

datetime-quarter

JSON →
library1.0.3pypypi✓ verified 84d ago

datetime-quarter is a simple and lightweight Python library that adds quarter-level support to standard `datetime` objects. It provides a `QuarterDateTime` class, allowing creation of objects representing a specific year and quarter, and methods to easily derive the start and end `datetime` for that quarter. The current version is 1.0.3, and it appears to have a stable but infrequent release cadence.

pip install datetime-quarter
INSTALL
IMPORT
SIG · DATETIME-QUARTER
D
datetime-quarter
datapythonv1.0.3
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DateQuarter
from datequarter import DateQuarter
from datetime_quarter import QuarterDateTime
quarter
from datequarter import quarter

Demonstrates creating `QuarterDateTime` objects from existing `datetime` objects or directly, and accessing its properties like year, quarter, and the start/end `datetime` of the quarter. Also shows basic comparison.

from datetime import datetime from datetime_quarter import QuarterDateTime # Create a QuarterDateTime object from a standard datetime dt_obj = datetime(2023, 7, 15) q_dt_from_dt = QuarterDateTime.from_datetime(dt_obj) print(f"From datetime {dt_obj}: Year={q_dt_from_dt.year}, Quarter={q_dt_from_dt.quarter}") print(f"Start of quarter: {q_dt_from_dt.start_of_quarter}") print(f"End of quarter: {q_dt_from_dt.end_of_quarter}") # Create a QuarterDateTime object directly with year and quarter q_dt_direct = QuarterDateTime(2024, 1) print(f"Directly created: {q_dt_direct}") print(f"Start of quarter: {q_dt_direct.start_of_quarter}") # Perform comparisons print(f"Is 2023Q1 before 2023Q2? {QuarterDateTime(2023, 1) < QuarterDateTime(2023, 2)}")
Debug
Known issues
gotchaThe `QuarterDateTime` object does not inherit directly from `datetime` and thus lacks many standard `datetime` attributes and methods (e.g., `day`, `hour`, `strftime`). It represents a quarter, not a specific point in time.
fix
Use `.start_of_quarter` or `.end_of_quarter` methods to get a standard `datetime` object if you need fine-grained date/time manipulation or formatting.
affects: All versions
gotchaWhen creating `QuarterDateTime` from a `datetime` object using `QuarterDateTime.from_datetime()`, the quarter is determined solely by the month of the input `datetime`. The day or time components are ignored.
fix
This is by design. Ensure your logic correctly accounts for quarter definition based on month boundaries.
affects: All versions
Upgrade
Version history
1.0.3latest on PyPI · released Feb 9, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
datetime-quarter — pip install datetime-quarter · libregistry