Skip to main content

A Carbon-like datetime library for Python inspired by Laravel's Carbon

Project description

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")))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

momentpy-0.1.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

momentpy-0.1.3-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file momentpy-0.1.3.tar.gz.

File metadata

  • Download URL: momentpy-0.1.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for momentpy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9616b369b5ddc8c860a1b693c4ffdcae0b01f29a3554b52956293077f84baae4
MD5 3ce631ec0d38845395c3eff38f4b31dc
BLAKE2b-256 f9e88cdbf689948653a41f6327862db971e52a4a8fb7bbc3a020a17cbd144db7

See more details on using hashes here.

File details

Details for the file momentpy-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: momentpy-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for momentpy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c5e16033182c9545729ea4af560a8f50ad20da5bf81a303945c224408cfc3223
MD5 59d52b46501bc2c3f023aed716da0ea0
BLAKE2b-256 2c855e315ec16f8358f5cd4c589fdaa3a164fbee010510ec55d24f270869e9ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page