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 BridgeDuration, BridgeTime, supported_units

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

custom = BridgeTime.parse_format("22/02/2026 10:15", "DD/MM/YYYY HH:mm", "UTC")
print(custom.to_iso())
from_array = BridgeTime.from_array([2026, 1, 22, 10, 15, 30, 250], "UTC")
print(from_array.to_array())
duration = BridgeDuration(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.add_duration(BridgeDuration.from_minutes(30)).to_iso())
print(now.is_between(now.start_of("day"), now.end_of("day"), "day", "[]"))
print(BridgeTime.min(now, future).to_iso(), BridgeTime.max(now, future).to_iso())
print(now.clamp(now.subtract(1, "day"), now.add(1, "day")).to_iso())

print(supported_units())

API Highlights

  • Core: parse, format, add, subtract, start_of, end_of, diff
  • Duration helpers: BridgeDuration, BridgeTime.duration(value, unit?), add_duration, subtract_duration
  • 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: BridgeTime.min(a, b), BridgeTime.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

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.0.tar.gz (83.0 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.0-cp38-abi3-win_amd64.whl (369.7 kB view details)

Uploaded CPython 3.8+Windows x86-64

bridgetime-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (518.6 kB view details)

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

bridgetime-0.2.0-cp38-abi3-macosx_11_0_arm64.whl (439.3 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

bridgetime-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl (450.3 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: bridgetime-0.2.0.tar.gz
  • Upload date:
  • Size: 83.0 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.0.tar.gz
Algorithm Hash digest
SHA256 fb04317418f0f6be99a67c3740df6a376a6401f68d64a8fee1e5ef2d35c16286
MD5 67cfabaf546afb0aa5473298c21f6748
BLAKE2b-256 280770f8198a77b4f9c2ba28583d8863842019405a1bb57e1d278159709bc963

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bridgetime-0.2.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 369.7 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.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5ca62da3c59136f9f5a88aaaa2887b2536d7667923d090fa505b3c70311c530b
MD5 cb5b2dae9e0131d0cd9bad75ef2aa65e
BLAKE2b-256 937b277fd6db0e5880ef07901a47e6ecd86b9f128eaa7881f37bc92b53707d2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bridgetime-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 904d48b1d42be03e24e35547c96e348081aea813378a41804d4ab416925feae6
MD5 e88675fabbcf999a4de2a39b305a8163
BLAKE2b-256 6dd013d2b9968078e5fa97e30c013b65bc720857e6ab226562177b310760584a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bridgetime-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 468e770a38f93a44663772519ca32ec8be5f8e88eea0f4531d5eeb6fd4049ed5
MD5 166c5191e309e65bdfe2cabd357dc91e
BLAKE2b-256 72a29a6edba72a248db6ef54eb05a68cfb5bc11961ec970315740055907aee5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bridgetime-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 37b0570e36079f84636cc2ad865bafe6f932e6c962fdc8f2e2d9127d1fe55c6c
MD5 5a8368cfe087b8168453cdb6b4ae8040
BLAKE2b-256 46c05812252453103eb437dd16b4045441afd051a82bcd7c41720111d755b534

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