Exemple #1
0
void DateTime::adjust(int minutes)
{
    long tmp, mod, nxt;

    tmp = mm + minutes;
    nxt = tmp / 60;// hours
    mod = abs(tmp) % 60;
    mod = mod * Signum(tmp) + 60;
    mod %= 60;
    mm = mod;

    tmp = nxt + hh;
    nxt = tmp / 24;
    mod = abs(tmp) % 24;
    mod = mod * Signum(tmp) + 24;
    mod %= 24;
    hh = mod;

    tmp = nxt + d;
    mod = LengthOfMonth();

    if (tmp > mod)
    {
        tmp -= mod;
        d = tmp + 1;
        m++;
    }
    if (tmp < 1)
    {
        m--;
        mod = LengthOfMonth();
        d = tmp + mod;
    }

    tmp=yOff;
    if(m == 0)
    {
        m = 12;
        tmp--;
    }

    if(m > 12)
    {
        m = 1;
        tmp++;
    }

    tmp += 100;
    tmp %= 100;
    yOff = tmp;
}
Exemple #2
0
//This date class is designed to take on values which are considered invalid
//I want the date class to act not only as a date structure, but also
//as a way of finding differences of dates (not really fully implemented yet)
//So this function validates the date based on criteria for this specific project
//and guareentees that IsLeapYear() will work as it is expected to.
bool cTimeAndDate::IsValiDate() const { 

	bool ret=thisyear>1600;

	ret=ret && thismonth>=1 && thismonth<=12;
	ret=ret && GetDay().ofthemonth>=1 && GetDay().ofthemonth<=LengthOfMonth();
	return ret;
}
Exemple #3
0
cTimeAndDate::cTimeAndDate(int m, int d, int y) {
	thismonth=m;
	thisday.ofthemonth=d;
	thisday.oftheyear=0;
	thisyear=y;
	for(int i=1; i<thismonth; i++)
	   	thisday.oftheyear+=LengthOfMonth(i);
	thisday.oftheyear+=thisday.ofthemonth;

//	thisday.ofthemillenium
	int n=(y-2000)*365+((y-2000!=0)*1+(y-2000)/4);
//	thisday.ofthemillenium
	n+=thisday.oftheyear;
	thisday.oftheweek=(n+5)%7; //plus fudge factor
	
	Refresh();
	
	
}