generated from Astrial.org/template
feat: use day ordinal for folder names
This commit is contained in:
parent
feeac0ff2d
commit
8a40d7704a
1 changed files with 5 additions and 3 deletions
|
@ -1,8 +1,9 @@
|
||||||
mod args;
|
mod args;
|
||||||
|
|
||||||
use args::{Args, Config};
|
use args::{Args, Config};
|
||||||
|
use chrono::Datelike;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use diaryrs::{macros::UnwrapOrFatalAble, time::Time};
|
use diaryrs::{macros::UnwrapOrFatalAble, time::Time, util};
|
||||||
use indoc::formatdoc;
|
use indoc::formatdoc;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
|
@ -31,13 +32,14 @@ fn main() {
|
||||||
let month = time.datetime.format("%m").to_string();
|
let month = time.datetime.format("%m").to_string();
|
||||||
let month_name = time.datetime.format("%B").to_string();
|
let month_name = time.datetime.format("%B").to_string();
|
||||||
let day = time.datetime.format("%d").to_string();
|
let day = time.datetime.format("%d").to_string();
|
||||||
|
let day_ordinal = util::ordinal(time.datetime.day());
|
||||||
let ymd = format!("{}-{}-{}", year, month, day);
|
let ymd = format!("{}-{}-{}", year, month, day);
|
||||||
|
|
||||||
let dir_path = config
|
let dir_path = config
|
||||||
.base_path
|
.base_path
|
||||||
.join(&year)
|
.join(&year)
|
||||||
.join(&month_name)
|
.join(&month_name)
|
||||||
.join(&ymd);
|
.join(&day_ordinal);
|
||||||
fs::create_dir_all(&dir_path)
|
fs::create_dir_all(&dir_path)
|
||||||
.unwrap_or_fatal("Failed to create directory for today's entry");
|
.unwrap_or_fatal("Failed to create directory for today's entry");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue