aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Perry <np@nathanperry.dev>2020-09-26 16:13:43 -0400
committerNathan Perry <np@nathanperry.dev>2020-09-26 16:13:43 -0400
commitab69488340af2133cf99d67b11e619b5cac467b5 (patch)
tree11e29658105b157c0a996ab0f6fa507ec36fbe38
parent23ce35dffe6b8b1fc6e5fd418db6a63922b20c86 (diff)
implement piano man
-rw-r--r--src/commands/today/mod.rs6
-rw-r--r--src/commands/today/pianoman.rs26
2 files changed, 30 insertions, 2 deletions
diff --git a/src/commands/today/mod.rs b/src/commands/today/mod.rs
index 50cee99..e18a01e 100644
--- a/src/commands/today/mod.rs
+++ b/src/commands/today/mod.rs
@@ -37,9 +37,10 @@ mod france;
mod shrek;
mod wednesday;
-
mod tomorrow;
+mod pianoman;
+
pub type TodayIter = Box<dyn Iterator<Item=TodayArgs>>;
#[derive(Clone, Debug, Hash, Default)]
@@ -74,8 +75,9 @@ lazy_static! {
shrek::shrek,
wednesday::wednesday,
-
tomorrow::tomorrow,
+
+ pianoman::pianoman,
];
}
diff --git a/src/commands/today/pianoman.rs b/src/commands/today/pianoman.rs
new file mode 100644
index 0000000..d2f11a5
--- /dev/null
+++ b/src/commands/today/pianoman.rs
@@ -0,0 +1,26 @@
+use super::prelude::*;
+
+lazy_static! {
+ static ref TARGET_TIME: chrono::NaiveTime = chrono::NaiveTime::from_hms(21, 0, 0);
+}
+
+pub fn pianoman(dt: chrono::NaiveDateTime) -> TodayIter {
+ if dt.weekday() != chrono::Weekday::Fri {
+ return Box::new(empty());
+ }
+
+ let diff = {
+ let result = *TARGET_TIME - dt.time();
+ if result < chrono::Duration::zero() {
+ -result
+ } else {
+ result
+ }
+ };
+
+ if diff > Duration::minutes(5) {
+ return Box::new(empty());
+ }
+
+ Box::new(once(by_url("https://www.youtube.com/watch?v=gxEPV4kolz0")))
+}