![]() |
Forum Index : Microcontroller and PC projects : Leap year
Author | Message | ||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I noticed that a couple of my micromites had an interesting date today > print time$ 12:59:24 > print date$ 30-02-2020 > both are running MMBasic V 5.4.x I haven't had a chance to test later versions but I don't remember any changes being made. Jim VK7JH MMedit |
||||
hitsware2![]() Guru ![]() Joined: 03/08/2019 Location: United StatesPosts: 719 |
O.M.G ! It's Y2K all over again ![]() my site |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
My weather station is running V5.0501 and it was OK. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
zeitfest Guru ![]() Joined: 31/07/2019 Location: AustraliaPosts: 581 |
I am guessing, the date is set from a RTC at startup ? Are there dodgy RTC ics out there .. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
No RTC involved. Both micromites do their own timekeeping and are running 24/7. I just updated one to MMBasic 5.5.2 and the same problem exists. > RUN 28-02-2020 23:59:50 28-02-2020 23:59:51 28-02-2020 23:59:52 28-02-2020 23:59:53 28-02-2020 23:59:54 28-02-2020 23:59:55 28-02-2020 23:59:56 28-02-2020 23:59:57 28-02-2020 23:59:58 28-02-2020 23:59:59 29-02-2020 00:00:00 29-02-2020 00:00:01 29-02-2020 00:00:02 29-02-2020 00:00:03 29-02-2020 00:00:04 29-02-2020 00:00:05 29-02-2020 00:00:06 29-02-2020 00:00:07 29-02-2020 00:00:08 29-02-2020 00:00:09 29-02-2020 23:59:50 29-02-2020 23:59:51 29-02-2020 23:59:52 29-02-2020 23:59:53 29-02-2020 23:59:54 29-02-2020 23:59:55 29-02-2020 23:59:56 29-02-2020 23:59:57 29-02-2020 23:59:58 29-02-2020 23:59:59 30-02-2020 00:00:00 30-02-2020 00:00:01 30-02-2020 00:00:02 30-02-2020 00:00:03 30-02-2020 00:00:04 30-02-2020 00:00:05 30-02-2020 00:00:06 30-02-2020 00:00:07 30-02-2020 00:00:08 30-02-2020 00:00:09 > Same results for the earlier version of MMBasic. The source code looks correct but something strange is happening. It can't just be Tasmania time that has the problem. (We wanted one more day of summer?) Jim VK7JH MMedit |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
It keeps going for a couple of days: 30-02-2020 23:59:50 30-02-2020 23:59:51 30-02-2020 23:59:52 30-02-2020 23:59:53 30-02-2020 23:59:54 30-02-2020 23:59:55 30-02-2020 23:59:56 30-02-2020 23:59:57 30-02-2020 23:59:58 30-02-2020 23:59:59 31-02-2020 00:00:00 31-02-2020 00:00:01 31-02-2020 00:00:02 31-02-2020 00:00:03 31-02-2020 00:00:04 31-02-2020 00:00:05 31-02-2020 00:00:06 31-02-2020 00:00:07 31-02-2020 00:00:08 31-02-2020 00:00:09 31-02-2020 23:59:50 31-02-2020 23:59:51 31-02-2020 23:59:52 31-02-2020 23:59:53 31-02-2020 23:59:54 31-02-2020 23:59:55 31-02-2020 23:59:56 31-02-2020 23:59:57 31-02-2020 23:59:58 31-02-2020 23:59:59 01-03-2020 00:00:00 01-03-2020 00:00:01 01-03-2020 00:00:02 01-03-2020 00:00:03 01-03-2020 00:00:04 01-03-2020 00:00:05 01-03-2020 00:00:06 01-03-2020 00:00:07 01-03-2020 00:00:08 01-03-2020 00:00:09 > VK7JH MMedit |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I know enough C to be dangerous but I think I have found the problem. In timers.c line 303 the closing swuare bracket is in the wrong place. if(++day > DaysInMonth[month + ((month == 2 && (year % 4) == 0)?1:0)]) { I think should be if(++day > DaysInMonth[month] + ((month == 2 && (year % 4) == 0)?1:0)) { The first version is adding one to the month number and therefore retrieving March = 31 days instead of retrieving February and adding one 28+1 = 29 Jim VK7JH MMedit |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
Sorry I am using RTC. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
Got one running 5.01 Rolled over OK from Feb to Mar Edit. Before this post, the Forum indicated that there was a reply from Panky this morning, but it wasn't showing. Mine come up OK Edited 2020-03-02 09:45 by Chopperp ChopperP |
||||
zeitfest Guru ![]() Joined: 31/07/2019 Location: AustraliaPosts: 581 |
The number of replies quoted is not matching the total replies displayed either |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
Thanks Jim, I will fix it in the next release. Geoff Geoff Graham - http://geoffg.net |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
That C source code will incorrectly recognize 2100 as a leap year. Beware in 80 years. (And in 180 and 280 years, but not in 380 years.) Visit Vegipete's *Mite Library for cool programs. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |