473,320 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

System.Timers.Timer and Daylight Savings

Is there any way to make a System.Timers.Timer adjust for daylight
savings time change? In a long running process I set a timer as follows
for a daily expiration:

_myTimer = new Timer(_myTimerDelegate, null, nextExpiration,
TimeSpan.FromDays(1));

When we make the change out of daylight time back to standard time, the
timer appears to fire one hour early (e.g., 4pm instead of 5pm). Is
there a way to set this timer so that it is daylight-time aware?

Thanks

Nov 17 '05 #1
3 3214
This isn't a timer issue. The timer has no concept of the current time.
It only knows that in a ^span^ of time, it has to fire.

Because of this, you will have to check the timer period every time it
is fired, and determine if the next day will result in a shift in the time
because of daylight savings.

A better solution would be to use the Windows Scheduler to run this
task. It can be configured to run at a certain time each day, and is not
affected by daylight savings. Because the OS updates the time automatically
for daylight savings, the scheduler, which is based on the system time, will
work correctly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ch********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Is there any way to make a System.Timers.Timer adjust for daylight
savings time change? In a long running process I set a timer as follows
for a daily expiration:

_myTimer = new Timer(_myTimerDelegate, null, nextExpiration,
TimeSpan.FromDays(1));

When we make the change out of daylight time back to standard time, the
timer appears to fire one hour early (e.g., 4pm instead of 5pm). Is
there a way to set this timer so that it is daylight-time aware?

Thanks

Nov 17 '05 #2
Thanks, that's what I thought. This function is actually sending a
message periodically from a long running process, so the Scheduler
would probably not be an option. It's too bad there's not an option on
the Timer to adjust for daylight changes, ie increment/decrement the
span when it crosses a daylight boundary.

Nov 17 '05 #3
What is stopping you from stopping the timer and creating a new instance
with the correct time span?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ch********@yahoo.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Thanks, that's what I thought. This function is actually sending a
message periodically from a long running process, so the Scheduler
would probably not be an option. It's too bad there's not an option on
the Timer to adjust for daylight changes, ie increment/decrement the
span when it crosses a daylight boundary.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bathroom_Monkey | last post by:
For posterity's sake, here is an algorithm I created to take a GMT time and convert it to U.S. central time, accounting for daylight saving time. Note: this algorithm can be modified to work for...
0
by: Jeff O. | last post by:
Has anyone written a class to adjust their Timer period for daylight savings time? Or, is there another way to have the timer automatically adjust for DST?
1
by: Ernie | last post by:
I am creating an .ics file that when opened (via Outlook) inserts a meeting into the calendar. All works fine unless the date and time I'm inserting happens to occur on the hour the time changes...
9
by: Mark Rae | last post by:
Hi, I've seen several articles about using System Timers in ASP.NET solutions, specifically setting them up in Global.asax' Application_OnStart event. I'm thinking about the scenario where I...
4
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts...
3
by: mmuras | last post by:
I did not see any discussions / threads for this but if there is one please let me know: -First, I am one of only two individuals within my company's IT Dept. -We have a Windows Server 2003 R2...
4
by: Polaris431 | last post by:
I have a web application in ASP.NET that will be used globally. Data is collected on mobile devices running Windows Mobile and sent to the web server where it is stored and can be viewed. Data is...
3
by: Generic Usenet Account | last post by:
Hi, Is there any way to make time-of-day adjustments for daylight savings using only standard time functions? We have a program that executes daily at a fixed time of day. After daylight...
8
by: Ollie Riches | last post by:
I'm looking into a production issue related to a windows service and System.Timers.Timer. The background is the windows service uses a System.Timers.Timer to periodically poll a directory location...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.