summaryrefslogtreecommitdiff
path: root/firmware/common
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common')
-rw-r--r--firmware/common/timefuncs.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c
index e59534eeba..774fba9ab0 100644
--- a/firmware/common/timefuncs.c
+++ b/firmware/common/timefuncs.c
@@ -194,12 +194,15 @@ time_t mktime(struct tm *t)
194} 194}
195#endif 195#endif
196 196
197int day_of_week(int m, int d, int y) 197void set_day_of_week(struct tm *tm)
198{ 198{
199 int y=tm->tm_year+1900;
200 int d=tm->tm_mday;
201 int m=tm->tm_mon;
199 static const char mo[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; 202 static const char mo[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
200 203
201 if(m == 0 || m == 1) y--; 204 if(m == 0 || m == 1) y--;
202 return (d + mo[m] + y + y/4 - y/100 + y/400) % 7; 205 tm->tm_wday = (d + mo[m] + y + y/4 - y/100 + y/400) % 7;
203} 206}
204 207
205void yearday_to_daymonth(int yd, int y, int *d, int *m) 208void yearday_to_daymonth(int yd, int y, int *d, int *m)