A few things: - FileTime is expressed in Universal time, and as such must be converted before subtracting the magic offset (patch 1)
- Strings in the format "2003-02-27T10:05:03-11:00" (note the timezone at the end) *must* be parsed by DateTime.Parse() for compatibility with Microsoft. This came up in my work with XML [de]serialization, which I'll send a patch for shortly (patch 1) - The date time format patterns didn't match MS output (patch 2) I've been running my test program (also included) on XP and Linux to get them to match. Also, a question. Whenever I run any .NET program under Mono, always I get three characters of garbage printed at the start "" (not sure if these will show up in email). Any ideas? Best regards, -elan
patch
Description: Binary data
using System;
using System.IO;
using System.Text;
using System.Globalization;
using System.Runtime.CompilerServices;
public class MainClass
{
static void Main ()
{
String date = "2003-02-27T10:05:03-11:00";
string format = "yyyy-MM-ddTHH:mm:sszzzzzz";
DateTime newNow = DateTime.ParseExact(date, format, null);
Console.WriteLine("*** ParseExact ***");
Console.WriteLine("Date.Exact: [{0}]", newNow.ToString());
Console.WriteLine("ToFileTime: [{0}]", newNow.ToFileTime());
Console.WriteLine("Ticks: [{0}]", newNow.Ticks);
Console.WriteLine("FromFileTime: [{0}]",
DateTime.FromFileTime(newNow.ToFileTime()).ToString());
Console.WriteLine("\n*** Parse ***");
newNow = DateTime.Parse(date);
Console.WriteLine("Date.Parse: [{0}]", newNow.ToString());
Console.WriteLine("ToFileTime: [{0}]", newNow.ToFileTime());
Console.WriteLine("Ticks: [{0}]", newNow.Ticks);
Console.WriteLine("FromFileTime: [{0}]",
DateTime.FromFileTime(newNow.ToFileTime()).ToString());
}
}
patch2
Description: Binary data
