[an error occurred while processing this directive]
[an error occurred while processing this directive]
|
persistent char Second; // Seconds Counter
persistent char Minute; // Minutes Counter
persistent char Hour; // Hours Counter
persistent char Day; // Days Counter
persistent char Month; // Months Counter
persistent char Year; // Years Counter
persistent - значит не обнуляемый после сброса
Прерывание от таймера, каждую секунду:
//- - - - - - - - - - - - - - - - - - - - - - -//
Second++; // Real Time Clock service
if (Second >= 60)
{
Second = 0;
Minute++;
}
if (Minute >= 60)
{
Minute = 0;
Hour++;
}
if (Hour >= 24)
{
Hour = 0;
Day++;
}
{ char lastday;
switch (Month)
{
case 2: if ((Year & 0x03)==0) lastday = 29;
else lastday = 28;
break;
case 4:
case 6:
case 9:
case 11: lastday = 30; break;
default: lastday = 31; break;
}
if (Day > lastday)
{
Day = 1;
Month++;
}
}
if (Month > 12)
{
Month = 1;
Year++;
}
if (Year >= 100) Year = 0;
//- - - - - - - - - - - - - - - - - - - - - - -//
E-mail: info@telesys.ru