Script: to_date accepts "now" as an argument

indentation fix
This commit is contained in:
Djack Donovan
2022-10-04 15:26:33 +02:00
committed by Brendan Hagan
parent 46ab8870d1
commit d1bac74eb9
2 changed files with 12 additions and 3 deletions
+2
View File
@@ -14,6 +14,8 @@ Convert a string value to a [[type:date]].
--Examples-- --Examples--
> to_date("2008-12-31 23:59:59") > to_date("2008-12-31 23:59:59")
> to_date("today midnight") > to_date("today midnight")
> to_date("today noon")
> to_date("now")
--See also-- --See also--
| [[fun:to_string]] Convert dates to strings | [[fun:to_string]] Convert dates to strings
+8 -1
View File
@@ -216,9 +216,16 @@ SCRIPT_FUNCTION(to_color) {
SCRIPT_FUNCTION(to_date) { SCRIPT_FUNCTION(to_date) {
try { try {
SCRIPT_PARAM_C(String, input);
if (input == "now") {
SCRIPT_RETURN(wxDateTime::Now());
}
else {
SCRIPT_PARAM_C(wxDateTime, input); SCRIPT_PARAM_C(wxDateTime, input);
SCRIPT_RETURN(input); SCRIPT_RETURN(input);
} catch (const ScriptError& e) { }
}
catch (const ScriptError& e) {
return delay_error(e); return delay_error(e);
} }
} }