https://github.com/modprog/toml-datetime-compat
https://github.com/modprog/toml-datetime-compat
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/modprog/toml-datetime-compat
- Owner: ModProg
- License: mit
- Created: 2023-01-10T21:31:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-21T10:27:14.000Z (about 2 years ago)
- Last Synced: 2024-11-08T09:20:31.175Z (over 1 year ago)
- Language: Rust
- Size: 15.6 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# toml-datetime-compat
Adds a functionality to easily convert between `toml_datetime`'s and
`chrono`'s/`time`'s types.
Both with the `serde` derive macros:
```rust
#[derive(Deserialize, Serialize)]
struct SomeDateTimes {
#[serde(with = "toml_datetime_compat")]
chrono_naive_date: chrono::NaiveDate,
#[serde(with = "toml_datetime_compat")]
chrono_naive_time: chrono::NaiveTime,
#[serde(with = "toml_datetime_compat")]
chrono_naive_date_time: chrono::NaiveDateTime,
#[serde(with = "toml_datetime_compat")]
chrono_date_time_utc: chrono::DateTime,
#[serde(with = "toml_datetime_compat")]
chrono_date_time_offset: chrono::DateTime,
#[serde(with = "toml_datetime_compat")]
time_date: time::Date,
#[serde(with = "toml_datetime_compat")]
time_time: time::Time,
#[serde(with = "toml_datetime_compat")]
time_primitive_date_time: time::PrimitiveDateTime,
#[serde(with = "toml_datetime_compat")]
time_offset_date_time: time::OffsetDateTime,"#
}
```
And by introducing a new trait `ToFromToml` that adds `to_toml` and `from_toml`
functions to the relevant structs from `chrono` and `time`.