jiff 0.1.14

A date-time library that encourages you to jump into the pit of success. This library is heavily inspired by the Temporal project.
Documentation
[package]
name = "jiff"
version = "0.1.14"  #:version
authors = ["Andrew Gallant <jamslam@gmail.com>"]
license = "Unlicense OR MIT"
repository = "https://github.com/BurntSushi/jiff"
documentation = "https://docs.rs/jiff"
description = '''
A date-time library that encourages you to jump into the pit of success.

This library is heavily inspired by the Temporal project.
'''
categories = ["date-and-time", "no-std"]
keywords = ["date", "time", "calendar", "zone", "duration"]
edition = "2021"
exclude = ["/.github", "/tmp"]
autotests = false
autoexamples = false
rust-version = "1.70"

[workspace]
members = [
  "jiff-cli",
  "jiff-tzdb",
  "jiff-tzdb-platform",
  "examples/*",
]

# Features are documented in the "Crate features" section of the crate docs:
# https://docs.rs/jiff/*/#crate-features
[features]
default = ["std", "tz-system", "tzdb-bundle-platform", "tzdb-zoneinfo"]
std = ["alloc"]
alloc = []
serde = ["dep:serde"]
logging = ["dep:log"]

# When enabled, Jiff will include code that attempts to determine the "system"
# time zone. For example, on Unix systems, this is usually determined by
# looking at the symlink information on /etc/localtime. But in general, it's
# very platform specific and heuristic oriented. On some platforms, this may
# require extra dependencies. (For example, `windows-sys` on Windows.)
tz-system = ["std", "dep:windows-sys"]

# This conditionally bundles tzdb into the binary depending on which platform
# Jiff is being built for.
tzdb-bundle-platform = ["dep:jiff-tzdb-platform", "alloc"]

# This forces the jiff-tzdb crate to be included. If tzdb-zoneinfo is enabled,
# then the system tzdb will take priority over the bundled database.
tzdb-bundle-always = ["dep:jiff-tzdb", "alloc"]

# This enables the system or "zoneinfo" time zone database. This is the
# database that is typically found at /usr/share/zoneinfo on macOS and Linux.
tzdb-zoneinfo = ["std"]

# This enables bindings to web browser APIs for retrieving the current time
# and configured time zone. This ONLY applies on wasm32-unknown-unknown and
# wasm64-unknown-unknown targets. Specifically, *not* on wasm32-wasi or
# wasm32-unknown-emscripten targets.
#
# This is an "ecosystem" compromise due to the fact that there is no general
# way to determine at compile time whether a wasm target is intended for use
# on the "web." In practice, only wasm{32,64}-unknown-unknown targets are used
# on the web, but wasm{32,64}-unknown-unknown targets can be used in non-web
# contexts as well. Thus, the `js` feature should be enabled only by binaries,
# tests or benchmarks when it is *known* that the application will be used in a
# web context.
#
# Libraries that depend on Jiff should not need to define their own `js`
# feature just to forward it to Jiff. Instead, application authors can depend
# on Jiff directly and enable the `js` feature themselves.
#
# (This is the same dependency setup that the `getrandom` crate uses.)
js = ["dep:wasm-bindgen", "dep:js-sys"]

[dependencies]
jiff-tzdb = { version = "0.1.1", path = "jiff-tzdb", optional = true }
log = { version = "0.4.21", optional = true }
serde = { version = "1.0.203", optional = true }

# Note that the `cfg` gate for the `tzdb-bundle-platform` must repeat the
# target gate on this dependency. The intent is that `tzdb-bundle-platform`
# is enabled by default, but that the `tzdb-bundle-platform` crate is only
# actually used on platforms without a system tzdb (i.e., Windows and wasm).
[target.'cfg(any(windows, target_family = "wasm"))'.dependencies]
jiff-tzdb-platform = { version = "0.1.1", path = "jiff-tzdb-platform", optional = true }

[target.'cfg(windows)'.dependencies.windows-sys]
version = ">=0.52.0, <=0.59.*"
default-features = false
features = ["Win32_Foundation", "Win32_System_Time"]
optional = true

[target.'cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown"))'.dependencies]
js-sys = { version = "0.3.50", optional = true }
wasm-bindgen = { version = "0.2.70", optional = true }

[dev-dependencies]
anyhow = "1.0.81"
chrono = { version = "0.4.38", features = ["serde"] }
chrono-tz = "0.9.0"
# This adds approximately 50 new compilation units when running `cargo test`
# locally on Unix. Blech.
icu = { version = "1.5.0", features = ["std"] }
insta = "1.39.0"
# We force `serde` to be enabled in dev mode so that the docs render and test
# correctly. This is highly suspicious.
jiff = { path = "./", features = ["serde"] }
quickcheck = { version = "1.0.3", default-features = false }
serde = { version = "1.0.203", features = ["derive"] }
serde_json = "1.0.117"
tabwriter = "1.4.0"
time = { version = "0.3.36", features = ["local-offset", "macros", "parsing"] }
tzfile = "0.1.3"
walkdir = "2.5.0"

# hifitime doesn't build on wasm for some reason, so exclude it there.
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies.hifitime]
version = "3.9.0"

[[test]]
path = "tests/lib.rs"
name = "integration"

# This is just like the default 'test' profile, but debug_assertions are
# disabled. This is important to cover for Jiff because we do a lot of extra
# work in our internal ranged integer types when debug_assertions are enabled.
# It also makes types fatter. It's very useful for catching overflow bugs.
# But since there's a fair bit of logic there, it's also worth running tests
# without debug_assertions enabled to exercise the *actual* code paths used
# in production.
[profile.testrelease]
inherits = "test"
debug-assertions = false

[package.metadata.docs.rs]
# We want to document all features.
all-features = true
# Since this crate's feature setup is pretty complicated, it is worth opting
# into a nightly unstable option to show the features that need to be enabled
# for public API items. To do that, we set 'docsrs', and when that's enabled,
# we enable the 'doc_auto_cfg' feature.
#
# To test this locally, run:
#
#     RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features
rustdoc-args = ["--cfg", "docsrs"]