Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused imports in naive's serde examples & fix some typos #616

Merged
merged 2 commits into from Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/datetime/serde.rs
Expand Up @@ -262,7 +262,7 @@ pub mod ts_nanoseconds {
}
}

/// Ser/de to/from timestamps in nanoseconds
/// Ser/de to/from optional timestamps in nanoseconds
///
/// Intended for use with `serde`'s `with` attribute.
///
Expand Down Expand Up @@ -392,23 +392,23 @@ pub mod ts_nanoseconds_option {
formatter.write_str("a unix timestamp in nanoseconds or none")
}

/// Deserialize a timestamp in seconds since the epoch
/// Deserialize a timestamp in nanoseconds since the epoch
fn visit_some<D>(self, d: D) -> Result<Self::Value, D::Error>
where
D: de::Deserializer<'de>,
{
d.deserialize_i64(NanoSecondsTimestampVisitor).map(Some)
}

/// Deserialize a timestamp in seconds since the epoch
/// Deserialize a timestamp in nanoseconds since the epoch
fn visit_none<E>(self) -> Result<Self::Value, E>
where
E: de::Error,
{
Ok(None)
}

/// Deserialize a timestamp in seconds since the epoch
/// Deserialize a timestamp in nanoseconds since the epoch
fn visit_unit<E>(self) -> Result<Self::Value, E>
where
E: de::Error,
Expand Down Expand Up @@ -696,23 +696,23 @@ pub mod ts_microseconds_option {
formatter.write_str("a unix timestamp in microseconds or none")
}

/// Deserialize a timestamp in seconds since the epoch
/// Deserialize a timestamp in microseconds since the epoch
fn visit_some<D>(self, d: D) -> Result<Self::Value, D::Error>
where
D: de::Deserializer<'de>,
{
d.deserialize_i64(MicroSecondsTimestampVisitor).map(Some)
}

/// Deserialize a timestamp in seconds since the epoch
/// Deserialize a timestamp in microseconds since the epoch
fn visit_none<E>(self) -> Result<Self::Value, E>
where
E: de::Error,
{
Ok(None)
}

/// Deserialize a timestamp in seconds since the epoch
/// Deserialize a timestamp in microseconds since the epoch
fn visit_unit<E>(self) -> Result<Self::Value, E>
where
E: de::Error,
Expand Down Expand Up @@ -1010,23 +1010,23 @@ pub mod ts_milliseconds_option {
formatter.write_str("a unix timestamp in milliseconds or none")
}

/// Deserialize a timestamp in seconds since the epoch
/// Deserialize a timestamp in milliseconds since the epoch
fn visit_some<D>(self, d: D) -> Result<Self::Value, D::Error>
where
D: de::Deserializer<'de>,
{
d.deserialize_i64(MilliSecondsTimestampVisitor).map(Some)
}

/// Deserialize a timestamp in seconds since the epoch
/// Deserialize a timestamp in milliseconds since the epoch
fn visit_none<E>(self) -> Result<Self::Value, E>
where
E: de::Error,
{
Ok(None)
}

/// Deserialize a timestamp in seconds since the epoch
/// Deserialize a timestamp in milliseconds since the epoch
fn visit_unit<E>(self) -> Result<Self::Value, E>
where
E: de::Error,
Expand Down
30 changes: 15 additions & 15 deletions src/naive/datetime/serde.rs
Expand Up @@ -66,7 +66,7 @@ impl<'de> de::Deserialize<'de> for NaiveDateTime {
/// # extern crate serde_json;
/// # extern crate serde;
/// # extern crate chrono;
/// # use chrono::{TimeZone, NaiveDate, NaiveDateTime, Utc};
/// # use chrono::{NaiveDate, NaiveDateTime};
/// use chrono::naive::serde::ts_nanoseconds;
/// #[derive(Deserialize, Serialize)]
/// struct S {
Expand Down Expand Up @@ -95,7 +95,7 @@ pub mod ts_nanoseconds {
use super::ne_timestamp;
use crate::NaiveDateTime;

/// Serialize a UTC datetime into an integer number of nanoseconds since the epoch
/// Serialize a datetime into an integer number of nanoseconds since the epoch
///
/// Intended for use with `serde`s `serialize_with` attribute.
///
Expand All @@ -110,7 +110,7 @@ pub mod ts_nanoseconds {
/// # #[macro_use] extern crate serde_json;
/// # #[macro_use] extern crate serde;
/// # extern crate chrono;
/// # use chrono::{TimeZone, NaiveDate, NaiveDateTime, Utc};
/// # use chrono::{NaiveDate, NaiveDateTime};
/// # use serde::Serialize;
/// use chrono::naive::serde::ts_nanoseconds::serialize as to_nano_ts;
/// #[derive(Serialize)]
Expand All @@ -136,7 +136,7 @@ pub mod ts_nanoseconds {
serializer.serialize_i64(dt.timestamp_nanos())
}

/// Deserialize a `DateTime` from a nanoseconds timestamp
/// Deserialize a `NaiveDateTime` from a nanoseconds timestamp
///
/// Intended for use with `serde`s `deserialize_with` attribute.
///
Expand All @@ -151,7 +151,7 @@ pub mod ts_nanoseconds {
/// # #[macro_use] extern crate serde_json;
/// # extern crate serde;
/// # extern crate chrono;
/// # use chrono::{NaiveDateTime, Utc};
/// # use chrono::NaiveDateTime;
/// # use serde::Deserialize;
/// use chrono::naive::serde::ts_nanoseconds::deserialize as from_nano_ts;
/// #[derive(Deserialize)]
Expand Down Expand Up @@ -216,7 +216,7 @@ pub mod ts_nanoseconds {
/// # extern crate serde_json;
/// # extern crate serde;
/// # extern crate chrono;
/// # use chrono::{TimeZone, NaiveDate, NaiveDateTime, Utc};
/// # use chrono::{NaiveDate, NaiveDateTime};
/// use chrono::naive::serde::ts_milliseconds;
/// #[derive(Deserialize, Serialize)]
/// struct S {
Expand Down Expand Up @@ -245,7 +245,7 @@ pub mod ts_milliseconds {
use super::ne_timestamp;
use crate::NaiveDateTime;

/// Serialize a UTC datetime into an integer number of milliseconds since the epoch
/// Serialize a datetime into an integer number of milliseconds since the epoch
///
/// Intended for use with `serde`s `serialize_with` attribute.
///
Expand All @@ -260,7 +260,7 @@ pub mod ts_milliseconds {
/// # #[macro_use] extern crate serde_json;
/// # #[macro_use] extern crate serde;
/// # extern crate chrono;
/// # use chrono::{TimeZone, NaiveDate, NaiveDateTime, Utc};
/// # use chrono::{NaiveDate, NaiveDateTime};
/// # use serde::Serialize;
/// use chrono::naive::serde::ts_milliseconds::serialize as to_milli_ts;
/// #[derive(Serialize)]
Expand All @@ -286,7 +286,7 @@ pub mod ts_milliseconds {
serializer.serialize_i64(dt.timestamp_millis())
}

/// Deserialize a `DateTime` from a milliseconds timestamp
/// Deserialize a `NaiveDateTime` from a milliseconds timestamp
///
/// Intended for use with `serde`s `deserialize_with` attribute.
///
Expand All @@ -301,7 +301,7 @@ pub mod ts_milliseconds {
/// # #[macro_use] extern crate serde_json;
/// # extern crate serde;
/// # extern crate chrono;
/// # use chrono::{NaiveDateTime, Utc};
/// # use chrono::NaiveDateTime;
/// # use serde::Deserialize;
/// use chrono::naive::serde::ts_milliseconds::deserialize as from_milli_ts;
/// #[derive(Deserialize)]
Expand Down Expand Up @@ -366,7 +366,7 @@ pub mod ts_milliseconds {
/// # extern crate serde_json;
/// # extern crate serde;
/// # extern crate chrono;
/// # use chrono::{TimeZone, NaiveDate, NaiveDateTime, Utc};
/// # use chrono::{NaiveDate, NaiveDateTime};
/// use chrono::naive::serde::ts_seconds;
/// #[derive(Deserialize, Serialize)]
/// struct S {
Expand Down Expand Up @@ -395,7 +395,7 @@ pub mod ts_seconds {
use super::ne_timestamp;
use crate::NaiveDateTime;

/// Serialize a UTC datetime into an integer number of seconds since the epoch
/// Serialize a datetime into an integer number of seconds since the epoch
///
/// Intended for use with `serde`s `serialize_with` attribute.
///
Expand All @@ -410,7 +410,7 @@ pub mod ts_seconds {
/// # #[macro_use] extern crate serde_json;
/// # #[macro_use] extern crate serde;
/// # extern crate chrono;
/// # use chrono::{TimeZone, NaiveDate, NaiveDateTime, Utc};
/// # use chrono::{NaiveDate, NaiveDateTime};
/// # use serde::Serialize;
/// use chrono::naive::serde::ts_seconds::serialize as to_ts;
/// #[derive(Serialize)]
Expand All @@ -436,7 +436,7 @@ pub mod ts_seconds {
serializer.serialize_i64(dt.timestamp())
}

/// Deserialize a `DateTime` from a seconds timestamp
/// Deserialize a `NaiveDateTime` from a seconds timestamp
///
/// Intended for use with `serde`s `deserialize_with` attribute.
///
Expand All @@ -451,7 +451,7 @@ pub mod ts_seconds {
/// # #[macro_use] extern crate serde_json;
/// # extern crate serde;
/// # extern crate chrono;
/// # use chrono::{NaiveDateTime, Utc};
/// # use chrono::NaiveDateTime;
/// # use serde::Deserialize;
/// use chrono::naive::serde::ts_seconds::deserialize as from_ts;
/// #[derive(Deserialize)]
Expand Down