blob: fa3ac7ed38a36cf33e13b846b4f865407689c510 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
use super::prelude::*;
lazy_static! {
static ref NINE_AM: chrono::NaiveTime = chrono::NaiveTime::from_hms(9, 0, 0);
static ref NINE_PM: chrono::NaiveTime = chrono::NaiveTime::from_hms(21, 0, 0);
static ref PIANOMANS: Vec<TodayArgs> = vec![
by_url("https://www.youtube.com/watch?v=gxEPV4kolz0"),
TodayArgs {
url: "https://www.youtube.com/watch?v=gxEPV4kolz0",
start: Some(Duration::seconds(30)),
end: Some(Duration::seconds(34)),
}
];
}
pub fn pianoman(dt: chrono::NaiveDateTime) -> TodayIter {
if dt.weekday() != chrono::Weekday::Sat {
return Box::new(empty());
}
let near_9am = duration_abs(*NINE_AM - dt.time()) <= Duration::minutes(5);
let near_9pm = duration_abs(*NINE_PM - dt.time()) <= Duration::minutes(5);
if !near_9am && !near_9pm {
return Box::new(empty());
}
Box::new(PIANOMANS.iter().cloned())
}
fn duration_abs(d: Duration) -> Duration {
if d < chrono::Duration::zero() {
-d
} else {
d
}
}
|