aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-05-10 13:44:11 +0200
committerGravatar Christian Hesse <mail@eworm.de>2023-05-10 20:02:44 +0200
commitbafd71344d2d2c1523b0f3a34ac238a59fb46d27 (patch)
treefc19d4a9ccc4de12ddd9039cb26a92c5ce6d3489
parente7927e0eee62ea331e97c3e572b12a594eca14fd (diff)
global-functions: introduce $ParseDate
The extra indention is intended for a later change.
-rw-r--r--global-functions.rsc13
1 files changed, 13 insertions, 0 deletions
diff --git a/global-functions.rsc b/global-functions.rsc
index 4ec5857..fa8b767 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -45,6 +45,7 @@
:global LogPrintExit2;
:global MkDir;
:global NotificationFunctions;
+:global ParseDate;
:global ParseKeyValueStore;
:global PrettyPrint;
:global RandomDelay;
@@ -682,6 +683,18 @@
:set NotificationFunctions ({});
}
+# parse the date and return a named array
+:set ParseDate do={
+ :local Date [ :tostr $1 ];
+
+ :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 };
+
+ :return ({ "year"=[ :tonum [ :pick $Date 7 11 ] ];
+ "month"=($Months->[ :pick $Date 0 3 ]);
+ "day"=[ :tonum [ :pick $Date 4 6 ] ] });
+}
+
# parse key value store
:set ParseKeyValueStore do={
:local Source $1;