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 : Maximite date bug?
Author | Message | ||||
Juri74 Senior Member Joined: 06/02/2012 Location: ItalyPosts: 162 |
hello.. try DATE$="30-02-2014"
Print DATE$ regards juri |
||||
atmega8 Guru Joined: 19/11/2013 Location: GermanyPosts: 722 |
works as expected: > DATE$="30-02-2014" > print date$ 30-02-2014 > |
||||
BobD Guru Joined: 07/12/2011 Location: AustraliaPosts: 935 |
So you are saying you can set the date wrong. Try setting to 23:59 on 28-02-2014 and see if it transitions to 01-03-2014 correctly. |
||||
atmega8 Guru Joined: 19/11/2013 Location: GermanyPosts: 722 |
Transition to 01-03-2014 works also correct |
||||
donmck Guru Joined: 09/06/2011 Location: AustraliaPosts: 1313 |
Really a matter of how far you go with error checking code, when it is obviously a user input error. Like month 13. Do you check for this? As long as you can input an actual date, and have it rollover correctly, then all is well. Don... https://www.dontronics.com |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9308 |
This is what I use for my RTC setting: [code] BF=0 if len(lin$)<>8 then BF=1 if mid$(lin$,3,1)<>":" or mid$(lin$,6,1)<>":" then BF=1 if val(mid$(lin$,1,2))<0 or val(mid$(lin$,1,2))>24 then BF=1 if VAL(mid$(lin$,4,2))<0 or val(mid$(lin$,4,2))>59 then BF=1 if val(mid$(lin$,7,2))<0 or val(mid$(lin$,7,2))>59 then BF=1 if BF=1 then print @(35,150) + clr$(Red) "Unacceptable format." pause 2500:goto start endif Time$=lin$:GoTo Start [/code] And for setting and checking the date: [code] BF=0 if len(lin$)<>8 then BF=1 if mid$(lin$,3,1)<>"-" or mid$(lin$,6,1)<>"-" then BF=1 if val(mid$(lin$,1,2))<1 or val(mid$(lin$,1,2))>31 then BF=1 if VAL(mid$(lin$,4,2))<1 or val(mid$(lin$,4,2))>12 then BF=1 if val(mid$(lin$,7,2))<1 or val(mid$(lin$,7,2))>99 then BF=1 if BF=1 then print @(35,150) + clr$(Red) "Unacceptable format." pause 2500:goto start endif date$=lin$ gosub SetLog GoTo Start [/code] lin$ is the user-entered date or time string. This is basic, and still allows you to enter something along the lines of 30-02-14 for the date, which you have already mentioned, is an illegal date, however some checking is better then none. I expect that the checking could be expanded with the help of a string array, so that if "02" was specified as the month, then the day cannot be greater then "28". I don't imagine that would be THAT hard to do. As Don says - how far do you really go with this kind of error checking? (rhetorical!) Smoke makes things work. When the smoke gets out, it stops! |
||||
Print this page |