Since you are trying to represent a time period from an arbitrary point, and not as a specific date, maybe you would be better off using the System.TimeSpan class? This allows you to set values โโin the constructor for more than 24 hours and can be used with DateTime objects as follows:
System.TimeSpan timestamp = new System.TimeSpan(25, 0, 0); System.DateTime parsedDateTime = new DateTime(0, 0, 0); parsedDateTime = parsedDateTime.Add(timestamp); Console.WriteLine(parsedDateTime.ToString("yyyy-MM-dd HH:mm:ss")); //Output as "0001-01-02 01:00:00"
NOTE. Code not verified.
EDIT:. In terms of parsing strings, I can't think of any basic .NET objects that parse strings with values โโgreater than 23 for an hour (since 25 is an invalid hour of the day), but assuming the format is consistent, you can create a very simple a line parsing procedure (or even a regular expression) to read the values โโindividually and manually load the constructor.
Karl Nicoll
source share