C
C#2w ago
xgenius

ticks must be between datetime.minvalue.ticks and datetime.maxvalue.ticks

I'm getting this error whilst fetching datetime value in open rails (an open src train simulator). I saw the fetching method in another lib of same exe and tried to use it in the lib that I was modifying according to me but it gives the error "ticks must be between datetime.minvalue.ticks and datetime.maxvalue.ticks" whilst the same piece of code works in the other lib.
No description
13 Replies
Sehra
Sehra2w ago
what is ActualDepart in this context? seconds since 1970?
xgenius
xgeniusOP2w ago
actual depart is train object's actual depart time from the set depart time
Sehra
Sehra2w ago
yes, but what is it measured in?
xgenius
xgeniusOP2w ago
No description
xgenius
xgeniusOP2w ago
int it says and if I log this values it shows "10000000"
Sehra
Sehra2w ago
but what is the unit?
xgenius
xgeniusOP2w ago
no unit should be seconds ig bc other values like depart time are in seconds
Sehra
Sehra2w ago
since you want to convert it to a datetime, you need to know what it is counting from. 10000000 seconds since when?
xgenius
xgeniusOP2w ago
it should be since today's date and 00:00:00 time bc set depart and arrival values are from start of the day
Sehra
Sehra2w ago
there is only 86400 seconds in a day
xgenius
xgeniusOP2w ago
yeah exactly it should not show 1000000 smth and else it's giving that ticks error
xgenius
xgeniusOP2w ago
ts
No description
Sehra
Sehra2w ago
if it's seconds, you can do new DateTime().AddSeconds(tttrain.PreviousStop.ActualDepart) or new DateTime(TimeSpan.TicksPerSecond * tttrain.PreviousStop.ActualDepart) would have the same effect

Did you find this page helpful?