mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
daily-psk: simplify calculation
Use a named array, and drop the loop...
This commit is contained in:
parent
3fe66c8413
commit
d586a5ab19
|
@ -33,19 +33,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);
|
||||
|
|
|
@ -33,19 +33,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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue