Skip to content

Commit 242cbf7

Browse files
committed
style: switch default amount of time and change --year to --ytd
1 parent 0e7e645 commit 242cbf7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Options:
2525
--color2 <HEX> Set color for second quartile
2626
--color3 <HEX> Set color for third quartile
2727
--color4 <HEX> Set color for fourth quartile
28-
--year Display the past year's worth of data
28+
--ytd Display the past year's worth of data
2929
--month Display the past month's worth of data
3030
--token <GITHUB_TOKEN> GitHub PAT token (uses $GITHUB_TOKEN if not specified)
3131
--hide-days Hide day-of-the-week string
@@ -68,4 +68,4 @@ The `--hide-days` and `--hide-months` arguments can be used to hide the respecti
6868
6969
## Time
7070
71-
By default, `gitcal` will display the year-to-date information. However, the `--year` and `--month` arguments can be used to instead use the past 365 days and the days since the beginning of the month respectively.
71+
By default, `gitcal` will display past 365 days of information. However, the `--ytd` and `--month` arguments can be used to instead use the year-to-date starting at January 1st or the days since the beginning of the month respectively.

src/main.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,11 @@ fn main() -> Result<(), Box<dyn Error>> {
319319
.arg(arg!(--color2 <HEX> "Set color for second quartile"))
320320
.arg(arg!(--color3 <HEX> "Set color for third quartile"))
321321
.arg(arg!(--color4 <HEX> "Set color for fourth quartile"))
322-
.arg(arg!(--year "Display the past year's worth of data"))
322+
.arg(arg!(--ytd "Display the past year's worth of data"))
323323
.arg(arg!(--month "Display the past month's worth of data"))
324324
.group(
325325
ArgGroup::new("time")
326-
.args(["year", "month"])
326+
.args(["ytd", "month"])
327327
.multiple(false)
328328
.required(false),
329329
)
@@ -377,14 +377,14 @@ fn main() -> Result<(), Box<dyn Error>> {
377377

378378
let now = Local::now();
379379
let now_formatted = now.format("%Y-%m-%dT%H:%M:%S");
380-
let time_start_formatted = if matches.get_flag("year") {
381-
now - Duration::days(365)
380+
let time_start_formatted = if matches.get_flag("ytd") {
381+
Local.with_ymd_and_hms(now.year(), 1, 1, 0, 0, 0).unwrap()
382382
} else if matches.get_flag("month") {
383383
Local
384384
.with_ymd_and_hms(now.year(), now.month(), 1, 0, 0, 0)
385385
.unwrap()
386386
} else {
387-
Local.with_ymd_and_hms(now.year(), 1, 1, 0, 0, 0).unwrap()
387+
now - Duration::days(365)
388388
}
389389
.format("%Y-%m-%dT%H:%M:%S");
390390

0 commit comments

Comments
 (0)