Re: Rotor Bug: TimeZone ToLocalTime
From: Justin Rogers (Justin_at_games4dotnet.com)
Date: 11/03/04
- Next message: George: "Re: Exception Handling - help!"
- Previous message: David Levine: "Re: Exception Handling - help!"
- In reply to: Todd Bandrowsky: "Rotor Bug: TimeZone ToLocalTime"
- Next in thread: Todd Bandrowsky: "Re: Rotor Bug: TimeZone ToLocalTime"
- Reply: Todd Bandrowsky: "Re: Rotor Bug: TimeZone ToLocalTime"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 3 Nov 2004 02:20:43 -0800
Did you do a round trip test?
using System;
public class RoundTripDateTime {
private static void Main(string[] args) {
DateTime realNow = DateTime.Now;
DateTime utc = realNow.ToUniversalTime();
DateTime now = utc.ToLocalTime();
Console.WriteLine(realNow);
Console.WriteLine(utc);
Console.WriteLine(now);
}
}
Or are you just basing this on a code examination? Having looked at the
code myself, GetUtcOffset doesn't depend on the time at all. It instead gets
all of the information from the time zone about how to offset the times.
So apparently, the real bug would be that turning an already local time
into a local time fails, but not converting a utc date into a local date. In
effect
the reverse is the actual reverse.
Note that in Whidbey, there are immense changes that make this *work*.
Each date stores a kind, and the calculations are based on this kind. In
this manner any time should be able to be converted into a real local time
or a real UTC time no matter what time zone you are in.
-- Justin Rogers DigiTec Web Consultants, LLC. Blog: http://weblogs.asp.net/justin_rogers "Todd Bandrowsky" <tbandrow@mightyware.com> wrote in message news:d43b6e1.0411021100.159c16d6@posting.google.com... > The following snippet is from CurrentTimeZone in Rotor. > > // > // Converts the specified datatime to the Universal time base > on the current timezone > // > /// <include file='doc\TimeZone.uex' > path='docs/doc[@for="TimeZone.ToUniversalTime"]/*' /> > public virtual DateTime ToUniversalTime(DateTime time) { > return (time - GetUtcOffset(time)); > } > > // > // Convert the specified datetime value from UTC to the local > time based on the time zone. > // > /// <include file='doc\TimeZone.uex' > path='docs/doc[@for="TimeZone.ToLocalTime"]/*' /> > public virtual DateTime ToLocalTime(DateTime time) { > return (time + GetUtcOffset(time)); > } > > ToLocalTime is incorrect, because the call for GetUtcOffset specifies > a date already in local time, not UTC. As a result, the calls to > ToLocalTime and ToUniversalTime are not inverse operations. > > Todd Bandrowsky > tbandrow@mightyware.com
- Next message: George: "Re: Exception Handling - help!"
- Previous message: David Levine: "Re: Exception Handling - help!"
- In reply to: Todd Bandrowsky: "Rotor Bug: TimeZone ToLocalTime"
- Next in thread: Todd Bandrowsky: "Re: Rotor Bug: TimeZone ToLocalTime"
- Reply: Todd Bandrowsky: "Re: Rotor Bug: TimeZone ToLocalTime"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|