DateTime.ToLocalTime()

  • Thread starter Thread starter G.S.
  • Start date Start date
G

G.S.

Hello group,
Hopefully an easy question in regard to DateTime's ToLocalTime() and
ToUTC time

Where are those functions taking the locale info from to do the
conversion?

I assume they are using the current thread context and .NET framework
takes care of that? yes? If not, could somebody shed some light or
point me in a direction to read this up somewhere...
 
G.S. said:
Hello group,
Hopefully an easy question in regard to DateTime's ToLocalTime() and
ToUTC time

Where are those functions taking the locale info from to do the
conversion?

I assume they are using the current thread context and .NET framework
takes care of that? yes? If not, could somebody shed some light or
point me in a direction to read this up somewhere...

Hi G.S.

DateTime dt = new DateTime(2008, 12, 08);

dt.ToLocalTime();

is equal to

TimeZone.CurrentTimeZone.ToLocalTime(date);

which in turn calls GetUtcOffsetFromUniversalTime if the DateTime isn't
already local time. etc.

You can see this for yourself if you are using Visual Studio 2008 with
Framework source code stepping enabled.

This article explains briefly how to do it, but its not terribly intuitive.
Google around or ask in this group if you get stuck

[How to: Debug .NET Framework Source]
http://msdn.microsoft.com/en-us/library/cc667410.aspx
 
Back
Top