aboutsummaryrefslogtreecommitdiffstats
path: root/daily-psk.template.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-05-10 13:28:51 +0200
committerGravatar Christian Hesse <mail@eworm.de>2023-05-10 18:10:31 +0200
commitd586a5ab1975e7f06a43f816e3809753d9606cba (patch)
tree5f48c1de9c893039359b6150cb957b9cf8c3dbda /daily-psk.template.rsc
parent3fe66c841392c8cbfa6d6514fe0b2f685911364a (diff)
daily-psk: simplify calculation
Use a named array, and drop the loop...
Diffstat (limited to 'daily-psk.template.rsc')
-rw-r--r--daily-psk.template.rsc12
1 files changed, 3 insertions, 9 deletions
diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc
index 5f30ce3..e2a3d59 100644
--- a/daily-psk.template.rsc
+++ b/daily-psk.template.rsc
@@ -34,19 +34,13 @@ $WaitFullyConnected;
:global DailyPskSecrets;
- :local Months { "jan"; "feb"; "mar"; "apr"; "may"; "jun";
- "jul"; "aug"; "sep"; "oct"; "nov"; "dec" };
+ :local Months { "jan"=1; "feb"=2; "mar"=3; "apr"=4; "may"=5; "jun"=6;
+ "jul"=7; "aug"=8; "sep"=9; "oct"=10; "nov"=11; "dec"=12 };
- :local Month [ :pick $Date 0 3 ];
+ :local Month ($Months->[ :pick $Date 0 3 ]);
:local Day [ :tonum [ :pick $Date 4 6 ] ];
:local Year [ :pick $Date 7 11 ];
- :for MIndex from=0 to=[ :len $Months ] do={
- :if ($Months->$MIndex = $Month) do={
- :set Month ($MIndex + 1);
- }
- }
-
:local A ((14 - $Month) / 12);
:local B ($Year - $A);
:local C ($Month + 12 * $A - 2);