Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Diff: http-clock-script.inc
- Revision:
- 21:048b7dbdf0aa
- Parent:
- 15:2cea2bbd5046
- Child:
- 22:f45bbb468439
diff -r 007fb5796d20 -r 048b7dbdf0aa http-clock-script.inc
--- a/http-clock-script.inc Wed Jan 09 08:07:53 2019 +0000
+++ b/http-clock-script.inc Wed Jan 09 12:25:08 2019 +0000
@@ -100,21 +100,15 @@
" if (!leapEnable) return; // Adjustment disabled\n"
" \n"
" //Get the calander date and time from the ms\n"
-" var now = new Date(msCount - msCountAtRtcSet + msRtc);\n"
-" var y = now.getUTCFullYear();\n"
-" var n = now.getUTCMonth () + 1;\n"
-" var d = now.getUTCDate ();\n"
-" var h = now.getUTCHours ();\n"
-" var m = now.getUTCMinutes ();\n"
-" var s = now.getUTCSeconds ();\n"
+" var now = new Date(msCount - msCountAtRtcSet + msRtc);\n"
+" var leapStart = new Date(leapyear, leapmonth - 1, 1, 0, 0, leapBackward ? -1: 0);\n"
+" \n"
+" if (now < leapStart) return; //Do nothing until reached the leap start\n"
" \n"
-" //Check for leap\n"
-" if (y == leapyear && n == leapmonth && d == 1 && m == 0 && s == 0)\n"
-" {\n"
-" leapEnable = false;\n"
-" if (leapBackward) { msRtc += 1000; leaps -= 1; }\n"
-" else { msRtc -= 1000; leaps += 1; }\n"
-" } \n"
+" if (leapBackward) { msRtc += 1000; leaps -= 1; } //skip 59\n"
+" else { msRtc -= 1000; leaps += 1; } //repeat 59\n"
+" \n"
+" leapEnable = false;\n"
"}\n"
"function displayTime()\n"
"{\n"