int verifdatenaiss(char *chaine) { 
   int i, j, m, a, result; 
    
    
   if(strlength(chaine) == 10 && chaine[2] == '/' && chaine[5] == '/') {				//Si longeur de chaine = 10 ET  
   																						//si les "/" sont bien places 
   		char jour[3] = {chaine[0], chaine[1], '\0' }; 
 		char mois[3] = {chaine[3], chaine[4], '\0' };									//Division de la date en differentes  
 		char annee[5] = {chaine[6], chaine[7], chaine[8], chaine[9], '\0' };			//variables char[] jours, mois, annees 
   
         j = nbchartoint(jour); 
         m = nbchartoint(mois);															//Conversion en int 
         a = nbchartoint(annee); 
          
          
 		if(j <= daysinmonth(m, a) && j >= 1){											//Si le jour du mois est valide (annee bisextile) 
 												 
     		if(a >= 1905 && a <=1996) {													//Si la date est posterieure au 31 décembre 1904 et  
     																					//anterieure au 1er janvier 1997 
     		 
 				return 1;																//Alors retourne 1 = valide 
 			}  
 		 
   		} 	  
 
     } 
    
 	return 0;																			//Dans tous les autres cas, retourne 0
 	
 } 
Beispiel #2
0
void normalise(int* res)
{
	// Rebase day and month numbers on 0
	--res[1];
	--res[2];
	//cerr << "TOZERO " << tostringall(res) << endl;

	// Normalise seconds
	normalN(res[5], res[4], 60);
	//cerr << "ADJSEC " << tostringall(res) << endl;

	// Normalise minutes
	normalN(res[4], res[3], 60);
	//cerr << "ADJMIN " << tostringall(res) << endl;

	// Normalise hours
	normalN(res[3], res[2], 24);
	//cerr << "ADJHOUR " << tostringall(res) << endl;

	// Normalise days
	while (res[2] < 0)
	{
		--res[1];
		normalN(res[1], res[0], 12);
		res[2] += daysinmonth(res[0], res[1]+1);
	}
	//cerr << "ADJDAY1 " << tostringall(res) << endl;
	while (true)
	{
		normalN(res[1], res[0], 12);
		int dim = daysinmonth(res[0], res[1]+1);
		if (res[2] < dim) break;
		res[2] -= dim;
		++res[1];
	}
	//cerr << "ADJDAY2 " << tostringall(res) << endl;

	// Normalise months
	normalN(res[1], res[0], 12);
	//cerr << "ADJMONYEAR " << tostringall(res) << endl;

	++res[1];
	++res[2];
	//cerr << "FROMZERO " << tostringall(res) << endl;
}
Beispiel #3
0
/**
 * Convert the given time in seconds elapsed since the beginning of the given
 * year.  It is assumed that year <= t[0]
 */
long long int secondsfrom(int year, const int* val)
{
	long long int res = 0;
	if (val[5] != -1) res += val[5];
	if (val[4] != -1) res += val[4] * 60;
	if (val[3] != -1) res += val[3] * 3600;
	if (val[2] != -1) res += (val[2]-1) * 3600 * 24;
	if (val[1] != -1)
		for (int i = 1; i < val[1]; ++i)
			res += daysinmonth(val[0], i) * 3600 * 24;
	for (int i = year; i < val[0]; ++i)
		res += daysinyear(i) * 3600 * 24;
	return res;
}
void dialCalendar::RefreshCalendar(void) {
	BString tmp;
	int d = getdayofweek(year,month,1);
	int m = daysinmonth(year,month);
	int i = 0;
	int j = 0;
	int k = 1;
	// 1st line
	while (i<d) {
		caldaytab[i][j] = -1;
		caltab[i][j]->SetLabel("");
		caltab[i][j]->SetEnabled(false);
		i++;
	};
	// next lines
	while (k<=m) {
		tmp = ""; tmp << k;
		caldaytab[i][j] = k;
		caltab[i][j]->SetLabel(tmp.String());
		caltab[i][j]->SetEnabled(true);
		i++; k++;
		if (i>=7) {
			i=0; j++;
		}
	}
	// finish last lines
	while (j<6) {
		caldaytab[i][j] = -1;
		caltab[i][j]->SetLabel("");
		caltab[i][j]->SetEnabled(false);
		i++;
		if (i>=7) {
			i=0; j++;
		}
	}
	monthyear->SetText(makeDateString());
	this->UpdateIfNeeded();
}