Re: Difference in Time
I thought you said you wanted the number of seconds between now and
someother day.
If you have todays date, and you want to find the date for next sunday.
(This method will ensure that the month and year are also correct if next
sunday happens to fall on another month or year)
CTime CurTime = CTime::GetCurrentTime();
//find the number of days between today and next sunday
CTimeSpan Span(8-CurTime.GetDayOfWeek(),0,0,0);
//Lets do today at 8pm
CTime
NextSunday(CurTime.GetYear(),CurTime.GetMonth(),CurTime().GetDay,20,0,0);
//now add the number of days to make it sunday
NextSunday += Span;
Note that I am not checking to see if today is sunday.
AliR.
"Trecius" <Trecius@discussions.microsoft.com> wrote in message
news:4240D2C6-AA09-4D6A-B45B-DF5EFCB6E303@microsoft.com...
Yes, I knew about the time structures, but I'm wondering about is how to
actually GET the next Sunday. I could always do CTime::GetCurrentTime(),
but
what do I manipulate, or add, to get the NEXT Sunday? Once I have the
next
Sunday, I know I could always do a difference in times and the result will
be
a CTimeSpan, which I can easily use GetTotalSeconds().
Trecius
"Doug Harrison [MVP]" wrote:
On Tue, 3 Apr 2007 11:12:02 -0700, Trecius
<Trecius@discussions.microsoft.com> wrote:
Hello, Newsgroupians:
I've a question regarding time.
I am creating an application that works much like the old Task
Scheduler. I
have a specific time I want to do an action. For example, every Sunday
at
8:00 PM, I want to do my action. My approach is to simply create a
thread
and have it ::WaitForSingleObject on a waitable timer. The only problem
I'm
having is how can I determine the number of seconds between NOW and the
next
Sunday at 8:00 PM? Thank you.
See time, localtime, mktime, and difftime. Oh wait, this is the MFC
group,
so see CTime and maybe CTimeSpan. There are also Windows API functions
you
can use; search on SYSTEMTIME and maybe FILETIME to discover them.
--
Doug Harrison
Visual C++ MVP