Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/function/to_date.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 10 additions & 3 deletions src/script/functions/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down