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_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.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())

API Highlights

  • Core: parse, format, add, subtract, start_of, end_of, diff
  • Duration helpers: bridge_duration, bridge_time.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: 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.2.tar.gz (83.2 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.2-cp38-abi3-win_amd64.whl (370.7 kB view details)

Uploaded CPython 3.8+Windows x86-64

bridgetime-0.2.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (519.3 kB view details)

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

bridgetime-0.2.2-cp38-abi3-macosx_11_0_arm64.whl (439.7 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

bridgetime-0.2.2-cp38-abi3-macosx_10_12_x86_64.whl (452.1 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: bridgetime-0.2.2.tar.gz
  • Upload date:
  • Size: 83.2 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.2.tar.gz
Algorithm Hash digest
SHA256 220301bf9a99b41f39d7040c743bddc594d43b36a60aba04f5a14acdf9b4f5d3
MD5 5e780bdd9109cc4153d581d56b3fdfac
BLAKE2b-256 ddc0f64232ec513b64b512b1fb0b3b5fa3085f0fd762e811b70ff2ac8b267061

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bridgetime-0.2.2-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 370.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.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f5fdb9358232ef532d7265077be814895d0f6d847b6cbeccad9d2841601b8ca4
MD5 a6242f04d5ae613218db73f792f430c7
BLAKE2b-256 85b5dec0c14da80644d380c840274baf43941392f0456e9c59d6cde517ece79d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bridgetime-0.2.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 abb2bb238d953325d9375f7aa9f0ed5363b1c1ed68d8ae7456944463ebbc2307
MD5 b623672163479c3a1091910bfa4c5b38
BLAKE2b-256 fd982550bf29920b22899ec3181cc5274500c8b5d45acfa04c64dc093502c514

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bridgetime-0.2.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8dfb4578fd7a3f769ea8498d91c70920112dd4f5087ad6c902f8eb1a74777c0b
MD5 b7b635f3564d796933766cd9add683f9
BLAKE2b-256 8650c6371e7c9cd5f71da63da2e719333b54f8dc20c7f59d23fba46dda52f733

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bridgetime-0.2.2-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0516014422d5386b1a42db3a5a2e1672c982baecce904f0e659c09378270c1ea
MD5 9f470601984320530e000dc749411a5d
BLAKE2b-256 4ec6a10b1a7d291e58a3f3a2ba13d7be0928d331cbe02fe18e3127eee5564d2c

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