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.1.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.1-cp38-abi3-win_amd64.whl (369.8 kB view details)

Uploaded CPython 3.8+Windows x86-64

bridgetime-0.2.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (518.8 kB view details)

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

bridgetime-0.2.1-cp38-abi3-macosx_11_0_arm64.whl (438.5 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

bridgetime-0.2.1-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.1.tar.gz.

File metadata

  • Download URL: bridgetime-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 119d56eaeabd1960a11dd81171a609019fc61a6ec63fe0aaf7a1833ff8425c05
MD5 72a2929e675ed479eb825afcadaefb3e
BLAKE2b-256 d8c1bbe9852ce1f14f509e300bfc268f6cd1acc164bbdb0e941c2cdf90b2daa4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bridgetime-0.2.1-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 369.8 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.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1966a910af3e9cf41f2b0ac150869a30a7dac879dd33bceedb0a11d96881a411
MD5 838263476e05a0983b8aef51c12644e8
BLAKE2b-256 1d4050434732edcf2a191cc8ecff82d5c348aa2dfa280abbe63f1abb3bfc5eec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bridgetime-0.2.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c06cb023cf95ac17d65fd980e7ff4e2329f8cf3dcc2207f4c8e9e61b96ef27ee
MD5 a384d0d92fd2c1e4247f5846656a45cd
BLAKE2b-256 216a07e8a3b1b23a3499862bc57049e6b79ec389a0af48f308311235f8779e15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bridgetime-0.2.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d19d9dd0ceae5938da43b0652bf87aa0f0b6c6009568999133d93aead8bf2692
MD5 cee4b237e227973faf92934e83efc301
BLAKE2b-256 b97c317b2d808159046d0bb2259fcc01db389b712b35207d875cc5b50f42d08f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bridgetime-0.2.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 56b23a0a4cb50f0d9f457e5b813527625a3137296aeb0cedcaa61a9cc909d106
MD5 6c1dcfbec7167f2f82b8161c156ee8ef
BLAKE2b-256 a8a78fdce80fd8e5f02d1bfecbcc566abbdc081c08784c6d6d7e99d26982335b

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