Merge pull request #52 from haganbmj/script_to_date

Script: to_date accepts "now" as an argument
This commit is contained in:
Brendan Hagan
2022-11-18 22:11:29 -05:00
committed by GitHub
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--
> to_date("2008-12-31 23:59:59")
> to_date("today midnight")
> to_date("today noon")
> to_date("now")
--See also--
| [[fun:to_string]] Convert dates to strings
+10 -3
View File
@@ -216,9 +216,16 @@ SCRIPT_FUNCTION(to_color) {
SCRIPT_FUNCTION(to_date) {
try {
SCRIPT_PARAM_C(wxDateTime, input);
SCRIPT_RETURN(input);
} catch (const ScriptError& e) {
SCRIPT_PARAM_C(String, input);
if (input == "now") {
SCRIPT_RETURN(wxDateTime::Now());
}
else {
SCRIPT_PARAM_C(wxDateTime, input);
SCRIPT_RETURN(input);
}
}
catch (const ScriptError& e) {
return delay_error(e);
}
}