fix(daily): use midnight when creating file for non-today date
This commit is contained in:
parent
d0e4dccd1a
commit
d872e9e338
1 changed files with 8 additions and 1 deletions
|
|
@ -65,7 +65,14 @@ pub fn run(date: Option<String>) -> Result<(), StreamdError> {
|
||||||
Command::new(&editor).arg(file_path).status()?;
|
Command::new(&editor).arg(file_path).status()?;
|
||||||
} else {
|
} else {
|
||||||
let now_local = Utc::now().with_timezone(&tz);
|
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);
|
let file_path = base_folder.join(&file_name);
|
||||||
fs::write(&file_path, "# ")?;
|
fs::write(&file_path, "# ")?;
|
||||||
Command::new(&editor).arg(&file_path).status()?;
|
Command::new(&editor).arg(&file_path).status()?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue