Mike, So if we keep s_date1970 as UTC and just convert the event TimeStamp to UTC before getting the difference it should work right:
DateTime s_date1970 = new DateTime(1970, 1, 1); ... TimeSpan timeSince1970 = loggingEvent.TimeStamp.ToUniversalTime() - s_date1970; That should be equivalent to subtracting the time zone UTC offset. Nicko > -----Original Message----- > From: Mike Blake-Knox [mailto:[EMAIL PROTECTED] > Sent: 19 August 2004 19:52 > To: 'Log4NET User' > Subject: RE: XmlLayoutSchemaLog4j timestamp > > Nicko, > > I found I was having problems with daylight savings time and > needed to change the calculation (but not the static > s_date1970). I'm now using: > > // Calculate the timestamp as the > number of milliseconds since January 1970 UTC/GMT > // Note that the offset between local > time and GMT changes when daylight saving time starts and ends > TimeSpan timeSince1970 = > loggingEvent.TimeStamp - s_date1970 > - > localZone.GetUtcOffset(loggingEvent.TimeStamp); > > The root of the problem seems to be Windows' unique method of > keeping the timezone (difference to UTC) information in the > DateTime object but not changing it when the time is changed > to UTC. As the difference between local time and UTC changes > when you start or stop daylight savings time and my servers > need to keep on logging, the value must be determined for > each timestamp. > > I've tested it with various winter and summer times > (including one from a Microsoft blog) and chainsaw showed the > correct time. > > I've picked up a lot of sympathy for the winCVS developers > who, a few years ago, had great difficulty extracting > sensible times from Samba and SMB shares. > > Regards, > > Mike Blake-Knox > email: [EMAIL PROTECTED] > TSYS Office: (706) 644-3643 > cellphone: (706) 570-4641 > > > > -----Original Message----- > > From: Nicko Cadell [mailto:[EMAIL PROTECTED] > > Sent: Thursday, August 19, 2004 1:41 PM > > To: Log4NET User > > Subject: RE: XmlLayoutSchemaLog4j timestamp > > > > Mike, > > > > I must have been up late when I wrote that! The CVS code has been > > changed to: > > > > DateTime s_date1970 = new DateTime(1970, 1, 1); > > > > Which should do the job. > > > > Cheers, > > Nicko > >
