From 4554034d32dd572c92fd1cdab29bbee54bd1b3f1 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Sun, 10 Apr 2022 12:33:56 +0200 Subject: [PATCH] time: rustfmt Signed-off-by: Thomas Lamprecht --- proxmox-time/src/calendar_event.rs | 8 ++++---- proxmox-time/src/daily_duration.rs | 9 +++------ proxmox-time/src/date_time_value.rs | 8 ++++++-- proxmox-time/src/lib.rs | 12 ++++++------ proxmox-time/src/time_span.rs | 3 +-- proxmox-time/src/wasm.rs | 6 +++--- proxmox-time/src/week_days.rs | 7 +------ 7 files changed, 24 insertions(+), 29 deletions(-) diff --git a/proxmox-time/src/calendar_event.rs b/proxmox-time/src/calendar_event.rs index f7134779..c70d9eae 100644 --- a/proxmox-time/src/calendar_event.rs +++ b/proxmox-time/src/calendar_event.rs @@ -37,7 +37,7 @@ pub struct CalendarEvent { pub(crate) year: Vec, } -#[cfg(not(target_arch="wasm32"))] +#[cfg(not(target_arch = "wasm32"))] impl CalendarEvent { /// Computes the next timestamp after `last`. If `utc` is false, the local /// timezone will be used for the calculation. @@ -181,8 +181,8 @@ pub fn verify_calendar_event(i: &str) -> Result<(), Error> { } /// Compute the next event. Use [CalendarEvent::compute_next_event] instead. -#[deprecated="use method 'compute_next_event' of CalendarEvent instead"] -#[cfg(not(target_arch="wasm32"))] +#[deprecated = "use method 'compute_next_event' of CalendarEvent instead"] +#[cfg(not(target_arch = "wasm32"))] pub fn compute_next_event( event: &CalendarEvent, last: i64, @@ -197,7 +197,7 @@ pub fn compute_next_event( } /// Parse a [CalendarEvent] -#[deprecated="use std::str::FromStr trait instead"] +#[deprecated = "use std::str::FromStr trait instead"] pub fn parse_calendar_event(i: &str) -> Result { i.parse() } diff --git a/proxmox-time/src/daily_duration.rs b/proxmox-time/src/daily_duration.rs index badb2a80..37c4f6ab 100644 --- a/proxmox-time/src/daily_duration.rs +++ b/proxmox-time/src/daily_duration.rs @@ -3,19 +3,16 @@ use std::convert::{TryFrom, TryInto}; use anyhow::Error; use nom::{ - bytes::complete::tag, - character::complete::space0, - error::context, + bytes::complete::tag, character::complete::space0, error::context, multi::separated_nonempty_list, }; use crate::parse_helpers::{parse_complete_line, parse_error, parse_hm_time, IResult}; use crate::{parse_weekdays_range, WeekDays}; -#[cfg(not(target_arch="wasm32"))] +#[cfg(not(target_arch = "wasm32"))] use crate::TmEditor; - /// Time of Day (hour with minute) #[derive(Default, PartialEq, Clone, Debug)] pub struct HmTime { @@ -42,7 +39,7 @@ pub struct DailyDuration { pub end: HmTime, } -#[cfg(not(target_arch="wasm32"))] +#[cfg(not(target_arch = "wasm32"))] impl DailyDuration { /// Test it time is within this frame pub fn time_match(&self, epoch: i64, utc: bool) -> Result { diff --git a/proxmox-time/src/date_time_value.rs b/proxmox-time/src/date_time_value.rs index c3c20352..72b4c2ee 100644 --- a/proxmox-time/src/date_time_value.rs +++ b/proxmox-time/src/date_time_value.rs @@ -40,7 +40,9 @@ impl DateTimeValue { let mut next: Option = None; let mut set_next = |v: u32| { if let Some(n) = next { - if v < n { next = Some(v); } + if v < n { + next = Some(v); + } } else { next = Some(v); } @@ -48,7 +50,9 @@ impl DateTimeValue { for spec in list { match spec { DateTimeValue::Single(v) => { - if *v > value { set_next(*v); } + if *v > value { + set_next(*v); + } } DateTimeValue::Range(start, end) => { if value < *start { diff --git a/proxmox-time/src/lib.rs b/proxmox-time/src/lib.rs index 8fda9d26..15ce0a01 100644 --- a/proxmox-time/src/lib.rs +++ b/proxmox-time/src/lib.rs @@ -1,8 +1,8 @@ #![allow(clippy::manual_range_contains)] -#[cfg(not(target_arch="wasm32"))] +#[cfg(not(target_arch = "wasm32"))] mod tm_editor; -#[cfg(not(target_arch="wasm32"))] +#[cfg(not(target_arch = "wasm32"))] pub use tm_editor::*; pub(crate) mod parse_helpers; @@ -21,14 +21,14 @@ pub use week_days::*; mod daily_duration; pub use daily_duration::*; -#[cfg(not(target_arch="wasm32"))] +#[cfg(not(target_arch = "wasm32"))] mod posix; -#[cfg(not(target_arch="wasm32"))] +#[cfg(not(target_arch = "wasm32"))] pub use posix::*; -#[cfg(target_arch="wasm32")] +#[cfg(target_arch = "wasm32")] mod wasm; -#[cfg(target_arch="wasm32")] +#[cfg(target_arch = "wasm32")] pub use wasm::*; #[cfg(test)] diff --git a/proxmox-time/src/time_span.rs b/proxmox-time/src/time_span.rs index 0a6c9cad..418c560e 100644 --- a/proxmox-time/src/time_span.rs +++ b/proxmox-time/src/time_span.rs @@ -207,7 +207,7 @@ impl std::str::FromStr for TimeSpan { } /// Parse a [TimeSpan] -#[deprecated="Use std::str::FromStr trait instead."] +#[deprecated = "Use std::str::FromStr trait instead."] pub fn parse_time_span(i: &str) -> Result { i.parse() } @@ -271,4 +271,3 @@ pub fn verify_time_span(i: &str) -> Result<(), Error> { let _: TimeSpan = i.parse()?; Ok(()) } - diff --git a/proxmox-time/src/wasm.rs b/proxmox-time/src/wasm.rs index cd5930c9..836bce34 100644 --- a/proxmox-time/src/wasm.rs +++ b/proxmox-time/src/wasm.rs @@ -10,18 +10,18 @@ pub fn epoch_f64() -> f64 { js_sys::Date::now() / 1000.0 } - /// Convert Unix epoch into RFC3339 local time with TZ pub fn epoch_to_rfc3339(epoch: i64) -> Result { let js_date = js_sys::Date::new_0(); js_date.set_time((epoch as f64) * 1000.0); - js_date.to_iso_string().as_string() + js_date + .to_iso_string() + .as_string() .ok_or_else(|| format_err!("to_iso_string did not return a string")) } /// Parse RFC3339 into Unix epoch pub fn parse_rfc3339(input_str: &str) -> Result { - // TOTO: This should parse olny RFC3339, but currently also parse // other formats let time_milli = js_sys::Date::parse(input_str); diff --git a/proxmox-time/src/week_days.rs b/proxmox-time/src/week_days.rs index 64d41375..85425095 100644 --- a/proxmox-time/src/week_days.rs +++ b/proxmox-time/src/week_days.rs @@ -1,10 +1,5 @@ use bitflags::bitflags; -use nom::{ - bytes::complete::tag, - character::complete::alpha1, - combinator::opt, - sequence::pair, -}; +use nom::{bytes::complete::tag, character::complete::alpha1, combinator::opt, sequence::pair}; use crate::parse_helpers::{parse_error, IResult};