Skip to content

Latest commit

 

History

230 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Morrow.mojo

Human-friendly date and time utilities for Mojo. Morrow provides an date-time API for creating, parsing, formatting, shifting, comparing, and humanizing date-time values.

Test Documentation GitHub release

Language: English | 中文

Documentation: https://mojoto.github.io/morrow.mojo/

Installation

Morrow is available from the official Modular Community channel. From a Pixi workspace already configured for Mojo, add the Modular Community channel and install Morrow:

pixi workspace channel add --prepend https://repo.prefix.dev/modular-community
pixi add morrow

The package installs a compiler-compatible morrow.mojoc into the active Pixi environment, so it can be imported without copying source files.

Usage

Paste the following example into the REPL:

from morrow import FORMAT_RSS, Morrow, TimeZone

var now = Morrow.now()
print(now)

var utc = Morrow.utcnow()
print(utc)

var parsed = Morrow.get("2026-01-01 03:04:05Z")
print(parsed)
print(parsed.format("YYYY-MM-DD HH:mm:ss ZZ"))

var beijing = parsed.to("+08:00")
print(beijing)

var hour = beijing.span("hour")
print(hour)

print(beijing.isocalendar())
print(beijing.timetuple())

var rss = Morrow(2026, 1, 1, 10, 30, 35, 0, TimeZone(0, "UTC"))
print(rss.format(FORMAT_RSS))

Morrow is UTC by default, supports IANA and fixed-offset time zones, parses ISO 8601 strings and POSIX timestamps, and formats values with date/time tokens or Python-style strftime. English, Simplified Chinese, and Traditional Chinese are supported for formatting, parsing, and relative time. Named and local time zones require ICU (provided by macOS; install libicu-dev on Debian/Ubuntu).

Development

Source builds support Mojo 1.0.0 and 1.1.0. Use make install MOJO_VERSION=1.0.0 to select 1.0 (the default is 1.1.0), then run make test build. CI tests and precompiles both versions on Linux x86-64, Linux ARM64, and macOS ARM64. Release archives are built separately for each compiler version; choose the matching archive. Mojo 1.1 emits deprecation warnings for the string API retained for 1.0 compatibility.

make package builds two Conda variants of the same Morrow version, each requiring its exact Mojo compiler version. Publish both builds to the same channel so Pixi can select the build matching the compiler constraint in the consuming project.

Run make help to list the available targets.

Target Description
make install Create or reuse .venv and install the pinned Mojo version with uv
make test Run every tests/test_*.mojo file
make test-package Build and test the precompiled package outside the source checkout
make benchmark Run five samples of each performance benchmark
make format Format the morrow and tests directories
make build Precompile morrow as morrow.mojoc
make package Build the distributable Conda package with rattler-build
make clean Remove morrow.mojoc
make doc-install Install Docusaurus dependencies
make doc-build Build the Docusaurus static site
make doc-serve Serve the built Docusaurus site
make doc-clean Remove generated Docusaurus files

The documentation targets require Node.js and npm. Run make doc-install before building the documentation, then use make doc-build followed by make doc-serve to preview the built site.

See the testing guide and 1.x stability contract for validation commands, compiler compatibility, and distribution guarantees.

About

Human-friendly date & time for Mojo 🔥

Topics

Resources

Stars

126 stars

Watchers

18 watching

Forks

Releases

Packages

Used by

Contributors

Languages