getting the day of the week

Hello all just started an account. I have a fun question that is an end of an inherited class. I am trying to return the day of the week using time structures. However, I cannot get the correct date from two different structures, even if they are declared as different structures. So, when I check the number of the week, the two provided to check with are the same.

point is: They keep coming up as the same.

bool Weekly::occurs_on(int year, int month, int day)
{


struct tm * chec ;
time_t clock1 ;
time(&clock1);
//time device intialized
//...hooking time structure with pointers
chec = localtime(&clock1) ;


chec->tm_year = year - 1900 ;
chec->tm_yday = day ;
chec->tm_mon = month - 1 ;



mktime(chec) ;
int nummy = chec->tm_wday ;

//ok this number has been grabbed
//nummy holds a number you'll use


//redailing the structure
int lol1 = get_it().tm_year - 1900 ;
int lol2 = get_it().tm_mday ;
int lol3 = get_it().tm_mon - 1 ;

//can't reset the clock template...f
time_t clock2 ;
time(&clock2);
chec = localtime(&clock2) ;

chec->tm_year = lol1 ;
chec->tm_yday = lol2;
chec->tm_mon = lol3 ;



mktime(chec);
int mum = chec->tm_wday ;

if(nummy == mum)
{

return true ;
}


//if it doesn't pass then return false
return false ;

}



nummy and mum can't always be the same.... yet they are......... even if you create a different set of structures. they need to create their own times....
It depends on what get_it() returns.

1
2
3
int lol1 = get_it().tm_year - 1900 ; // Why this? Isn't it already without 1900?
int lol2 = get_it().tm_mday ;
int lol3 = get_it().tm_mon - 1 ; // And this? 


// And this?

i'm guessing month in that library is zero-based. I know of a few libraries like this, for example java's Calendar class.
Topic archived. No new replies allowed.