Save time like TimeSpan and parse it
-
23-03-2021 - |
Question
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.
La 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) %>
Autres conseils
There's a solution to allow a user to enter TimeSpan as Text and save it as it's a time span. Take a look http://mdworkstuff.blogspot.com/2011/03/timespan-editor-for-xaf.html
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow