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

  • Home
  • SEARCH
  • 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 6639709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:35:09+00:00 2026-05-25T23:35:09+00:00

I have an MFC application where I want a certain method to be called

  • 0

I have an MFC application where I want a certain method to be called at specified times. I will specify the times by using a vector of tm structs that have the hour minute and second filled out. Possibly I may need to store a boolean value for each time to indicate whether the method was called at the specified time. I have a timer that goes off every 50ms.

In MFC, the time is not guaranteed to go off at the specified interval. I want to ensure that the method is called even if off by a few seconds. My application does not currently require precise timing (although I’m open to it if there is an easy solution). My current thought on how to do this is to allow for some slippage such that I allow the time to be equal +/- a few seconds. Does that seem like a reasonable way to achieve this?

I want to check if two times are equal within a certain tolerance of seconds. What’s the best way to to this in c++? I have access to a CTime object and/or a struct tm object (and potentially other windows time data structures)

UPDATE

I guess there is actually added complexity in the case where the seconds is near the minute or hour boundary. I can’t just compare seconds.

  • 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-05-25T23:35:10+00:00Added an answer on May 25, 2026 at 11:35 pm

    You need to use mktime to get a time_t. time_t is generally the number of seconds since the beginning of 1970, so you don’t need to worry about 2:10:59 vs 2:11:01.

    struct tm expected_tm;
    struct tm actual_tm;
    
    // set those tms to something
    
    time_t expected_time = mktime( &expected_tm );
    time_t actual_time = mktime( &actual_tm );
    
    if ( abs( expected_time - actual_time ) < 5 ) // for 5s tolerance
    {
        // GOOD
    }
    else
    {
         // BAD
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mature MFC C++ application that displays on screen and prints using
I have an MFC application (using a legacy library that I can't change). When
I have a MFC application that I want to distribute via USB flash drives.
I have an MFC application, which i don't want to be closed during the
I have a MFC application that launches a IWebBrowser2 window. On users computers where
I have an MFC application that runs on my computer, but when I try
We have a MFC 8 application compiled with /CLR that contains a larger amount
I have C++ application which has UI developed using MFC, does some networking using
I have an MFC DLL that is loaded by a 3rd party application. How
We have a command line application that could benefit from a GUI. We want

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.