Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Zeller's congruence to get day of week
#10
Code: (Select All)
CheckDate = Date$
CheckTime = Time$
If CheckDate <> Date$ Then ' Midnight rolled over
    CheckDate = Date$
    CheckTime = Time$
End If

I don't think the above is going to catch any Midnight roll over for you. Follow along with me and think of this little scenario:

CheckDate = Date$ '23:59.9998 time (HH:MM:SSSS)
CheckTime = Time$ '23:59.9998 time
If CheckDate <> Date$ Then ' 23:59.9999 time ==> OH NOS! TIME DOESN'T MATCH! GET NEW TIME!
    CheckDate = Date$ ' 23:59.9999 time
    CheckTime = Time$ ' 00:00.0000 time <-- Midnight just rolled over between those times!
End If[/code]

As you can see, you're not preventing the Date from falling behind. If it can fall behind after the first CheckDate = Date$ assignment, then why can't it fall behind at the second CheckDate = Date$ assignment?

Seems to me like the only way to do what you're wanting would be to verify the date again before the PRINT statement. Check the CheckDate$ vs Date$ there, and if it's not the same at that point, then redo the process with the new date...

(And yet, that can't catch 100% of all date change errors, as the date might change in the millisecond after that check, and while the PRINT is printing the date...)

Sometimes you just have to shrug and say, "Close enough is close enough."
Reply


Messages In This Thread
RE: Simple Zeller's congruence to get day of week - by SMcNeill - 09-16-2024, 12:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple Finances Utility ASCIIhole 6 438 02-02-2026, 06:21 PM
Last Post: ASCIIhole
  Zeller's congruence pass 3: test day-of-week calculation algorythms for accuracy TDarcos 0 1,101 10-23-2024, 05:04 PM
Last Post: TDarcos
  Archive-dot-org simple helper mnrvovrfc 11 2,620 07-14-2023, 12:43 AM
Last Post: grymmjack
  Simple directory display eoredson 0 529 03-29-2023, 03:01 AM
Last Post: eoredson
  Simple Mouse Wheel Scolling Pete 9 1,879 12-27-2022, 11:41 PM
Last Post: grymmjack

Forum Jump:


Users browsing this thread: 1 Guest(s)