global-functions: $ParseDate: handle date in ISO standard format

This was introduced with RouterOS 7.10beta5...

https://xkcd.com/1179/ 😜
This commit is contained in:
Christian Hesse 2023-05-10 14:42:48 +02:00
parent bafd71344d
commit 60f863871c

View file

@ -687,12 +687,18 @@
:set ParseDate do={ :set ParseDate do={
:local Date [ :tostr $1 ]; :local Date [ :tostr $1 ];
:if ([ :pick $Date 4 5 ] != "-") do={
:local Months { "jan"=1; "feb"=2; "mar"=3; "apr"=4; "may"=5; "jun"=6; :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 }; "jul"=7; "aug"=8; "sep"=9; "oct"=10; "nov"=11; "dec"=12 };
:return ({ "year"=[ :tonum [ :pick $Date 7 11 ] ]; :return ({ "year"=[ :tonum [ :pick $Date 7 11 ] ];
"month"=($Months->[ :pick $Date 0 3 ]); "month"=($Months->[ :pick $Date 0 3 ]);
"day"=[ :tonum [ :pick $Date 4 6 ] ] }); "day"=[ :tonum [ :pick $Date 4 6 ] ] });
}
:return ({ "year"=[ :tonum [ :pick $Date 0 4 ] ];
"month"=[ :tonum [ :pick $Date 5 7 ] ];
"day"=[ :tonum [ :pick $Date 8 10 ] ] });
} }
# parse key value store # parse key value store