actually fix linux tests
This commit is contained in:
parent
50c5c29cae
commit
32677b8cd9
|
@ -1,7 +1,6 @@
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use chrono::{LocalResult, NaiveDateTime};
|
use chrono::{LocalResult, NaiveDateTime};
|
||||||
use serde::de;
|
use serde::de;
|
||||||
use chrono::serde::ts_seconds;
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -17,7 +16,7 @@ pub struct SecondsStringTimestampVisitor;
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use chrono::{TimeZone, DateTime, Utc};
|
/// # use chrono::{TimeZone, DateTime, Utc};
|
||||||
/// # use serde::{Deserialize, Serialize};
|
/// # use serde::{Deserialize, Serialize};
|
||||||
/// use chrono::serde::ts_seconds;
|
/// use chorus::types::serde::ts_seconds_str;
|
||||||
/// #[derive(Deserialize, Serialize)]
|
/// #[derive(Deserialize, Serialize)]
|
||||||
/// struct S {
|
/// struct S {
|
||||||
/// #[serde(with = "ts_seconds_str")]
|
/// #[serde(with = "ts_seconds_str")]
|
||||||
|
@ -33,7 +32,7 @@ pub struct SecondsStringTimestampVisitor;
|
||||||
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
||||||
/// let my_s: S = serde_json::from_str(&as_string)?;
|
/// let my_s: S = serde_json::from_str(&as_string)?;
|
||||||
/// assert_eq!(my_s.time, time);
|
/// assert_eq!(my_s.time, time);
|
||||||
/// // Ok::<(), serde_json::Error>(())
|
/// # Ok::<(), serde_json::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
pub mod ts_seconds_str {
|
pub mod ts_seconds_str {
|
||||||
|
@ -53,10 +52,10 @@ pub mod ts_seconds_str {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use chrono::{TimeZone, DateTime, Utc};
|
/// # use chrono::{TimeZone, DateTime, Utc};
|
||||||
/// # use serde::Serialize;
|
/// # use serde::Serialize;
|
||||||
/// use chrono::serde::ts_seconds::serialize as to_ts;
|
/// use chorus::types::serde::ts_seconds_str::serialize as to_ts;
|
||||||
/// #[derive(Serialize)]
|
/// #[derive(Serialize)]
|
||||||
/// struct S {
|
/// struct S {
|
||||||
/// #[serde(serialize_with = "ts_seconds_str")]
|
/// #[serde(serialize_with = "to_ts")]
|
||||||
/// time: DateTime<Utc>
|
/// time: DateTime<Utc>
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
@ -65,7 +64,7 @@ pub mod ts_seconds_str {
|
||||||
/// };
|
/// };
|
||||||
/// let as_string = serde_json::to_string(&my_s)?;
|
/// let as_string = serde_json::to_string(&my_s)?;
|
||||||
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
||||||
/// // Ok::<(), serde_json::Error>(())
|
/// # Ok::<(), serde_json::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn serialize<S>(dt: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error>
|
pub fn serialize<S>(dt: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
|
@ -83,16 +82,16 @@ pub mod ts_seconds_str {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use chrono::{DateTime, TimeZone, Utc};
|
/// # use chrono::{DateTime, TimeZone, Utc};
|
||||||
/// # use serde::Deserialize;
|
/// # use serde::Deserialize;
|
||||||
/// use chrono::serde::ts_seconds::deserialize as from_ts;
|
/// use chorus::types::serde::ts_seconds_str::deserialize as from_ts;
|
||||||
/// #[derive(Debug, PartialEq, Deserialize)]
|
/// #[derive(Debug, PartialEq, Deserialize)]
|
||||||
/// struct S {
|
/// struct S {
|
||||||
/// #[serde(deserialize_with = "ts_seconds_str")]
|
/// #[serde(deserialize_with = "from_ts")]
|
||||||
/// time: DateTime<Utc>
|
/// time: DateTime<Utc>
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// let my_s: S = serde_json::from_str(r#"{ "time": "1431684000" }"#)?;
|
/// let my_s: S = serde_json::from_str(r#"{ "time": "1431684000" }"#)?;
|
||||||
/// assert_eq!(my_s, S { time: Utc.timestamp_opt(1431684000, 0).unwrap() });
|
/// assert_eq!(my_s, S { time: Utc.timestamp_opt(1431684000, 0).unwrap() });
|
||||||
/// // Ok::<(), serde_json::Error>(())
|
/// # Ok::<(), serde_json::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn deserialize<'de, D>(d: D) -> Result<DateTime<Utc>, D::Error>
|
pub fn deserialize<'de, D>(d: D) -> Result<DateTime<Utc>, D::Error>
|
||||||
where
|
where
|
||||||
|
@ -127,7 +126,7 @@ pub mod ts_seconds_str {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use chrono::{TimeZone, DateTime, Utc};
|
/// # use chrono::{TimeZone, DateTime, Utc};
|
||||||
/// # use serde::{Deserialize, Serialize};
|
/// # use serde::{Deserialize, Serialize};
|
||||||
/// use chrono::serde::ts_seconds_option;
|
/// use chorus::types::serde::ts_seconds_option_str;
|
||||||
/// #[derive(Deserialize, Serialize)]
|
/// #[derive(Deserialize, Serialize)]
|
||||||
/// struct S {
|
/// struct S {
|
||||||
/// #[serde(with = "ts_seconds_option_str")]
|
/// #[serde(with = "ts_seconds_option_str")]
|
||||||
|
@ -143,7 +142,7 @@ pub mod ts_seconds_str {
|
||||||
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
||||||
/// let my_s: S = serde_json::from_str(&as_string)?;
|
/// let my_s: S = serde_json::from_str(&as_string)?;
|
||||||
/// assert_eq!(my_s.time, time);
|
/// assert_eq!(my_s.time, time);
|
||||||
/// // Ok::<(), serde_json::Error>(())
|
/// # Ok::<(), serde_json::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub mod ts_seconds_option_str {
|
pub mod ts_seconds_option_str {
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
@ -160,10 +159,10 @@ pub mod ts_seconds_option_str {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use chrono::{TimeZone, DateTime, Utc};
|
/// # use chrono::{TimeZone, DateTime, Utc};
|
||||||
/// # use serde::Serialize;
|
/// # use serde::Serialize;
|
||||||
/// use chrono::serde::ts_seconds_option::serialize as to_tsopt;
|
/// use chorus::types::serde::ts_seconds_option_str::serialize as from_tsopt;
|
||||||
/// #[derive(Serialize)]
|
/// #[derive(Serialize)]
|
||||||
/// struct S {
|
/// struct S {
|
||||||
/// #[serde(serialize_with = "ts_seconds_option_str")]
|
/// #[serde(serialize_with = "from_tsopt")]
|
||||||
/// time: Option<DateTime<Utc>>
|
/// time: Option<DateTime<Utc>>
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
@ -172,7 +171,7 @@ pub mod ts_seconds_option_str {
|
||||||
/// };
|
/// };
|
||||||
/// let as_string = serde_json::to_string(&my_s)?;
|
/// let as_string = serde_json::to_string(&my_s)?;
|
||||||
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
||||||
/// // Ok::<(), serde_json::Error>(())
|
/// # Ok::<(), serde_json::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn serialize<S>(opt: &Option<DateTime<Utc>>, serializer: S) -> Result<S::Ok, S::Error>
|
pub fn serialize<S>(opt: &Option<DateTime<Utc>>, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
|
@ -193,16 +192,16 @@ pub mod ts_seconds_option_str {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use chrono::{DateTime, TimeZone, Utc};
|
/// # use chrono::{DateTime, TimeZone, Utc};
|
||||||
/// # use serde::Deserialize;
|
/// # use serde::Deserialize;
|
||||||
/// use chrono::serde::ts_seconds_option::deserialize as from_tsopt;
|
/// use chorus::types::serde::ts_seconds_option_str::deserialize as from_tsopt;
|
||||||
/// #[derive(Debug, PartialEq, Deserialize)]
|
/// #[derive(Debug, PartialEq, Deserialize)]
|
||||||
/// struct S {
|
/// struct S {
|
||||||
/// #[serde(deserialize_with = "ts_seconds_option_str")]
|
/// #[serde(deserialize_with = "from_tsopt")]
|
||||||
/// time: Option<DateTime<Utc>>
|
/// time: Option<DateTime<Utc>>
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// let my_s: S = serde_json::from_str(r#"{ "time": "1431684000" }"#)?;
|
/// let my_s: S = serde_json::from_str(r#"{ "time": "1431684000" }"#)?;
|
||||||
/// assert_eq!(my_s, S { time: Utc.timestamp_opt(1431684000, 0).single() });
|
/// assert_eq!(my_s, S { time: Utc.timestamp_opt(1431684000, 0).single() });
|
||||||
/// // Ok::<(), serde_json::Error>(())
|
/// # Ok::<(), serde_json::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn deserialize<'de, D>(d: D) -> Result<Option<DateTime<Utc>>, D::Error>
|
pub fn deserialize<'de, D>(d: D) -> Result<Option<DateTime<Utc>>, D::Error>
|
||||||
where
|
where
|
||||||
|
|
Loading…
Reference in New Issue