added common business date acronyms
This commit is contained in:
@@ -154,11 +154,18 @@ fn named_date<Tz: TimeZone>(
|
|||||||
move |input: &str| {
|
move |input: &str| {
|
||||||
let local_today = now.with_timezone(&local).date();
|
let local_today = now.with_timezone(&local).date();
|
||||||
let remaining = &input[input.len()..];
|
let remaining = &input[input.len()..];
|
||||||
|
let day_index = local_today.weekday().num_days_from_monday();
|
||||||
match input {
|
match input {
|
||||||
"yesterday" => Ok((remaining, local_today - Duration::days(1))),
|
"yesterday" => Ok((remaining, local_today - Duration::days(1))),
|
||||||
"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))),
|
||||||
|
"sod"=>Ok((remaining,local_today)),
|
||||||
|
"eow"=> Ok((remaining,local_today+Duration::days((6-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)))
|
||||||
|
|||||||
Reference in New Issue
Block a user