There is no standard way to transfer dates and times using either url parameters or JSON. Keep in mind that TDateTime
is actually a double
behind the scenes, so defining the method like in your example, the argument should be given as a floating point number in the url.
If you want to accept a date as an ISO8601 string, you have to define the argument as a string
type and manually do the conversion. Here is one function I use in my own code for exactly this type of problem.
uses
Soap.XSBuiltIns;
function ISODateStrToDate(DateStr: string): TDateTime;
var
xsDate: TXSDate;
begin
xsDate := TXSDate.Create;
try
xsDate.XSToNative(DateStr);
Exit(xsDate.AsDate);
finally
xsDate.Free;
end;
end;
This function throws away the time portion of the ISO8601 string. I don't need it in most cases.
If you need the time portion, you can possibly use
function XMLTimeToDateTime(const XMLDateTime: InvString; AsUTCTime: Boolean = False): TDateTime;
this is from the same Soap.XSBuiltIns unit, however BE WARNED! This function only works correctly for full ISO8601 strings which includes full time zone information (the +01:00 or -05:00 ending part). For your example ISO8601 datetime it will act as if you have given the time in UTC time and it will try to convert it to a TDateTime value in local time.