simplify day and month literals

Sat, 01 Feb 2025 14:04:19 +0100

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

simplify day and month literals

src/html.cpp file | annotate | diff | comparison | revisions
src/main.cpp file | annotate | diff | comparison | revisions
--- a/src/html.cpp	Sat Feb 01 13:59:01 2025 +0100
+++ b/src/html.cpp	Sat Feb 01 14:04:19 2025 +0100
@@ -27,6 +27,7 @@
 #include <cstdio>
 
 namespace chrono = std::chrono;
+using chrono::operator ""d;
 
 namespace html {
     static constexpr const char* weekdays[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
@@ -140,7 +141,7 @@
     unsigned colspans[12] = {};
     {
         unsigned total_cols = 0;
-        chrono::sys_days day{chrono::year_month_day{chrono::year{year}, chrono::month{1}, chrono::day{1}}};
+        chrono::sys_days day{chrono::year_month_day{chrono::year{year}, chrono::January, 1d}};
         if (chrono::weekday{day}.iso_encoding() != 1) {
             colspans[0] = 1;
             total_cols = 1;
--- a/src/main.cpp	Sat Feb 01 13:59:01 2025 +0100
+++ b/src/main.cpp	Sat Feb 01 14:04:19 2025 +0100
@@ -35,6 +35,7 @@
 #include <cerrno>
 
 namespace chrono = std::chrono;
+using chrono::operator ""d;
 
 static void print_help() {
     fputs(
@@ -184,8 +185,8 @@
     } else {
         year = settings.year;
     }
-    chrono::year_month_day report_begin{chrono::year{year}, chrono::month{1}, chrono::day{1}};
-    chrono::year_month_day report_end{chrono::year{year}, chrono::month{12}, chrono::day{31}};
+    chrono::year_month_day report_begin{chrono::year{year}, chrono::January, 1d};
+    chrono::year_month_day report_end{chrono::year{year}, chrono::December, 31d};
 
     // read the commit logs
     fm::heatmap heatmap;

mercurial