Easter Day (calculation algorithm)

Discussion in 'Code Samples & Tips' started by maXim, Mar 19, 2008.

  1. maXim

    maXim Active Member Licensed User

    Hi Everyone,

    a simple solution to detect the Easter day:
     

    Attached Files:

  2. alfcen

    alfcen Well-Known Member Licensed User

    Ciao MaXim

    Wow, your coding required a great deal of concentration.
    Here is a shorter version:

    Code:
    Sub DateOfEaster(y)
      
    Dim c, n, k, i, j, l, m, d
      c = Int(y / 
    100)
      n = y - 
    19 * int( y / 19 )
      k = int(( c - 
    17 ) / 25)
      i = Int(c - int(c / 
    4) - ( c - k ) / 3 + 19 * n + 15)
      i = i - 
    30 * int( i / 30 )
      i = i - int(i / 
    28 ) * ( 1 - int( i / 28 ) * int( 29 / ( i + 1 ) ) * int( ( 21 - n ) / 11 ) )
      j = y + int(y / 
    4) + i + 2 - c + int(c / 4)
      j = j - 
    7 * int( j / 7 )
      l = i - j
      m = int(
    3 + (l + 40 ) / 44)
      d = l + 
    28 - 31 * int( m / 4 )
      
    if m = 3 Then Return "March " & d
      
    if m = 4 Then Return "April " & d
    End Sub
    Perhaps a later version of B4P will add the "\" operator.

    Feel free to use or abuse :)

    Roberto
     
  3. maXim

    maXim Active Member Licensed User

    Last edited: Mar 19, 2008
Loading...