[riot-notifications] [RIOT-OS/RIOT] periph/rtc: normalize struct tm before usage (#11413)

benpicco notifications at github.com
Thu Sep 12 11:29:18 CEST 2019


benpicco commented on this pull request.



> +    return 31 - ((month % 7) & 1);
+}
+
+#if RTC_NORMALIZE_COMPAT
+static int _wday(int day, int month, int year)
+{
+    /* Tomohiko Sakamoto's Algorithm */
+    static const uint8_t t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
+    year -= month < 2;
+    return (year + year/4 - year/100 + year/400 + t[month] + day) % 7;
+}
+
+static int _yday(int day, int month, int year)
+{
+    static const uint8_t d[] = { 0,  31,  59, 90, 120, 151,
+                               181, 212, 243, 17,  48,  78};

Now I think this just makes it ugly.
The wrap-around is already explained in two other places now.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11413#discussion_r323643155
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190912/a9edf755/attachment-0001.htm>


More information about the notifications mailing list