(23.02.2011, 23:38)routeconverter Wrote: (23.02.2011, 13:29)RsH Wrote: The time in the GPX file is already in 24 hour clock format, isn't it?
Time is most parts of the world and in most software is in 24 hour clock format. SCNR ;-)
(23.02.2011, 13:29)RsH Wrote: If so, why does it need to be converted to 'locale' format?
Actually it's the output that does the conversion. Internally time is stored in milliseconds since 1/1/70 and the timezone. To format it into a string, a date formatter has to be used. And by default this date formatter uses the locale to present English users their AM/PM stuff, Germans their day then month then year preference etc...
I hope one of the following solves the problem... you have to figure it out, as I do NOT know these programming languages..
==========================================
1.
Go to
http://www.epochconverter.com/epoch/batch-convert.php and on the RIGHT side of the web page pick the appropriate programming language and you will be given the conversion routine to use.
==========================================
2.
perl -e 'print scalar gmtime(hex shift), "\n"' 3BE00B2C
should give the correct result with a 24 hour clock, I think, where the "\N" or the 3BE00B2C is the UTC time. Since I do not know Perl, I am not certain of which it is. Of course, if you are not using Perl, then there has to be an equivalent somewhere.
====================================
Someone else suggested:
1 public static DateTime ConvertTime(long timeAsInteger)
2 {
3 double time = Convert.ToDouble(timeAsInteger) / 100;
4 DateTime baseDate = new DateTime(1970, 1, 1);
5 DateTime result = baseDate + TimeSpan.FromSeconds(time);
6 return result;
7 }
If 'I' pass in 117969553301 'I' get the answer 20/05/2007 21:12:13 (that's UK date format...)
Not sure whether it will help, but it's very close to 5/21/2007 00:12:13.
It's a very strange DateTime encoding though!!
============================
Another response I've discovered is:
Given that you are parsing the date from a string, the system has no way of knowing what kind of DateTime you are parsing.
DateTime has a kind property, which can have one of the three values:
* Unspecified
* Local
* Utc
So for the code you show:
DateTime convertedDate = DateTime.Parse(dateStr);
var kind = converted.Kind; // will equal DateTimeKind.Unspecified
You say you know what kind it is, so tell it.
DateTime convertedDate = DateTime.SpecifyKind(
DateTime.Parse(dateStr),
DateTimeKind.Utc);
var kind = converted.Kind; // will equal DateTimeKind.Utc
Then the system knows its in UTC time...