memoryd: the day and the month of a time with get, never a slice
Implemented-By: OpenCode session (model recorded in docs/implementer-log.md)
This commit is contained in:
@@ -84,11 +84,7 @@ pub(crate) fn append(store: &Store, mut record: Record, now: Timestamp) -> Resul
|
||||
// `serde_json::to_string(&record)`, then `store.append(&format!("edits/{month}.jsonl"),
|
||||
// &format!("{line}\n"))?` where month is the first 7 characters of day. Ok(record.id).
|
||||
let rfc = now.to_rfc3339();
|
||||
let day = if rfc.len() >= 10 {
|
||||
&rfc[..10]
|
||||
} else {
|
||||
"0000-00-00"
|
||||
};
|
||||
let day = rfc.get(..10).unwrap_or("0000-00-00");
|
||||
let taken = records(store)?
|
||||
.iter()
|
||||
.filter(|r| r.id.starts_with(&format!("{day}-")))
|
||||
@@ -97,7 +93,7 @@ pub(crate) fn append(store: &Store, mut record: Record, now: Timestamp) -> Resul
|
||||
let edits_dir = store.path("edits");
|
||||
std::fs::create_dir_all(&edits_dir).map_err(|e| format!("{}: {e}", edits_dir.display()))?;
|
||||
let line = serde_json::to_string(&record).map_err(|e| e.to_string())?;
|
||||
let month = &day[..7];
|
||||
let month = day.get(..7).unwrap_or("0000-00");
|
||||
store.append(&format!("edits/{month}.jsonl"), &format!("{line}\n"))?;
|
||||
Ok(record.id)
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@ pub struct Note {
|
||||
/// A time as the notes show it: to the minute, in UTC.
|
||||
pub fn minute(time: Timestamp) -> String {
|
||||
let s = time.to_rfc3339();
|
||||
let head = if s.len() >= 16 { &s[..16] } else { &s };
|
||||
format!("{head}Z")
|
||||
format!("{}Z", s.get(..16).unwrap_or(&s))
|
||||
}
|
||||
|
||||
fn class_name(class: DataClass) -> &'static str {
|
||||
|
||||
@@ -158,7 +158,7 @@ pub fn recall(
|
||||
Some(fts) => search(index, &fts, args.k)?,
|
||||
};
|
||||
let rfc = now.to_rfc3339();
|
||||
let month = &rfc[..7];
|
||||
let month = rfc.get(..7).unwrap_or("0000-00");
|
||||
std::fs::create_dir_all(store.path("recalls")).map_err(|e| format!("recalls: {e}"))?;
|
||||
let logged = Logged {
|
||||
time: rfc.clone(),
|
||||
|
||||
@@ -100,7 +100,7 @@ pub fn submit(
|
||||
// accepted")).
|
||||
args.check()?;
|
||||
let rfc = ctx.now.to_rfc3339();
|
||||
let day = &rfc[..10];
|
||||
let day = rfc.get(..10).unwrap_or("0000-00-00");
|
||||
let taken = waiting(store)?
|
||||
.iter()
|
||||
.filter(|line| match line {
|
||||
|
||||
Reference in New Issue
Block a user