mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Merge pull request #52 from haganbmj/script_to_date
Script: to_date accepts "now" as an argument
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user