fix(daily): use midnight when creating file for non-today date

This commit is contained in:
Konstantin Fickel 2026-04-19 10:55:13 +02:00
parent 5c6a88a211
commit dbf0808233
Signed by: kfickel
GPG key ID: A793722F9933C1A5

View file

@ -65,7 +65,14 @@ pub fn run(date: Option<String>) -> Result<(), StreamdError> {
Command::new(&editor).arg(file_path).status()?;
} else {
let now_local = Utc::now().with_timezone(&tz);
let file_name = now_local.format("%Y%m%d-%H%M%S_daily.md").to_string();
let file_timestamp = if target_date == now_local.date_naive() {
now_local
} else {
tz.from_local_datetime(&NaiveDateTime::new(target_date, NaiveTime::MIN))
.earliest()
.unwrap()
};
let file_name = file_timestamp.format("%Y%m%d-%H%M%S_daily.md").to_string();
let file_path = base_folder.join(&file_name);
fs::write(&file_path, "# ")?;
Command::new(&editor).arg(&file_path).status()?;