Skip to main content
Python-MomentX
==============

[![Travis CI](https://travis-ci.org/berlincode/momentx.svg?branch=master&style=flat)](https://travis-ci.org/berlincode/momentx)
[![Python versions](https://img.shields.io/pypi/pyversions/momentx.svg)](https://pypi.python.org/pypi/momentx/)
[![new-style BSD](https://img.shields.io/pypi/l/momentx.svg)](https://github.com/berlincode/momentx/blob/master/LICENSE.txt)


A lightweight wrapper around datetime with a focus on timezone handling and
few dependencies (only datetime, pytz and six).

Provides a immutable date/time type that always has an attached timezone.

This module was originally derived from the [moment module](https://github.com/zachwill/moment)
by Zach Williams. Following the main differences:

* MomentX dates always contain a timezone
* comparison made easy because all MomentX objects are timezone-offset-aware
* strptime with timezone support (%z)
* MomentX objects are immutable (add(), replace(), etc does not alter the object)
* api methods were converted to @classmethod
* zero() is now a method and not a property
* python3 support
* removed js like date formatting options and 'times' dependency

Typical usage may look like this:
```

>>> from momentx import MomentX
>>>
>>> MomentX.utc(2012, 12, 18)
<Moment(2012-12-18 00:00:00+0000 / UTC)>
>>>
>>> MomentX(2012, 12, 18, timezone="UTC")
<Moment(2012-12-18 00:00:00+0000 / UTC)>
>>>
>>> MomentX(2012, 12, 18, timezone="Europe/Berlin")
<Moment(2012-12-18 00:00:00+0100 / Europe/Berlin)>
>>>
>>> MomentX(2012, 12, 18, timezone="Europe/Berlin").astimezone("UTC")
<Moment(2012-12-17 23:00:00+0000 / UTC)>
>>>
>>> MomentX(2012, 12, 18, 10, 11, 12, timezone="UTC").replace(hours=3)
<Moment(2012-12-18 03:11:12+0000 / UTC)>
>>>
>>> MomentX(2012, 12, 18, 10, 11, 12, timezone="UTC").zero()
<Moment(2012-12-18 00:00:00+0000 / UTC)>
>>>
>>> MomentX.utc(2012, 12, 18).add(days=2)
<Moment(2012-12-20 00:00:00+0000 / UTC)>
>>>
>>> MomentX.utcnow()
<Moment(2016-05-17 18:30:40+0000 / UTC)>
>>>
>>> MomentX.utcnow().strftime('%Y-%m-%d %H:%M:%S%z')
'2016-05-17 18:31:20+0000'

```

Public repository
-----------------

https://github.com/berlincode/momentx


License
-------

Code and documentation copyright Ulf Bartel. Code is licensed under the
[new-style BSD license](./LICENSE.txt).



v0.1.0, 2016-05-17 -- Initial public release.
v0.2.0, 2017-08-26 -- added epoch seconds as possible input for momentx(), fix division, added tests, cleanup

Release files for momentx 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for momentx 0.2.3
File Size Uploaded
momentx-0.2.3.tar.gz 7.3 kB Details

Release files / momentx-0.2.3.tar.gz

Download URL momentx-0.2.3.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
036768814c6dc30503f37a7c3a76276ce90bebe23d06e72d7313ae7bfc39e233
BLAKE2b-256 checksum
How to use checksums
36d3d412998167aaf5ccf2a18f51211c67b0fdaded04b3846eab013b1c9eec60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.3 This release

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page