summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 6ac8784..52169b4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,15 +1,19 @@
#![feature(negative_impls)]
#![feature(freeze)]
#![feature(freeze_impls)]
+#![feature(portable_simd)]
#![allow(internal_features)]
#![allow(mutable_transmutes)]
use maud::{html, Markup, PreEscaped, DOCTYPE};
-use regex::{Match, Regex};
use std::mem::{take, transmute};
use worker::*;
+pub mod dateparse;
pub mod solar;
-use crate::solar::{dow, solar};
+use crate::{
+ dateparse::dateparse,
+ solar::{dow, solar},
+};
async fn text(r: &mut Response) -> Result<String> {
match r.body() {
@@ -33,9 +37,6 @@ async fn fetch(req: Request, env: Env, _ctx: Context) -> Result<Response> {
let a = ctx.env.assets("ASSETS")?;
let mut a = a.fetch(u.join("_/diary")?, None).await?;
let a = text(&mut a).await?;
- let re = Regex::new(
- r"(0[1-9]|[1-9]|1[0-2])\/(0[1-9]|[1-9]|1\d|2\d|3[01])\/(\d{2})$",
- ).unwrap();
bone("shitpit", "look in the sky! it's a bird! it's a plane! no it's superego!", html! {
p {
"The numbering system for people (#1, #2, ...) is arbitrary and "
@@ -51,12 +52,11 @@ async fn fetch(req: Request, env: Env, _ctx: Context) -> Result<Response> {
}
pre {
@for x in a.split('\n').map(|l| {
- re.captures(l)
+ dateparse(l)
.map_or_else(|| html! { (PreEscaped(l)) "\n" },
|c| {
- let (m, d, y) = (c.get(1), c.get(2), c.get(3));
- let f = |x: Option<Match>| -> usize { x.unwrap().as_str().parse().unwrap() };
- let (y, m, d) = (f(y) + 2000, f(m), f(d));
+ let (m, d, y) = c;
+ let y = y + 2000;
let s = solar(y, m, d);
let (dowc, dowl) = dow(y, m, d);
let (y, m, d, t) = (s.year, s.month, s.day, s.term);