Re: A82: Confirm Calendar Bug..


[Prev][Next][Index][Thread]

Re: A82: Confirm Calendar Bug..




Ahmed, here's the final word in how to find what day it is: (I took this
from some FAQ).  This shouldn't be too hard to implement for ASM.
Especially when Dines releases ASH 3.1 w/math ROM Call support!
				Rob Bonstein


To calculate the day on which a particular date falls, the following
algorithm may be used (the divisions are integer divisions, in which
remainders are discarded):

a = (14 - month) / 12
y = year - a
m = month + 12*a - 2
For Julian calendar: d = (5 + day + y + y/4 + (31*m)/12) % 7
For Gregorian calendar: d = (day + y + y/4 - y/100 + y/400 + (31*m)/12) % 7

The value of d is 0 for a Sunday, 1 for a Monday, 2 for a Tuesday, etc.

Example: On what day of the week was the author born?

My birthday is 2 August 1953 (Gregorian, of course).

a = (14 - 8) / 12 = 0
y = 1953 - 0 = 1953
m = 8 + 12*0 - 2 = 6
d = (2 + 1953 + 1953/4 - 1953/100 + 1953/400 + (31*6)/12) % 7
  = (2 + 1953 +  488   -    19    +     4    +    15    ) % 7
  = 2443 % 7  = 0

I was born on a Sunday.



At 04:43 PM 6/2/98 -0400, you wrote:
>
>Hey,
>    Would someone clarify to me 100% .. what is wrong w/my Calendar program?
>Should 2000 be 29 days or is it correct as 28?  If it is incorrect, then is
>all 400x years [0,400,800,...] have 29 days whereas all other 100 years have
>28?   Can someone tell me for sure?  I will probably also add saving feature
>in the next version... Thanks for any help.
>                                                                            
>-Ahmed
>
>ahmedre@bellsouth.net
>
>http://asm8x.home.ml.org
>
>


References: