datetime-quarter
Simple quarter support for python datetime.date
Setup
- Install via pip (
pip install datetime-quarter) - or via git (
git clone "https://github.com/BetaS/datetime-quarter") - Check availability in your project like below
from datequarter import DateQuarter
sample = DateQuarter(2019, 4)
print(sample) # 2019 4Q
Operations
1. Creation
item = DateQuarter(2019, 4) # 2019 4Qitem = DateQuarter(2018, 8) # 2019 4Qfor convinienceitem = DateQuarter.from_date(datetime.date(2019, 12, 31)) # 2019 4Q
2. Adding or sub quarter
DateQuarter(2019, 4)+1 # 2020 1QDateQuarter(2019, 4)-4 # 2018 4Q
3. Getting distance
DateQuarter(2019, 4) - DateQuarter(2019, 1) # 3QDateQuarter(2019, 1) - DateQuarter(2019, 4) # -3Q
4. Comparison of DateQuarter
DateQuarter(2019, 1) > DateQuarter(2019, 4) # FalseDateQuarter(2019, 1) < DateQuarter(2019, 4) # TrueDateQuarter(2019, 1) == DateQuarter(2019, 4) # FalseDateQuarter(2019, 1) != DateQuarter(2019, 4) # True- also support
>=and<=
5. Comparison of datetime.date
datetime.date(2019, 12, 31) in DateQuarter(2019, 1) # Falsedatetime.date(2019, 12, 31) in DateQuarter(2019, 4) # True- also support
>,>=and vice versa
6. Getting start and end date
DateQuarter(2019, 1).start_date() # datetime.date(2019, 1, 1)DateQuarter(2019, 1).end_date() # datetime.date(2019, 3, 31)
7. Iterate over containing date
quarter = DateQuarter(2019, 1)
for day in quarter.days():
print(day) # [datetime.date(2019, 1, 1), ..., datetime.date(2019, 3, 31)]
8. Iterate between DateQuarter
start = DateQuarter(2019, 1)
end = DateQuarter(2019, 4)
for quarter in DateQuarter.between(start, end):
print(quarter) # [DateQuarter(2019, 1), DateQuarter(2019, 2) , DateQuarter(2019,3)]
- also it support reversed case
Metadata
Release files for datetime-quarter 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| datetime-quarter-1.0.3.tar.gz | 2.7 kB | Without provenance | Details for datetime-quarter-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| datetime_quarter-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for datetime_quarter-1.0.3-py3-none-any.whl |
Total release size: 6.6 kB
Release files / datetime-quarter-1.0.3.tar.gz
| Download URL | datetime-quarter-1.0.3.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86ac0e8c4483e6343df89443f26eaeedce3cff1cbafe700027a9d9a7c35abbd2
|
|
BLAKE2b-256 checksum How to use checksums |
507c3b95527669bddb18d5f44ae3ff4c23e734bbf5552851926a34e40b67fdeb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.1
|
Release files / datetime_quarter-1.0.3-py3-none-any.whl
| Download URL | datetime_quarter-1.0.3-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5d89d06175366d5e5693900ecd2e700e4dcd23705b91acd6bd123a65281787d
|
|
BLAKE2b-256 checksum How to use checksums |
a440d981eda9ede2f5d2a9a31b43d640836595a1679543c54103c71eaca61f9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.1
|
Security for datetime-quarter 1.0.3
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.