Registry / data / maya
library0.6.1pypypi✓ verified 22d ago

Maya is a Python library designed to make working with datetimes significantly easier and more intuitive. It wraps Python's built-in `datetime` module, providing a human-friendly API that simplifies common tasks such as parsing diverse date strings, handling timezones, and converting between various time representations. It aims to eliminate common pitfalls like distinguishing between naive and aware datetimes. The current version is 0.6.1, and while releases are infrequent, the project is actively maintained to address user issues.

pip install maya
INSTALL
IMPORT
SIG · MAYA
M
maya
datapythonv0.6.1
Install
4.2s avg
Import
1046ms
Disk
33MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.074s · 35.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.2s · import 1.018s · 36MB
33MB installed
● package 33MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

maya
import maya

This quickstart demonstrates how to get the current time, parse human-readable date strings, convert datetimes to specific timezones, and generate time intervals using the `maya` library. It showcases the core functionalities of `maya.now()`, `maya.parse()`, `MayaDT.datetime()`, and `maya.intervals()`.

import maya # Get the current time now = maya.now() print(f"Current time: {now}") # Parse anything date_obj = maya.parse("tomorrow") print(f"'Tomorrow' parsed: {date_obj.slang_date()}, {date_obj.slang_time()}") # Convert to a specific timezone la_time = now.datetime(to_timezone="America/Los_Angeles") print(f"Current time in LA: {la_time}") # Generate time intervals start = maya.when("2024-01-01") end = maya.when("2024-01-03") print("Days in interval:") for day in maya.intervals(start=start, end=end, interval=60*60*24): print(f"- {day.slang_date()}")
Debug
Known issues
gotchaWhen parsing imprecise dates (e.g., `maya.when('tomorrow')` or '2024-01-15'), Maya typically returns a `MayaDT` object representing 00:00:00 of that day. This may not align with a user's expectation of representing a full day or a time-of-day relative to the current moment.
fix
Be explicit with time components if a specific time is desired (e.g., `maya.when('tomorrow 12pm')`), or handle ranges manually if a full-day interval is needed (e.g., `maya.when('2024-01-15').start_of_day()` and `.end_of_day()` if available, or construct `MayaInterval` explicitly).
affects: All versions
gotchaWhile Maya aims to simplify timezone handling by internally converting all times to UTC for consistent arithmetic, operations like adding a `timedelta` to a `MayaDT` object obtained with a specific `to_timezone` might not correctly account for Daylight Saving Time (DST) transitions in non-UTC timezones. This can lead to off-by-one-hour errors.
fix
For precise timezone-aware arithmetic, convert to a `datetime` object with the desired timezone using `MayaDT.datetime(to_timezone='...')` and perform arithmetic there, or ensure operations are explicitly done in UTC before converting back to a local timezone.
affects: All versions
gotchaOlder versions of Maya (e.g., v0.4.1) had specific, limited compatibility with `pendulum` versions (e.g., `>= 1.0` and `<= 1.5.1`). While this might be resolved in 0.6.1, unexpected `pendulum` version incompatibilities can still occur during installation or runtime, leading to broken parsing functionality.
fix
Check `maya`'s `setup.py` or `pyproject.toml` (if available in a modern release) for current `pendulum` dependency constraints. If encountering issues, try pinning `pendulum` to a known compatible version in your `requirements.txt`.
affects: <= 0.5.0, potentially later versions with specific `pendulum` releases.
gotchaUsers have reported that `maya.parse()` may fail to correctly parse some valid ISO 8601 strings or encounter issues with 'certain dates', indicating potential edge cases in its parsing logic.
fix
If parsing fails, try providing date strings in common, unambiguous formats (e.g., 'YYYY-MM-DD HH:MM:SSZ') or fall back to Python's standard `datetime.strptime()` if specific formatting is known.
affects: All versions
gotchaInstalling `maya` in a `python-slim` Docker container (or similar minimal environments) can fail due to dependencies (specifically `regex`) requiring a C compiler (`gcc`) or Python development headers (`python3.x-dev`) during the wheel building process.
fix
Ensure `gcc` and `python3-dev` (or equivalent for your OS/Python version) are installed in the Docker image or environment before attempting `pip install maya`.
affects: All versions in minimal environments
Errors
Common errors & fixes
AttributeError: 'NoneType' object has no attribute 'replace'
This error occurs when `maya.parse()` fails to interpret a date string, returning `None`, and a subsequent operation attempts to call a method (like `replace`) on this `None` object. This often happens with malformed or unrecognized date string formats.
fix
Ensure the date string provided to `maya.parse()` is in a supported and unambiguous format. Add error handling to check if `maya.parse()` returns `None` before proceeding. For example: `m = maya.parse(date_string); if m is not None: do_something_with(m)`.
ModuleNotFoundError: No module named 'maya'
The `maya` Python library for datetimes is not installed in your current Python environment. This error is distinct from issues with the Autodesk Maya 3D software.
fix
Install the library using pip: `pip install maya`
Inconsistent conversion of datetime slang
The `maya.when()` or `maya.parse()` functions may produce unexpected results or fail to parse certain 'human slang' or specific date string formats, particularly when timezone interpretations become ambiguous or the underlying parsing libraries (like Pendulum) encounter an edge case.
fix
For critical date parsing, provide explicit, standardized date and time strings (e.g., ISO 8601, RFC 2822) rather than relying solely on 'human slang'. If timezones are involved, consider explicitly setting them during parsing using `maya.parse(date_string, timezone='UTC')` or similar methods.
Upgrade
Version history
0.6.1latest on PyPI · released Jan 6, 2019
Audit
Dependencies
pendulumrequiredPowers Maya's date parsing capabilities.
dateparserrequiredLikely used for robust string parsing, as indicated by GitHub issues.
Agent activity
5 hits · last 30 days
node
4
Resources
maya — pip install maya · libregistry