aboutsummaryrefslogtreecommitdiff
path: root/www/framework
diff options
context:
space:
mode:
Diffstat (limited to 'www/framework')
-rw-r--r--www/framework/event.nix30
1 files changed, 30 insertions, 0 deletions
diff --git a/www/framework/event.nix b/www/framework/event.nix
index dcd4265..f0489db 100644
--- a/www/framework/event.nix
+++ b/www/framework/event.nix
@@ -6,6 +6,25 @@
inherit (lib) mkOption types;
cfg = event.config;
sort-key = e: "${e.date.start} ${e.time.start}";
+ # https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Sakamoto's_methods
+ weekday =
+ date:
+ let
+ parts = map lib.toIntBase10 (lib.splitString "-" date);
+ m = lib.elemAt parts 1;
+ d = lib.elemAt parts 2;
+ y = lib.elemAt parts 0 - (if m < 3 then 1 else 0);
+ offset = lib.elemAt [ 0 3 2 5 0 3 5 1 4 6 2 4 ] (m - 1);
+ in
+ lib.elemAt [
+ "Sonntag"
+ "Montag"
+ "Dienstag"
+ "Mittwoch"
+ "Donnerstag"
+ "Freitag"
+ "Samstag"
+ ] (lib.mod (y + y / 4 - y / 100 + y / 400 + offset + d) 7);
prior =
let
candidates = lib.filter (
@@ -157,6 +176,17 @@
'';
type = types.str;
example = "Samstag, 20.12.2025 von 15:00 bis 17:00 Uhr";
+ default =
+ let
+ date = lib.concatStringsSep "." (lib.reverseList (lib.splitString "-" cfg.date.start));
+ time =
+ if cfg.time.end == null then
+ "ab ${cfg.time.start}"
+ else
+ "von ${cfg.time.start} bis ${cfg.time.end}";
+ in
+ "${weekday cfg.date.start}, ${date} ${time}";
+ defaultText = lib.literalMD "Wochentag, Datum und Uhrzeit aus den Zeitangaben des Termins";
};
venue = mkOption {
description = ''