From 6f6c93dccc3f820f369f10ed117b6dac42e1923d Mon Sep 17 00:00:00 2001 From: totoro Date: Tue, 20 Jun 2017 19:55:01 +0200 Subject: [PATCH] add get datetime, date and time with default value in webarg --- web/CXM_web_arg_utils.anubis | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+), 0 deletions(-) diff --git a/web/CXM_web_arg_utils.anubis b/web/CXM_web_arg_utils.anubis index bac6ee9..f33dd6e 100644 --- a/web/CXM_web_arg_utils.anubis +++ b/web/CXM_web_arg_utils.anubis @@ -97,6 +97,19 @@ public define Maybe(DB_date) found(value) then success(db_date(value)) }. +public define DB_date + get_DB_date + ( + List(Web_arg) lwa, + String arg_name, + DB_date default + ) = + if web_arg_value(lwa, arg_name) is + { + not_found then default, + found(value) then db_date(value) + }. + public define Maybe(DB_time) get_DB_time ( @@ -109,6 +122,19 @@ public define Maybe(DB_time) found(value) then success(db_time(value)) }. +public define DB_time + get_DB_time + ( + List(Web_arg) lwa, + String arg_name, + DB_time default + ) = + if web_arg_value(lwa, arg_name) is + { + not_found then default, + found(value) then db_time(value) + }. + public define Maybe(DB_datetime) get_DB_datetime ( @@ -120,6 +146,19 @@ public define Maybe(DB_datetime) not_found then failure, found(value) then success(db_datetime(value)) }. + +public define DB_datetime + get_DB_datetime + ( + List(Web_arg) lwa, + String arg_name, + DB_datetime default + ) = + if web_arg_value(lwa, arg_name) is + { + not_found then default, + found(value) then db_datetime(value) + }. public define Maybe(String) get_String -- libgit2 0.21.4