forked from Proxmox/proxmox
time: rustfmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
800cf63a8a
commit
4554034d32
@ -37,7 +37,7 @@ pub struct CalendarEvent {
|
||||
pub(crate) year: Vec<DateTimeValue>,
|
||||
}
|
||||
|
||||
#[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<CalendarEvent, Error> {
|
||||
i.parse()
|
||||
}
|
||||
|
@ -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<bool, Error> {
|
||||
|
@ -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 {
|
||||
|
@ -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)]
|
||||
|
@ -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<TimeSpan, Error> {
|
||||
i.parse()
|
||||
}
|
||||
@ -271,4 +271,3 @@ pub fn verify_time_span(i: &str) -> Result<(), Error> {
|
||||
let _: TimeSpan = i.parse()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user