datefun
Functional approach to date manipulations
Date is string. In ISO format (Y-M-D). Mostly it came from database.
Now we want some manipulations and return again ISO date as string.
Conversion functions:
- dt_make(year: int, month: int, day: int) -> str
- dt_from_object(obj: datetime) -> str
Date (string) output functions:
- dt_month_start(iso_date: str) -> str
- dt_month_end(iso_date: str) -> str
- dt_week_start(iso_date: str, week_start_monday: bool = True) -> str
- dt_week_end(iso_date: str, week_start_monday: bool = True) -> str
- dt_quarter_start(iso_date: str) -> str
- dt_quarter_end(iso_date: str) -> str
- dt_semiyear_start(iso_date: str) -> str
- dt_semiyear_end(iso_date: str) -> str
- dt_year_start(iso_date: str) -> str
- dt_year_end(iso_date: str) -> str
- dt_add_years(iso_date: str, many_years: int, interpret_0228_as_monthend: bool = True) -> str
- dt_add_months(iso_date: str, many_months: int, stay_in_month_end: bool = True) -> str
- dt_add_days(iso_date: str, many_days: int) -> str
- dt_easter(year: int) -> str
- dt_easter_gauss(year: int) -> str
- dt_good_friday(year: int) -> str
- dt_pentecost(year: int) -> str
- dt_add_week(iso_date: str, many_weeks: int) -> str
- dt_add_quarter(iso_date: str, many_quarters: int, stay_in_month_end: bool = True) -> str
- dt_add_semiyear(iso_date: str, many_semiyear: int, stay_in_month_end: bool = True) -> str
Boolean output functions:
- is_leap_year(year_or_date: int | str) -> bool
- is_valid_date(iso_date: str) -> bool
Integer output functions:
- int_days_in_month(iso_date: str) -> int
No external dependecies (only internals, eg. datetime)
Needs python 3.10 (because of type hints/annotations with pipes)
install
pip install datefun
(or pip3 or pipx)
usage
from datefun import datefun
print(datefun.dt_add_months("2025-02-28", -1)) # outputs 2025-01-31
print(datefun.dt_add_months("2025-02-28", 1, False)) # outputs 2025-03-28
or
from datefun.datefun import dt_add_months
print(dt_add_months("2025-02-28", -1)) # outputs 2025-01-31
print(dt_add_months("2025-02-28", 1, False)) # outputs 2025-03-28
Metadata
Release files for datefun 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| datefun-0.0.8-py3-none-any.whl | Python 3 | none | any | Details for datefun-0.0.8-py3-none-any.whl |
Release files / datefun-0.0.8-py3-none-any.whl
| Download URL | datefun-0.0.8-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2cf691ae85b2992bdaba144588ac71953a3ade497d90c8f30c6831982865e3c
|
|
BLAKE2b-256 checksum How to use checksums |
04cf040668c5bc6976135bb83a99198d9cf31582e041309c1991d2af8e98a766
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for datefun 0.0.8
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.