summaryrefslogtreecommitdiff
path: root/clock.c
diff options
context:
space:
mode:
Diffstat (limited to 'clock.c')
-rw-r--r--clock.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/clock.c b/clock.c
index 3068816..270edff 100644
--- a/clock.c
+++ b/clock.c
@@ -15,31 +15,42 @@
struct time data time;
-u8 code MDAYS[] = {
+const u8 code MDAYS[] = {
29, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+u8 is_cet(void)
+{
+ return ((time.flags & FLAG_CET) && !(time.flags & FLAG_CEST));
+}
+
+u8 is_cest(void)
+{
+ return ((time.flags & FLAG_CEST) && !(time.flags & FLAG_CET));
+}
void clock(void)
{
u8 i;
time.second++;
- if( time.second == 60 ){
+ if( time.second >= 60 ){
+ if (time.flags & FLAG_LEAP_SECOND && time.second == 60) {
+ return;
+ }
time.second = 0;
timeflags = 1<<ONE_MINUTE; // to correct deviation per minute
time.minute++;
if( time.minute == 60 ){
time.minute = 0;
time.hour++;
- switch( time.hour ){
- case 24:
+ if (time.hour == 24) {
time.hour = 0;
time.day++;
time.wday++;
if( time.wday == 8 )
time.wday = 1;
i = time.month;
- if( i == 2 && (time.year & 3) == 0 ) // leap year
+ if( i == 2 && !(time.year % 4) ) // leap year
i = 0;
if( LPM(MDAYS+i) < time.day ){
time.day = 1;
@@ -51,9 +62,14 @@ void clock(void)
time.year = 0; // next century
}
}
- break;
-// case 2:
-// case 3: summertime(); break;
+ }
+ if (time.flags & FLAG_SUMMERTIME_PENDING) {
+ if (is_cet() && time.hour == 2) {
+ time.hour = 3;
+ }
+ if (is_cest() && time.hour == 3) {
+ time.hour = 2;
+ }
}
}
}