Time type problem

Hi, I’m having a strange Time type conversion problem; I have a time(7) column in my MS SQL Db, mapped in my POCO as:

public TimeSpan? AN07_ORAAMAPRE { get; set; }

I configured Servicestack this way:

JsConfig.DateHandler = DateHandler.ISO8601;

var dates = OrmLiteConfig.DialectProvider.GetDateTimeConverter();
dates.DateStyle = DateTimeKind.Utc;

SqlServerDialect.Provider.RegisterConverter<TimeSpan>(new SqlServerTimeConverter
{
    Precision = 7
})

Now… when I call my service that handle this time type I’ve get back: PT17H8M instead of 17:08:00; what kind of format is that? Is PT stands for Pacific Time? (I’m not in a Pacific Time zone…).
How can I format my time types as simple hh:mm:ss?

Maybe stupid question but why TimeSpan, not DateTime?

I’ve read here: https://github.com/ServiceStack/ServiceStack.OrmLite/wiki/OrmLite-Type-Converters#sql-server-time-converter that the time column can be enabled by registering the SqlServerTimeConverter… so, if I’m not wrong, I think is the way to do it…

I’ve solved my own problem this way:

JsConfig.TimeSpanHandler = TimeSpanHandler.StandardFormat;

How TimeSpans are serialized is independent from how they’re stored in OrmLite.

ServiceStack.Text uses XSD Duration Format by default so PT17H8M stands for:

  • P = Time Period
  • T = Time Separator
  • 17H = 17th Hour (5pm)
  • 8M = 8 minutes