In this case you've found an hour where WA didn't exist according to
Microsoft's TimeZone data:

In DotLisp, with wadate as your date and wstTimezone as you've retrieved it:
> (wstTimezone.GetUtcOffset (.AddMinutes wadate 60))
09:00:00
> (wstTimezone.GetUtcOffset (.AddMinutes wadate -1))
09:00:00
> (TimeZoneInfo:ConvertTimeToUtc (.AddMinutes wadate -1)wstTimezone)
31/12/2008 2:59:00 PM
> (TimeZoneInfo:ConvertTimeToUtc (.AddMinutes wadate 60)wstTimezone)
31/12/2008 4:00:00 PM
>

All the local times in between are invalid.

Drop a note at Connect.

-- 
Regards,
Mark Hurd, B.Sc.(Ma.)(Hons.)


On 8 November 2012 10:44, Wallace Turner <wallacetur...@gmail.com> wrote:

>  This question is similar to [this][1] stackoverflow question insofar as
> the Exception thrown is clear and explicit:
>
> I'm converting the 1st Jan 2009 (perth time) to UTC and getting 
> "*System.ArgumentException:
> The supplied DateTime represents an invalid time*"
>
> [TestMethod]public void TestMethod1(){
>     var date = DateTime.Parse("1-Jan-2009 00:00");
>     var wstTimezone = TimeZoneInfo.FindSystemTimeZoneById("W. Australia 
> Standard Time");
>     Trace.WriteLine(wstTimezone.IsInvalidTime(date));//is invalid
>     Trace.WriteLine(TimeZoneInfo.ConvertTime(date, wstTimezone, 
> TimeZoneInfo.FindSystemTimeZoneById("UTC")));//throw Exception}
>
>
>
>
> 1) I'm more curious than concerned - *Can anyone out here in the west
> recall why this time might be invalid?* One hour either side of this
> works ok; I can't recall daylight savings moving/changing during this
> period.
>
> 2) In general, how are people handling cases like this? For example, if
> you have a user who wants to select all the foos from 1st Jan 2009 onwards
> then you would naturally get the start time in the users timezone
> (1-Jan-2009 00:00) and convert to UTC - this is especially problematic if
> you only allow the user to select the start and end date (no times) which
> means you'd have to ask the user to select a different date completely
> because 'midnight didnt exist in your timezone on the selected date'
>
> Hope I'm making sense
>
> Wal
>
>
> [1]:
> http://stackoverflow.com/questions/2416439/exception-calling-when-timezoneinfo-converttimetoutc-for-certain-datetime-values
>

Reply via email to