kmp84
Joined: 02 Feb 2010 Posts: 345
|
|
Posted: Thu Apr 01, 2021 9:34 am |
|
|
Hi mr.Ttelmah,
Thanks for help! Now it's OK.
I've added this line "timeT->month -= 1;", but I don't know porpose of this "timeT->month %= 12;" and this :
Code: |
#ifdef TIME_T_USES_2010
i = 110;
#else
i = 70;
#endif |
Last my code:
Code: |
time_t mktime(rtc_time_t *timeT){
time_t unixTime = 0;
int1 isLeapYear = FALSE;
unsigned int16 i = 0;
unsigned int16 tmp_year;
tmp_year = 2000+timeT->year;
timeT->month -= 1;
if(timeT != '\0'){
unixTime += timeT->second;
unixTime += (unsigned int32)(timeT->minute) * 60;
unixTime += (unsigned int32)(timeT->hour) * 3600;
isLeapYear = LeapYear(tmp_year);
/* Clamp the month to [0,11) */
//timeT->month %= 12;
for(i=1; i<=timeT->month; i++)
{
unixTime += (DaysInMonth(i - 1, isLeapYear) * 86400);
}
/* Clamp the days in the month */
//timeT->tm_mday %= DaysInMonth(timeT->tm_mon,isLeapYear);
unixTime += (timeT->dayOfMonth - 1) * 86400;
#ifdef TIME_T_USES_2010
i = 110;
#else
i = 70;
#endif
while(i < tmp_year){
isLeapYear = LeapYear(i);
if(isLeapYear)
unixTime += (31622400); // seconds in 366 days
else
unixTime += (31536000); // seconds in 365 days
i++;
}
}
return unixTime;
} |
|
|