| Crates.io | iso8601-timestamp |
| lib.rs | iso8601-timestamp |
| version | 0.3.3 |
| created_at | 2022-04-16 11:09:57.970418+00 |
| updated_at | 2025-01-01 10:20:13.03217+00 |
| description | High-performance ISO8601 Timestamp formatting and parsing |
| homepage | |
| repository | https://github.com/Lantern-chat/iso8601-timestamp |
| max_upload_size | |
| id | 568928 |
| size | 151,208 |
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-postgresrusqlite
ToSql/FromSql implementations for Timestamp so it can be stored/fetched from an rusqlite/sqlite3 databasediesel/diesel-pg
ToSql/FromSql and AsExpressionschema
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 Timestampworker
now_utc() in Cloudflare workersjs
now_utc() in WASM using js-sysramhorns
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.