PC Review


Reply
Thread Tools Rate Thread

when the clock is adjusted forward, any time in the period that isskipped is invalid

 
 
pamela fluente
Guest
Posts: n/a
 
      19th Mar 2011
Hi friend, take the following simple code (vb or c#)

It raises the exception:

The supplied DateTime represents an invalid time. For example,
when the clock is adjusted forward, any time in the period that is
skipped is invalid.
Parameter name: dateTime

Could i have some enlightening on this? (should be related with
daylight)
And how should i modify my loop to proceed normally in the generation
of new dates avoiding the error ?


[BTW i am generating time series of random prices, this is time, the
"x" axis]


-Pam



-----------------------------------------------
Public TimeZoneInfo_LOCAL As TimeZoneInfo = TimeZoneInfo.Local
Public TimeZoneInfo_EDT As TimeZoneInfo =
TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click

Dim d As New Date(Now.Year, Now.Month, Now.Day)
Do
Dim NewDate = d.AddMinutes(-1)
Dim NewDate_EDT As Date =
TimeZoneInfo.ConvertTime(NewDate, TimeZoneInfo_EDT,
TimeZoneInfo_LOCAL)

d = NewDate
Loop

End Sub
-----------------------------------------------


-----------------------------------------------
public TimeZoneInfo TimeZoneInfo_LOCAL = TimeZoneInfo.Local;
public TimeZoneInfo TimeZoneInfo_EDT =
TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");

private void Button1_Click(System.Object sender, System.EventArgs e)
{
System.DateTime d = new System.DateTime(DateAndTime.Now.Year,
DateAndTime.Now.Month, DateAndTime.Now.Day);
do {
dynamic NewDate = d.AddMinutes(-1);
System.DateTime NewDate_EDT = TimeZoneInfo.ConvertTime(NewDate,
TimeZoneInfo_EDT, TimeZoneInfo_LOCAL);

d = NewDate;
} while (true);

}

-----------------------------------------------
 
Reply With Quote
 
 
 
 
pamela fluente
Guest
Posts: n/a
 
      19th Mar 2011
Or maybe it's clearer if i pose the question in a time "forward" mode:

This also gives the same error:

--------------------------

Public TimeZoneInfo_LOCAL As TimeZoneInfo = TimeZoneInfo.Local
Public TimeZoneInfo_EDT As TimeZoneInfo =
TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click


Dim d As New Date(2011, 3, 1)
Do
Dim NewDate = d.AddMinutes(1)
Dim NewDate_EDT As Date =
TimeZoneInfo.ConvertTime(NewDate, TimeZoneInfo_EDT,
TimeZoneInfo_LOCAL)

d = NewDate
Loop

End Sub

--------------------------

I am looking for a way to have the loop proceed normally generating
edt dates (a gap of 1 hour is fine, no problem).

-Pam
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      19th Mar 2011
On 19-03-2011 09:17, pamela fluente wrote:
> Hi friend, take the following simple code (vb or c#)
>
> It raises the exception:
>
> The supplied DateTime represents an invalid time. For example,
> when the clock is adjusted forward, any time in the period that is
> skipped is invalid.
> Parameter name: dateTime
>
> Could i have some enlightening on this? (should be related with
> daylight)
> And how should i modify my loop to proceed normally in the generation
> of new dates avoiding the error ?
>
> [BTW i am generating time series of random prices, this is time, the
> "x" axis]


If your app is to be able to handle DST changes, then you should
use UTC time internally and only convert to local time in display.

Arne
 
Reply With Quote
 
pamela fluente
Guest
Posts: n/a
 
      19th Mar 2011
On 19 Mar, 14:39, Arne Vajhøj <a...@vajhoej.dk> wrote:
> On 19-03-2011 09:17, pamela fluente wrote:
>
>
>
>
>
>
>
>
>
> > Hi friend, take the following simple code (vb or c#)

>
> > It raises the exception:

>
> > * * *The supplied DateTime represents an invalid time. *For example,
> > when the clock is adjusted forward, any time in the period that is
> > skipped is invalid.
> > Parameter name: dateTime

>
> > Could i have some enlightening on this? *(should be related with
> > daylight)
> > And how should i modify my loop to proceed normally in the generation
> > of new dates avoiding the error ?

>
> > [BTW i am generating time series of random prices, this is time, the
> > "x" axis]

>
> If your app is to be able to handle DST changes, then you should
> use UTC time internally and only convert to local time in display.
>
> Arne


Yes. It' seemed just more convenient for me to deal with real dates
because these are real prices.
After all i need only 2 version of dates: LOCAL and EDT when i display
it.
If possible i'd like just to find an easy way to skip the hour. It's
right after all: these are prices randomly generated.

-Pam
 
Reply With Quote
 
pamela fluente
Guest
Posts: n/a
 
      19th Mar 2011
On 19 Mar, 17:03, Peter Duniho <NpOeStPe...@NnOwSlPiAnMk.com> wrote:
> On 3/19/11 6:43 AM, pamela fluente wrote:
>
> > [...]
> > If possible i'd like just to find an easy way to skip the hour. It's
> > right after all: these are prices randomly generated.

>
> There is an easy way: use UTC time internally and only convert to local
> time in display.
>
> Hopefully, that advice sounds familiar to you. *
>
> BTW, if you're going to post code in the C# newsgroup, it would be best
> if you would make sure that code is C# code. *If you want help with
> VB.NET code, there's a different forum for that.
>
> Pete


thanks.

(c# and vb.net are the same to me.)

-Pam
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
invalid time - clock adjusted forward pamela fluente Microsoft VB .NET 19 20th Mar 2011 03:56 PM
Clock In / Clock Out (Military Time) equals negative time?? =?Utf-8?B?VHJhY2V5?= Microsoft Access Queries 6 13th Feb 2007 09:49 PM
Loop problem when time period loops from 1 to end of period again Lance Microsoft Access Queries 3 9th May 2006 02:38 AM
Appointments adjusted up one hour when I reset my clock. How do I. =?Utf-8?B?UGF0IFM=?= Microsoft Outlook Discussion 0 1st Nov 2004 04:19 PM
Time adjusted sandy Windows XP Security 0 31st Jul 2003 05:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:04 PM.