DateTime.ToLocalTime()

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...
 
M

Morten Wennevik [C# MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top