Crates.io | iso8601-timestamp |
lib.rs | iso8601-timestamp |
version | |
source | src |
created_at | 2022-04-16 11:09:57.970418 |
updated_at | 2024-12-08 19:20:30.37179 |
description | High-performance ISO8601 Timestamp formatting and parsing |
homepage | |
repository | https://github.com/Lantern-chat/iso8601-timestamp |
max_upload_size | |
id | 568928 |
Cargo.toml error: | TOML parse error at line 23, column 1 | 23 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This crate provides high-performance formatting and parsing routines for ISO8601 timestamps, primarily focused on UTC values but with support for parsing (and automatically applying) UTC Offsets.
The primary purpose of this is to keep the lightweight representation of timestamps within data structures, and only formatting it to a string when needed via Serde.
The [Timestamp
] struct is only 12 bytes, while the formatted strings can be as large as 35 bytes, and care is taken to avoid heap allocations when formatting.
Example:
use iso8601_timestamp::Timestamp;
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Event {
name: String,
ts: Timestamp, // only 12 bytes
value: i32,
}
when serialized to JSON could result in:
{
"name": "some_event",
"ts": "2021-10-17T02:03:01Z",
"value": 42
}
When serializing to non-human-readable formats, such as binary formats, the Timestamp
will be written as an i64
representing milliseconds since the Unix Epoch. This way it only uses 8 bytes instead of 24.
Similarly, when deserializing, it supports either an ISO8601 string or an i64
representing a unix timestamp in milliseconds.
std
(default)
serde
(default)
Timestamp
and [TimestampStr
]rkyv_07
rkyv
0.7 archive support for Timestamp
, serializing it as a 64-bit signed unix offset in milliseconds.rkyv_08
rkyv
0.8 archive support for Timestamp
, serializing it as a 64-bit signed unix offset in milliseconds.verify
pg
ToSql
/FromSql
implementations for Timestamp
so it can be directly stored/fetched from a PostgreSQL database using rust-postgres
rusqlite
ToSql
/FromSql
implementations for Timestamp
so it can be stored/fetched from an rusqlite
/sqlite3
databasediesel
/diesel-pg
ToSql
/FromSql
and AsExpression
schema
JsonSchema
for generating a JSON schema on the fly using schemars
.bson
visit_map
implementation to handle deserialising BSON (MongoDB) DateTime format, { $date: string }
.rand
rand
implementations, to generate random timestamps.quickcheck
quickcheck
's Arbitrary
implementation on Timestamp
worker
now_utc()
in Cloudflare workersjs
now_utc()
in WASM using js-sys
ramhorns
Content
for Timestamp
, formatting it as a regular ISO8601 timestamp.fred
Timestamp
and RedisValue
/RedisKey
to be used with fred
Redis client.borsh
Borsh
(de)serialization for Timestamp
using the borsh
crate.i64
milliseconds since the Unix Epoch.