cargo fmt
This commit is contained in:
@@ -160,12 +160,24 @@ fn named_date<Tz: TimeZone>(
|
|||||||
"today" => Ok((remaining, local_today)),
|
"today" => Ok((remaining, local_today)),
|
||||||
"tomorrow" => Ok((remaining, local_today + Duration::days(1))),
|
"tomorrow" => Ok((remaining, local_today + Duration::days(1))),
|
||||||
// TODO: lots more!
|
// TODO: lots more!
|
||||||
"eod" => Ok((remaining,local_today + Duration::days(1))),
|
"eod" => Ok((remaining, local_today + Duration::days(1))),
|
||||||
"sod" => Ok((remaining,local_today)),
|
"sod" => Ok((remaining, local_today)),
|
||||||
"eow" => Ok((remaining,local_today + Duration::days((6-day_index).into()))),
|
"eow" => Ok((
|
||||||
"eoww" => Ok((remaining,local_today + Duration::days((5-day_index).into()))),
|
remaining,
|
||||||
"sow" => Ok((remaining,local_today + Duration::days((6-day_index).into()))),
|
local_today + Duration::days((6 - day_index).into()),
|
||||||
"soww" => Ok((remaining,local_today + Duration::days((7-day_index).into()))),
|
)),
|
||||||
|
"eoww" => Ok((
|
||||||
|
remaining,
|
||||||
|
local_today + Duration::days((5 - day_index).into()),
|
||||||
|
)),
|
||||||
|
"sow" => Ok((
|
||||||
|
remaining,
|
||||||
|
local_today + Duration::days((6 - day_index).into()),
|
||||||
|
)),
|
||||||
|
"soww" => Ok((
|
||||||
|
remaining,
|
||||||
|
local_today + Duration::days((7 - day_index).into()),
|
||||||
|
)),
|
||||||
_ => Err(Err::Error(Error::new(input, ErrorKind::Tag))),
|
_ => Err(Err::Error(Error::new(input, ErrorKind::Tag))),
|
||||||
}
|
}
|
||||||
.map(|(rem, dt)| (rem, dt.and_hms(0, 0, 0).with_timezone(&Utc)))
|
.map(|(rem, dt)| (rem, dt.and_hms(0, 0, 0).with_timezone(&Utc)))
|
||||||
@@ -308,12 +320,12 @@ mod test {
|
|||||||
#[case::today_from_evening(ldt(2021, 3, 1, 21, 30, 30), "today", ld(2021, 3, 1))]
|
#[case::today_from_evening(ldt(2021, 3, 1, 21, 30, 30), "today", ld(2021, 3, 1))]
|
||||||
#[case::tomorrow(ld(2021, 3, 1), "tomorrow", ld(2021, 3, 2))]
|
#[case::tomorrow(ld(2021, 3, 1), "tomorrow", ld(2021, 3, 2))]
|
||||||
#[case::tomorow_from_evening(ldt(2021, 3, 1, 21, 30, 30), "tomorrow", ld(2021, 3, 2))]
|
#[case::tomorow_from_evening(ldt(2021, 3, 1, 21, 30, 30), "tomorrow", ld(2021, 3, 2))]
|
||||||
#[case::end_of_week(ld(2021,8,25,), "eow", ld(2021,8,29))]
|
#[case::end_of_week(ld(2021, 8, 25,), "eow", ld(2021, 8, 29))]
|
||||||
#[case::end_of_work_week(ld(2021,8,25), "eoww", ld(2021,8,28))]
|
#[case::end_of_work_week(ld(2021, 8, 25), "eoww", ld(2021, 8, 28))]
|
||||||
#[case::start_of_week(ld(2021,8,25), "sow", ld(2021,8,29))]
|
#[case::start_of_week(ld(2021, 8, 25), "sow", ld(2021, 8, 29))]
|
||||||
#[case::start_of_work_week(ld(2021,8,25), "soww", ld(2021,8,30))]
|
#[case::start_of_work_week(ld(2021, 8, 25), "soww", ld(2021, 8, 30))]
|
||||||
#[case::end_of_today(ld(2021,8,25), "eod", ld(2021,8,26))]
|
#[case::end_of_today(ld(2021, 8, 25), "eod", ld(2021, 8, 26))]
|
||||||
#[case::start_of_today(ld(2021,8,25), "sod", ld(2021,8,25))]
|
#[case::start_of_today(ld(2021, 8, 25), "sod", ld(2021, 8, 25))]
|
||||||
fn test_local_timestamp(
|
fn test_local_timestamp(
|
||||||
#[case] now: Box<dyn Fn(FixedOffset) -> DateTime<Utc>>,
|
#[case] now: Box<dyn Fn(FixedOffset) -> DateTime<Utc>>,
|
||||||
#[values(*IST, *UTC_FO, *HST)] tz: FixedOffset,
|
#[values(*IST, *UTC_FO, *HST)] tz: FixedOffset,
|
||||||
|
|||||||
@@ -113,9 +113,11 @@ impl<'t> Txn<'t> {
|
|||||||
fn get_next_working_set_number(&self) -> anyhow::Result<usize> {
|
fn get_next_working_set_number(&self) -> anyhow::Result<usize> {
|
||||||
let t = self.get_txn()?;
|
let t = self.get_txn()?;
|
||||||
let next_id: Option<usize> = t
|
let next_id: Option<usize> = t
|
||||||
.query_row("SELECT COALESCE(MAX(id), 0) + 1 FROM working_set", [], |r| {
|
.query_row(
|
||||||
r.get(0)
|
"SELECT COALESCE(MAX(id), 0) + 1 FROM working_set",
|
||||||
})
|
[],
|
||||||
|
|r| r.get(0),
|
||||||
|
)
|
||||||
.optional()
|
.optional()
|
||||||
.context("Getting highest working set ID")?;
|
.context("Getting highest working set ID")?;
|
||||||
|
|
||||||
@@ -290,7 +292,10 @@ impl<'t> StorageTxn for Txn<'t> {
|
|||||||
|
|
||||||
let rows: Vec<Result<(usize, Uuid), _>> = rows.collect();
|
let rows: Vec<Result<(usize, Uuid), _>> = rows.collect();
|
||||||
let mut res = Vec::with_capacity(rows.len());
|
let mut res = Vec::with_capacity(rows.len());
|
||||||
for _ in 0..self.get_next_working_set_number().context("Getting working set number")? {
|
for _ in 0..self
|
||||||
|
.get_next_working_set_number()
|
||||||
|
.context("Getting working set number")?
|
||||||
|
{
|
||||||
res.push(None);
|
res.push(None);
|
||||||
}
|
}
|
||||||
for r in rows {
|
for r in rows {
|
||||||
|
|||||||
Reference in New Issue
Block a user