time: rustfmt

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-04-10 12:33:56 +02:00
parent 800cf63a8a
commit 4554034d32
7 changed files with 24 additions and 29 deletions

View File

@ -3,9 +3,7 @@ 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,
};
@ -15,7 +13,6 @@ use crate::{parse_weekdays_range, WeekDays};
#[cfg(not(target_arch = "wasm32"))]
use crate::TmEditor;
/// Time of Day (hour with minute)
#[derive(Default, PartialEq, Clone, Debug)]
pub struct HmTime {

View File

@ -40,7 +40,9 @@ impl DateTimeValue {
let mut next: Option<u32> = 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 {

View File

@ -271,4 +271,3 @@ pub fn verify_time_span(i: &str) -> Result<(), Error> {
let _: TimeSpan = i.parse()?;
Ok(())
}

View File

@ -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<String, Error> {
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<i64, Error> {
// TOTO: This should parse olny RFC3339, but currently also parse
// other formats
let time_milli = js_sys::Date::parse(input_str);

View File

@ -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};