Skip to main content

BridgeTime: Rust-powered Day.js/Moment-style datetime toolkit

Project description

bridgetime (Python)

BridgeTime is a Rust-powered datetime toolkit with a Day.js/Moment-style API exposed to Python.

Install

pip install bridgetime

Quickstart

from bridgetime import bridge_duration, bridge_time, supported_locales, supported_units

now = bridge_time.now("UTC")
print(now.to_iso())

custom = bridge_time.parse_format("22/02/2026 10:15", "DD/MM/YYYY HH:mm", "UTC")
print(custom.to_iso())
from_array = bridge_time.from_array([2026, 1, 22, 10, 15, 30, 250], "UTC")
print(from_array.to_array())
duration = bridge_duration(90, "minute")
print(duration.humanize(True))  # in 2 hours

ny = now.to_timezone("America/New_York")
print(ny.format("YYYY-MM-DD HH:mm:ss"))
print(now.utc_offset(), now.is_utc(), ny.is_dst())

future = now.add(2, "week").start_of("day")
print(future.to_iso())

print(now.get("month"))          # 0-based month (Jan=0)
print(now.set("day", 1).to_iso())  # set weekday (Sunday=0)
print(now.days_in_month())
print(now.quarter(), now.iso_weekday())
print(now.day_of_year(), now.week(), now.iso_week())
print(now.iso_week_year(), now.days_in_year(), now.weeks_in_year(), now.iso_weeks_in_year())
print(now.is_today())
print(now.add(30, "minute").from_now())  # in 30 minutes
print(now.calendar())
print(now.format_locale("dddd, D MMMM YYYY HH:mm", "fr"))
print(now.add_duration(bridge_duration.from_minutes(30)).to_iso())
print(now.is_between(now.start_of("day"), now.end_of("day"), "day", "[]"))
print(bridge_time.min(now, future).to_iso(), bridge_time.max(now, future).to_iso())
print(now.clamp(now.subtract(1, "day"), now.add(1, "day")).to_iso())

print(supported_units())
print(supported_locales())

parsed = bridge_time.parse_batch(["2026-02-22T10:15:30Z", "2026-02-23T10:15:30Z"], "UTC")
rendered = bridge_time.format_batch(parsed, "dddd, DD MMM YYYY", "UTC", "es")
print(rendered)

API Highlights

  • Core: parse, format, add, subtract, start_of, end_of, diff
  • Locale/calendar: format_locale, calendar, supported_locales
  • Duration helpers: bridge_duration, bridge_time.duration(value, unit?), add_duration, subtract_duration
  • Batch parse/format helpers: parse_batch, parse_format_batch, format_batch
  • Custom parse helpers: parse_format(input, pattern, timezone?), from_array(components, timezone?), to_array()
  • Timezone helpers: timezone, utc_offset, is_utc, is_dst, to_timezone
  • Calendar helpers: get, set, component getters/setters (year, set_year, etc), days_in_month, is_leap_year, is_valid
  • Week/day helpers: day_of_year, set_day_of_year, quarter, set_quarter, iso_weekday, set_iso_weekday, week, week_of_year, set_week, iso_week, set_iso_week, iso_week_year, days_in_year, weeks_in_year, iso_weeks_in_year
  • Relative-day helpers: is_today, is_yesterday, is_tomorrow
  • Relative-time helpers: from_time, to_time, from_now, to_now
  • Min/max helpers: bridge_time.min(a, b), bridge_time.max(a, b), clamp(start, end)
  • Comparison helpers: is_before, is_after, is_same, is_same_or_before, is_same_or_after, is_same_or_before_unit, is_same_or_after_unit
  • Unit/range helpers: is_before_unit, is_after_unit, is_same_unit, is_between

Uppercase exports (BridgeTime, BridgeDuration) are no longer part of the public Python API.

Build Locally

cd bindings/python/bridgetime
maturin develop

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

bridgetime-0.2.3.tar.gz (89.5 kB view details)

Uploaded Source

Built Distributions

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

bridgetime-0.2.3-cp38-abi3-win_amd64.whl (383.5 kB view details)

Uploaded CPython 3.8+Windows x86-64

bridgetime-0.2.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (534.5 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

bridgetime-0.2.3-cp38-abi3-macosx_11_0_arm64.whl (450.2 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

bridgetime-0.2.3-cp38-abi3-macosx_10_12_x86_64.whl (464.5 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file bridgetime-0.2.3.tar.gz.

File metadata

  • Download URL: bridgetime-0.2.3.tar.gz
  • Upload date:
  • Size: 89.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bridgetime-0.2.3.tar.gz
Algorithm Hash digest
SHA256 949a097c522a72a57a9ff7ab2d200e6d0366024b4fca4b1c20e2c57d558d7d42
MD5 302d6e23145b86e3bf195342547f86f4
BLAKE2b-256 21c86107a2f63e07b31abe254595077efac37f3d4b3db1ea0ff89f6044c4fae0

See more details on using hashes here.

File details

Details for the file bridgetime-0.2.3-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: bridgetime-0.2.3-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 383.5 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bridgetime-0.2.3-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4e0fcdb8ce243aa7d67ce08ad9f12297a1ffbaa8cd72ba95b85976afcb716fd1
MD5 7424ac594cafefe2a0936cb28418a854
BLAKE2b-256 1ed2905929bba4b3f0433d2f9d7810559a3278a1e069746b7f30d5c8b617a2f1

See more details on using hashes here.

File details

Details for the file bridgetime-0.2.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bridgetime-0.2.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9eac3dbcd55c2f6145ed1c5a69ba6613be5b2a8243b538817f4b0254fe9c588e
MD5 e971660ebf48a3447d2a34ead02e31da
BLAKE2b-256 7bf0f51f161fdfd72f4ebabd770de5565ca7b6ef5f08f6c96a1967234112a384

See more details on using hashes here.

File details

Details for the file bridgetime-0.2.3-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bridgetime-0.2.3-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0b50c797c21edcc8bf38613c02a17c2b57c9893d7239b187da5c0f4bc950326b
MD5 238c8676855561ee0780444db6673a11
BLAKE2b-256 de498fa5e0119d67e5677727b955231cb102cef3dbfc19a99358770751e2d500

See more details on using hashes here.

File details

Details for the file bridgetime-0.2.3-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for bridgetime-0.2.3-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c5b6f2014646178986e0afb54f810b08ae47840aa8d1ee76a2b72059555a2cf1
MD5 e1b3945f857519ad4a4a0fa33338fe3c
BLAKE2b-256 b7e65056ad0353659ff3edee755d1cd6691b68bf90f370036cacb7b5f64d2e39

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