Discussion:
Log timestamp in UTC
Joe Joe
2004-11-27 10:04:48 UTC
Permalink
Does there exist a conversion pattern specifier that logs the timestamp in
UTC?

_________________________________________________________________
Stay in touch with absent friends - get MSN Messenger
http://www.msn.co.uk/messenger
Nicko Cadell
2004-11-29 16:11:09 UTC
Permalink
Joe,

The date formatters (ABSOLUTE, DATE and ISO8601) format the date as a
local time. The simple date formatter accepts any DateTimeFormattingInfo
date pattern. Looking at the .NET docs for this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfsystemglobalizationdatetimeformatinfoclasstopic.asp

It looks like the 'U' pattern may convert the time from local to
universal time before displaying it.

Failing that you would need to write a new layout that output what you
needed. The pattern layout in 1.2 beta 8 is not extensible, but in the
current CVS head it should be very easy to add another pattern that
converts to UTC before rendering the date.

Nicko
-----Original Message-----
Sent: 27 November 2004 10:05
Subject: Log timestamp in UTC
Does there exist a conversion pattern specifier that logs the
timestamp in UTC?
_________________________________________________________________
Stay in touch with absent friends - get MSN Messenger
http://www.msn.co.uk/messenger
Joe Joe
2004-12-03 15:41:23 UTC
Permalink
Nicko, thanks for the response.
Post by Nicko Cadell
It looks like the 'U' pattern may convert the time from local to
universal time before displaying it.
The "U" pattern is long date + long time, not really appropriate. So it
looks like this is impossible without customising Log4Net (which I want to
avoid).
Post by Nicko Cadell
Failing that you would need to write a new layout that output what you
needed. The pattern layout in 1.2 beta 8 is not extensible, but in the
current CVS head it should be very easy to add another pattern that
converts to UTC before rendering the date.
I think it would make sense to have patterns for both UTC and local time.
But it would be better to retrieve the date as UTC, then convert to local
when rendering (local to UTC conversions are ambiguous for 1h each year at
the end of daylight savings time).

Joe

_________________________________________________________________
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo
Nicko Cadell
2004-12-08 13:15:24 UTC
Permalink
There are a number of guidelines regarding the issues of the DateTime
type:

http://msdn.microsoft.com/netframework/default.aspx?pull=/library/en-us/
dndotnet/html/datetimecode.asp
http://weblogs.asp.net/bclteam/archive/2004/05/21/136918.aspx
http://weblogs.asp.net/bclteam/archive/2004/06/01/145487.aspx
http://www.gotdotnet.com/team/clr/bcl/TechArticles/techarticles/DateTime
FAQ/FAQ.aspx

The best practice appears to be to store the DateTime as UTC and convert
to local time where necessary, i.e. in display or for serialisation.
This is something we will need to look at. In the meantime I have added,
to CVS, support for outputting the UTC date from the PatternLayout.

Nicko
-----Original Message-----
Sent: 03 December 2004 15:41
Subject: Re: Log timestamp in UTC
Nicko, thanks for the response.
Post by Nicko Cadell
It looks like the 'U' pattern may convert the time from local to
universal time before displaying it.
The "U" pattern is long date + long time, not really
appropriate. So it looks like this is impossible without
customising Log4Net (which I want to avoid).
Post by Nicko Cadell
Failing that you would need to write a new layout that
output what you
Post by Nicko Cadell
needed. The pattern layout in 1.2 beta 8 is not extensible,
but in the
Post by Nicko Cadell
current CVS head it should be very easy to add another pattern that
converts to UTC before rendering the date.
I think it would make sense to have patterns for both UTC and
local time.
But it would be better to retrieve the date as UTC, then
convert to local when rendering (local to UTC conversions are
ambiguous for 1h each year at the end of daylight savings time).
Joe
_________________________________________________________________
Express yourself with cool new emoticons
http://www.msn.co.uk/specials/myemo
Continue reading on narkive:
Loading...