Search code examples
c#devexpressxpoxaf

Save time like TimeSpan and parse it


I using xaf and xpo for my app. I have TimeSpan field for time:

private TimeSpan showTime;

public TimeSpan ShowTime
{
    get { return showTime; }
    set { SetPropertyValue("ShowTime", ref showTime, value); }
}

In the DB it saves like float.
In the app(generated by DevExpress) the time shows normally: 22:00:00, in the table like:79200 In another project I load data from this column and I can't parse it.

<li><a href="#"><%=TimeSpan.Parse(schedule.ShowTime.Value.ToString()) %></a></li>

I have got: 79200.00:00:00

How to parse properly?
Thanks.


Solution

  • If schedule.ShowTime.Value is of type double which is the amount of seconds, you need to use FromSeconds method:

    <%=TimeSpan.FromSeconds(schedule.ShowTime.Value) %>