Loading .github/workflows/ci.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ on: [push] name: CI env: rust_version: 1.48.0 rust_version: 1.49.0 java_version: 9 jobs: Loading rust-runtime/smithy-types/src/instant/format.rs +1 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ const NANOS_PER_SECOND: u32 = 1_000_000_000; #[non_exhaustive] #[derive(Debug, Eq, PartialEq)] pub enum DateParseError { Invalid(&'static str), Loading rust-runtime/smithy-types/src/instant/mod.rs +6 −5 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0. */ use crate::instant::format::DateParseError; use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc}; use std::str::FromStr; use std::time::{SystemTime, UNIX_EPOCH}; Loading Loading @@ -54,14 +55,14 @@ impl Instant { } } pub fn from_str(s: &str, format: Format) -> Result<Self, ()> { pub fn from_str(s: &str, format: Format) -> Result<Self, DateParseError> { match format { Format::DateTime => format::iso_8601::parse(s).map_err(|_| ()), Format::HttpDate => format::http_date::parse(s).map_err(|_| ()), Format::DateTime => format::iso_8601::parse(s), Format::HttpDate => format::http_date::parse(s), Format::EpochSeconds => <f64>::from_str(s) // TODO: Parse base & fraction separately to achieve higher precision .map(Self::from_f64) .map_err(|_| ()), .map_err(|_| DateParseError::Invalid("expected float")), } } Loading @@ -87,7 +88,7 @@ impl Instant { pub fn fmt(&self, format: Format) -> String { match format { Format::DateTime => { // TODO: hand write rfc3339 formatter & remove chrono dependency // TODO: hand write rfc3339 formatter & remove Chrono alloc feature let rfc3339 = self .to_chrono() .to_rfc3339_opts(SecondsFormat::AutoSi, true); Loading Loading
.github/workflows/ci.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ on: [push] name: CI env: rust_version: 1.48.0 rust_version: 1.49.0 java_version: 9 jobs: Loading
rust-runtime/smithy-types/src/instant/format.rs +1 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ const NANOS_PER_SECOND: u32 = 1_000_000_000; #[non_exhaustive] #[derive(Debug, Eq, PartialEq)] pub enum DateParseError { Invalid(&'static str), Loading
rust-runtime/smithy-types/src/instant/mod.rs +6 −5 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0. */ use crate::instant::format::DateParseError; use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc}; use std::str::FromStr; use std::time::{SystemTime, UNIX_EPOCH}; Loading Loading @@ -54,14 +55,14 @@ impl Instant { } } pub fn from_str(s: &str, format: Format) -> Result<Self, ()> { pub fn from_str(s: &str, format: Format) -> Result<Self, DateParseError> { match format { Format::DateTime => format::iso_8601::parse(s).map_err(|_| ()), Format::HttpDate => format::http_date::parse(s).map_err(|_| ()), Format::DateTime => format::iso_8601::parse(s), Format::HttpDate => format::http_date::parse(s), Format::EpochSeconds => <f64>::from_str(s) // TODO: Parse base & fraction separately to achieve higher precision .map(Self::from_f64) .map_err(|_| ()), .map_err(|_| DateParseError::Invalid("expected float")), } } Loading @@ -87,7 +88,7 @@ impl Instant { pub fn fmt(&self, format: Format) -> String { match format { Format::DateTime => { // TODO: hand write rfc3339 formatter & remove chrono dependency // TODO: hand write rfc3339 formatter & remove Chrono alloc feature let rfc3339 = self .to_chrono() .to_rfc3339_opts(SecondsFormat::AutoSi, true); Loading