use chrono API to determine the first monday in the year instead of calculating it

Sat, 01 Feb 2025 14:11:46 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 01 Feb 2025 14:11:46 +0100
changeset 12
d869ff924c19
parent 11
127fb6a8f706
child 13
e714005f3e9d

use chrono API to determine the first monday in the year instead of calculating it

src/main.cpp file | annotate | diff | comparison | revisions
--- a/src/main.cpp	Sat Feb 01 14:04:19 2025 +0100
+++ b/src/main.cpp	Sat Feb 01 14:11:46 2025 +0100
@@ -228,8 +228,7 @@
             unsigned column = 0, row = 0;
 
             // initialize first day (which must be a Monday, possibly the year before)
-            chrono::sys_days day_to_check{report_begin};
-            day_to_check -= chrono::days{chrono::weekday{day_to_check}.iso_encoding() - 1};
+            chrono::sys_days day_to_check = chrono::January / chrono::Monday[1] / chrono::year{year};
 
             // remember the starting point
             auto start = day_to_check;

mercurial