Reputation: 73
I have a simple method DateTimeNow, which returns DateTime.Now.
When starting the project in Visual Studio, I get to the /metadata page and I can see the method listed as:
Operations:
DateTimeNow XML JSON
When clicking the XML link, I get:
<DateTimeNowResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/MyServices.DTO">
<Result>0001-01-01T00:00:00</Result>
</DateTimeNowResponse>
But when clicking the JSON link, I get:
Server Error in '/' Application.
--------------------------------------------------------------------------------
The added or subtracted value results in an un-representable DateTime.
Parameter name: value
I started by creating the project as shown on http://www.servicestack.net/ServiceStack.Hello/
I am using version 3.9.46:
ServiceStack.3.9.46\lib\net35\ServiceStack.dll
ServiceStack.3.9.46\lib\net35\ServiceStack.ServiceInterface.dll
ServiceStack.Common.3.9.46\lib\net35\ServiceStack.Common.dll
ServiceStack.Common.3.9.46\lib\net35\ServiceStack.Interfaces.dll
ServiceStack.Text.3.9.46\lib\net35\ServiceStack.Text.dll
The Visual Studio 2012 project uses .NET Framework 4.5
Upvotes: 1
Views: 350
Reputation: 20772
JSON dates use the JavaScript Date object, which represents dates as the number of seconds since 1970-01-01 00:00:00 UTC. You are converting a time that is before then so it can't be represented.
Upvotes: 2