aboutsummaryrefslogtreecommitdiff
path: root/internal/caldata/caldata.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/caldata/caldata.go')
-rw-r--r--internal/caldata/caldata.go27
1 files changed, 26 insertions, 1 deletions
diff --git a/internal/caldata/caldata.go b/internal/caldata/caldata.go
index 9c17035..4e54f1f 100644
--- a/internal/caldata/caldata.go
+++ b/internal/caldata/caldata.go
@@ -77,9 +77,34 @@ func Tridentine() calendar.Layer {
return l
}
+// sanctoraleDir, when set, holds an optional external universal sanctorale that
+// overrides the embedded one (of.ini for OF, ef.ini for EF). Set once at startup
+// via SetSanctoraleDir; empty means "use the embedded calendar".
+var sanctoraleDir string
+
+// SetSanctoraleDir points caldata at the dir holding an optional external
+// universal sanctorale (<dir>/of.ini, <dir>/ef.ini). Empty disables it.
+func SetSanctoraleDir(dir string) { sanctoraleDir = dir }
+
// Base returns the universal base layer for a form: the 1962 calendar for
-// "old" (EF), the General Roman Calendar otherwise (OF).
+// "old" (EF), the General Roman Calendar otherwise (OF). If an external
+// sanctorale file is present and parses, it REPLACES the embedded calendar for
+// that form -- so the saints and ranks can be updated without a rebuild. A
+// missing or malformed external file falls back to the embedded default, which
+// therefore always keeps the tool self-contained and correct out of the box.
func Base(form string) calendar.Layer {
+ if sanctoraleDir != "" {
+ name := "of.ini"
+ if form == "old" {
+ name = "ef.ini"
+ }
+ if data, err := os.ReadFile(filepath.Join(sanctoraleDir, name)); err == nil {
+ if l, err := ParseLayer(data); err == nil {
+ return l
+ }
+ // malformed external file: fall through to the embedded default
+ }
+ }
if form == "old" {
return Tridentine()
}