Commit 6f6c93dccc3f820f369f10ed117b6dac42e1923d
1 parent
32f8435d
add get datetime, date and time with default value in webarg
Showing
1 changed file
with
39 additions
and
0 deletions
Show diff stats
web/CXM_web_arg_utils.anubis
| @@ -97,6 +97,19 @@ public define Maybe(DB_date) | @@ -97,6 +97,19 @@ public define Maybe(DB_date) | ||
| 97 | found(value) then success(db_date(value)) | 97 | found(value) then success(db_date(value)) |
| 98 | }. | 98 | }. |
| 99 | 99 | ||
| 100 | +public define DB_date | ||
| 101 | + get_DB_date | ||
| 102 | + ( | ||
| 103 | + List(Web_arg) lwa, | ||
| 104 | + String arg_name, | ||
| 105 | + DB_date default | ||
| 106 | + ) = | ||
| 107 | + if web_arg_value(lwa, arg_name) is | ||
| 108 | + { | ||
| 109 | + not_found then default, | ||
| 110 | + found(value) then db_date(value) | ||
| 111 | + }. | ||
| 112 | + | ||
| 100 | public define Maybe(DB_time) | 113 | public define Maybe(DB_time) |
| 101 | get_DB_time | 114 | get_DB_time |
| 102 | ( | 115 | ( |
| @@ -109,6 +122,19 @@ public define Maybe(DB_time) | @@ -109,6 +122,19 @@ public define Maybe(DB_time) | ||
| 109 | found(value) then success(db_time(value)) | 122 | found(value) then success(db_time(value)) |
| 110 | }. | 123 | }. |
| 111 | 124 | ||
| 125 | +public define DB_time | ||
| 126 | + get_DB_time | ||
| 127 | + ( | ||
| 128 | + List(Web_arg) lwa, | ||
| 129 | + String arg_name, | ||
| 130 | + DB_time default | ||
| 131 | + ) = | ||
| 132 | + if web_arg_value(lwa, arg_name) is | ||
| 133 | + { | ||
| 134 | + not_found then default, | ||
| 135 | + found(value) then db_time(value) | ||
| 136 | + }. | ||
| 137 | + | ||
| 112 | public define Maybe(DB_datetime) | 138 | public define Maybe(DB_datetime) |
| 113 | get_DB_datetime | 139 | get_DB_datetime |
| 114 | ( | 140 | ( |
| @@ -120,6 +146,19 @@ public define Maybe(DB_datetime) | @@ -120,6 +146,19 @@ public define Maybe(DB_datetime) | ||
| 120 | not_found then failure, | 146 | not_found then failure, |
| 121 | found(value) then success(db_datetime(value)) | 147 | found(value) then success(db_datetime(value)) |
| 122 | }. | 148 | }. |
| 149 | + | ||
| 150 | +public define DB_datetime | ||
| 151 | + get_DB_datetime | ||
| 152 | + ( | ||
| 153 | + List(Web_arg) lwa, | ||
| 154 | + String arg_name, | ||
| 155 | + DB_datetime default | ||
| 156 | + ) = | ||
| 157 | + if web_arg_value(lwa, arg_name) is | ||
| 158 | + { | ||
| 159 | + not_found then default, | ||
| 160 | + found(value) then db_datetime(value) | ||
| 161 | + }. | ||
| 123 | 162 | ||
| 124 | public define Maybe(String) | 163 | public define Maybe(String) |
| 125 | get_String | 164 | get_String |