Latest Service Stack breaks how DateTimes are deserialized?

Hi all,

We got a service stack project and we have been using it in prod for a while now. Lately we upgraded to the latest service stack packages and upgraded our service in our staging environment.

Suddenly all of our functional tests started breaking as the dates no longer come back as UTC but are converted to local time.

I tried doing this on the client side and the server side - didnt work.

        ServiceStack.Text.JsConfig.AssumeUtc = true;
        ServiceStack.Text.JsConfig.AlwaysUseUtc = true;
        ServiceStack.Text.JsConfig.DateHandler = DateHandler.ISO8601;
        ServiceStack.Text.JsConfig.SkipDateTimeConversion = true;

Any ideas? I m desperate - my developers have started doing .ToUniversalTime on pretty much every date on our project and i stopped them cause it’s insane…

Can you provide a standalone sample which shows the issue with UTC conversion? And the timezone at which your server is located.

What version did you upgrade from? and can you provide an example of a sample JSON with a DateTime then vs what it is now?

BTW one solution if you want to ensure UTC DateTime’s are serialized in a ISO 8601 format is to take over serialization of DateTime with:

JsConfig<DateTime>.SerializeFn = date => 
    date.ToUniversalTime().ToString("o", CultureInfo.InvariantCulture);
JsConfig<DateTime?>.SerializeFn = date => 
    date.Value.ToUniversalTime().ToString("o", CultureInfo.InvariantCulture);

My apologies everyone. It seems to be a change in JSON.NET serialization / deserialization rather than a ServceStack one. I tried to delete this post but couldnt. Consider it solved. Thanks