momentpy – A Python Date Manipulation Library (Laravel Moment Inspired)
momentpy is a Python library inspired by Laravel’s Moment, providing readable date/time manipulation with timezone support.
📦 Installation
pip install momentpy
Or locally:
git clone <your-repo>
cd momentpy
pip install .
🕰️ Importing
from momentpy import Moment
🕰️ Method Table (Quick Reference)
| Category | Method | Description |
|---|---|---|
| Constructors | Moment.now(tz=None) |
Current datetime |
| Constructors | Moment.today(tz=None) |
Today at 00:00 |
| Constructors | Moment.yesterday(tz=None) |
Yesterday at 00:00 |
| Constructors | Moment.tomorrow(tz=None) |
Tomorrow at 00:00 |
| Constructors | Moment.parse(date_str, fmt, tz) |
Parse string to Moment |
| Constructors | Moment.from_datetime(dt) |
Convert datetime to Moment |
| Formatting | format(fmt) |
Format datetime |
| Timezone | set_timezone(tz) |
Convert to timezone |
| Timezone | timezone_name() |
Get timezone name |
| Day | start_of_day() |
00:00:00 |
| Day | end_of_day() |
23:59:59.999999 |
| Week | start_of_week(week_start="monday") |
Start of week |
| Week | end_of_week(week_start="monday") |
End of week |
| Month | start_of_month() |
First day of month |
| Month | end_of_month() |
Last day of month |
| Year | start_of_year() |
First day of year |
| Year | end_of_year() |
Last day of year |
| Quarter | start_of_quarter() |
First day of quarter |
| Quarter | end_of_quarter() |
Last day of quarter |
| Relative | next(weekday) |
Next weekday |
| Relative | previous(weekday) |
Previous weekday |
| Relative | next_or_same(weekday) |
Next or same weekday |
| Relative | previous_or_same(weekday) |
Previous or same weekday |
| Manipulation | add_days(days) |
Add days |
| Manipulation | sub_days(days) |
Subtract days |
| Manipulation | add_hours(hours) |
Add hours |
| Manipulation | sub_hours(hours) |
Subtract hours |
| Manipulation | add_minutes(minutes) |
Add minutes |
| Manipulation | sub_minutes(minutes) |
Subtract minutes |
| Comparison | is_future() |
True if in future |
| Comparison | is_past() |
True if in past |
| Comparison | is_today() |
True if today |
| Comparison | is_yesterday() |
True if yesterday |
| Comparison | is_tomorrow() |
True if tomorrow |
| Human-readable | diff_for_humans(other) |
Human-readable diff |
📖 Example
from momentpy import Moment
now = Moment.now("UTC")
print("Start of week:", now.start_of_week())
print("End of quarter:", now.end_of_quarter())
print("Next Monday:", now.next("monday"))
print("Start of year:", now.start_of_year())
print("Difference:", now.diff_for_humans(Moment.parse("2025-01-01")))
Metadata
Release files for momentpy 0.1.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 | |
|---|---|---|---|
| momentpy-0.1.3.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| momentpy-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.6 kB
Release files / momentpy-0.1.3.tar.gz
| Download URL | momentpy-0.1.3.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9616b369b5ddc8c860a1b693c4ffdcae0b01f29a3554b52956293077f84baae4
|
|
BLAKE2b-256 checksum How to use checksums |
f9e88cdbf689948653a41f6327862db971e52a4a8fb7bbc3a020a17cbd144db7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.4
|
Release files / momentpy-0.1.3-py3-none-any.whl
| Download URL | momentpy-0.1.3-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c5e16033182c9545729ea4af560a8f50ad20da5bf81a303945c224408cfc3223
|
|
BLAKE2b-256 checksum How to use checksums |
2c855e315ec16f8358f5cd4c589fdaa3a164fbee010510ec55d24f270869e9ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.4
|