Пример #1
0
int main()
{
	int month;
	int day;
	printf("Input month and day:");
	scanf("%d,%d", &month, &day);
	int days = getdays(month,day);
	if(days > 0)
		printf("The day is %dth day of the year.\n", days);
	else
		return -1;
	return 0;
}
Пример #2
0
static uint_32 time2value(CONFIG_RTC _PTR_ para)
{
	CONFIG_RTC  tmp;
	uint_32 year, date, time;
	int flag = -1;	
	uint_32 i, count;
	uint_32 tmpvalue = 0;
	uint_32 value = 0;

	if(para->YEAR == 0)
		year = tmp.YEAR - baseyear;
	else 
		year = para->YEAR - baseyear;

	if(para->DATE == 0)
		date = tmp.DATE - basedate;
	else 
		date = para->DATE - basedate;

	if(para->TIME == 0)
		time = tmp.TIME;
	else
		time = para->TIME;

	for(i=0, count=0; i<=year; ){
		if(((baseyear+i)%400 == 0) || (((baseyear+i)%4 == 0)&&((baseyear+i)%100 != 0)))
			count++;
		i++;
	}	

	flag = (((baseyear+year)%400 == 0) || (((baseyear+year)%4 == 0)&&((baseyear+year)%100 != 0)))?1:0;
	if(flag == 1){
		tmpvalue = year*365+count-1;
	}else{
		tmpvalue = year*365+count;
	}
	
	 tmpvalue += getdays(date, flag);
	 value = ((tmpvalue*24+time/10000)*60+(time%10000)/100)*60 + (time%100);

	 return value;
}