Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8848471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:25:50+00:00 2026-06-14T12:25:50+00:00

I am running a process at a given clock time each day (in the

  • 0

I am running a process at a given clock time each day (in the United States–that is significant). I have been trying to calculate how to do that correctly for the 25 hour day. Consider the following C# code:

var referenceDate = new DateTime(2012, 11, 3);
var referenceTime = new TimeSpan(0, 19, 30, 0);
var originalTime = referenceDate.Add(referenceTime);
var tomorrow = referenceDate.AddDays(1);
var nextTimestamp = string.Format(
            "{0} {1:00}:{2:00}", 
            tomorrow.ToShortDateString(), 
            referenceTime.Hours, 
            referenceTime.Minutes);
var nextRunTimestamp = DateTime.Parse(nextTimestamp);

I used the format/parse sequence to make sure that we can avoid time spans when crossing the DST transition time. Now what should be the result of the following expression?

nextRunTimestamp.Subtract(originalTime).TotalHours

Well, it turns out to be 24 but I think it should be 25 since November 4, 2012 is a 25-hour day (transitioning at 2 AM) so the difference between 19:30 on November 3 and 19:30 on November 4 should be 25 hours.

How do I get to the right answer for each date in the year?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:25:51+00:00Added an answer on June 14, 2026 at 12:25 pm

    Actually it sounds like you don’t need to do that at all. Your problem seems rather moot, since if you have something running at the same time on every day, it will auto adjust to your time change anyways.

    If you are really interested though, you can get the DaylightTime of a particular year by utilizing:

    var dst = TimeZone.CurrentTimeZone.GetDaylightChanges(2012);
    

    The DaylightTime object has your start date and time and end date and time of DST for whatever timezone. From there, if you were so inclined, you could check if DST start or end falls in your time period and add or subtract an hour as needed.

    Then in your code you could have logic such as (pseudo code):

    if(dst.End > originalTime && dst.End < tomorrow)
        //Add hour for "25 hour" day
    
    if(dst.Start > orginalTime && dst.Start < tomorrow)
        //Subtract hour for "23 hour" day
    

    EDIT: I think I misunderstood what you were doing. Though the above code can give you if your DST start or end is within your time period. You are looking for this:

    //Probably DateTime.Now, but whatever
    var referenceDate = new DateTime(2012, 11, 3, 19, 30, 0);
    var nextTime = referenceDate.AddDays(1);
    
    Timer t = new Timer(nextTime.ToUniversalTime() - referenceDate.ToUniversalTime());
    
    t.Start();
    

    I hope you are not puting your DateTime in a string format then trying to do a Parse in your actual code…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a long running process that is called via a Nancy Module Get
I'm working in a project that already have a build process running with maven
Every process running on a machine is given the illusion that it is the
I have the following setup: An endless running PHP process that looks at a
How can I get the PID of a TERMINAL running a process with given
I have running process but it's executable file has got deleted. If I try
I want to write a long running process (linux daemon) that serves two purposes:
I have a situation where user requests to do a long running process. I
I have an application for PDAs with a long running process, and I'm getting
how can one tell (using non-CLR C++) which DLLs is a given running process

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.