Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:58 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Leap year

Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 01:53am 01 Mar 2020
Copy link to clipboard 
Print this post

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 States
Posts: 719
Posted: 02:29am 01 Mar 2020
Copy link to clipboard 
Print this post

O.M.G !
It's Y2K all over again  
my site
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 03:17am 01 Mar 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 581
Posted: 06:07am 01 Mar 2020
Copy link to clipboard 
Print this post

  Quote  30-02-2020


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: Australia
Posts: 6283
Posted: 06:40am 01 Mar 2020
Copy link to clipboard 
Print this post

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.


  Quote  DATE$ = "28/02/20"
TIME$ = "23:59:50"

FOR n = 1 TO 20
PRINT DATE$;" ";TIME$
PAUSE 1000
NEXT n
PRINT
DATE$ = "29/02/20"
TIME$ = "23:59:50"

FOR n = 1 TO 20
PRINT DATE$;" ";TIME$
PAUSE 1000
NEXT n



> 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: Australia
Posts: 6283
Posted: 06:45am 01 Mar 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 6283
Posted: 07:01am 01 Mar 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 1993
Posted: 08:30am 01 Mar 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 1097
Posted: 11:40pm 01 Mar 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 581
Posted: 11:49pm 01 Mar 2020
Copy link to clipboard 
Print this post

  Quote  but it wasn't showing.


The number of replies quoted is not matching the total replies displayed either
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 03:03pm 02 Mar 2020
Copy link to clipboard 
Print this post

Thanks Jim, I will fix it in the next release.
Geoff
Geoff Graham - http://geoffg.net
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 12:57am 06 Mar 2020
Copy link to clipboard 
Print this post

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.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025