Error 403 from Google Calendar? Upgrade to the new Google Calendar support. See here for details. close
Welcome, Guest
Please Login or Register.    Lost Password?

Incorrect Easter date
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: Incorrect Easter date
#16624
Incorrect Easter date 2 Years, 9 Months ago  
Using the code in the Wiki for calculate Easter gives me for 2012 the date of Good Friday on April 7th. But April 7th is Saturday.
I was using this code in an Excel ready-to-print calendar. It's more or less the same code, but with another approach. For 2012, it gives me the correct date of April 6th.

Code:

function Holidays_CalculateEaster(year)
  golden = (year % 19) + 1
  c = math.floor(year/400) + math.floor(8*(math.floor(year/100)+11)/25) - math.floor(year/100)
  s = (11 * golden + c) % 30
  if (s < 0) then
    s = s + 30
  end
  pfm = os.time{year=year, month=4, day=19} - s * 24 * 60 * 60
  if (pfm == os.time{year=year, month=4, day=19}) then
    pfm = pfm - 24 * 60 * 60
  elseif (pfm == os.time{year=year, month=4, day=18} and golden > 11) then
    pfm = pfm - 24 * 60 * 60
  end
  sunday = pfm + (7 - tonumber(os.date("%w", pfm))) * 24 * 60 * 60
  friday = sunday - 2 * 24 * 60 * 60

  return {year, tonumber(os.date("%m", friday)), tonumber(os.date("%d", friday))} 
end



PS: Maybe 86400 is better than 24*60*60, but it's more easy to understand.
Jorge_Luis
Platinum Boarder
Posts: 795
graphgraph
User Offline Click here to see the profile of this user
Gender: Male My Rainlendar Skins Location: Argentina Birthday: 03/15
The administrator has disabled public write access.
 
#16639
Re:Incorrect Easter date 2 Years, 9 Months ago  
I tested it, seem no problem.
anoob
Platinum Boarder
Posts: 508
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Location: TaiChung, Taiwan, R.O.C. Birthday: 02/12
The administrator has disabled public write access.
I couldn't speak English! This skin released to Customize.org(Do you want it? Click Picture) Please contact me if interested: jhg5702@gmail.com
 
#16640
Re:Incorrect Easter date 2 Years, 9 Months ago  
Sorry anoob, which one has no problem?
The code I pasted is the new one that I'm using.

Using the code from the wiki (wiki.rainlendar.info/images/0/04/Holidays.lua) brings me other values. Here are the values I got doing it matematically, using year=2012:

golden = 18
dom = 1
solar = 3
lunar = 1
pfm = -13 (< 0) ==> pfm = 17
tmp = 0
friday = 17
YEAR=2012 MONTH=4 DAY=7

I'm thinking... what if it's something related with the timezone? (I'm GMT-3)
Jorge_Luis
Platinum Boarder
Posts: 795
graphgraph
User Offline Click here to see the profile of this user
Gender: Male My Rainlendar Skins Location: Argentina Birthday: 03/15
Last Edit: 2012/02/03 12:21 By Jorge_Luis.Reason: A little bit confusion
The administrator has disabled public write access.
 
#16643
Re:Incorrect Easter date 2 Years, 9 Months ago  
Oh!, I was testing the first code you posted.

About the second posted code, Are you sure it is correct?
I test it with many different years, and it seems allways has 1 day offset. so i think that it maybe incorrect.
suggest modify following line as:
friday = math.floor(pfm + tmp) - 1
anoob
Platinum Boarder
Posts: 508
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Location: TaiChung, Taiwan, R.O.C. Birthday: 02/12
Last Edit: 2012/02/05 00:33 By anoob.
The administrator has disabled public write access.
I couldn't speak English! This skin released to Customize.org(Do you want it? Click Picture) Please contact me if interested: jhg5702@gmail.com
 
#16700
Re:Incorrect Easter date 2 Years, 9 Months ago  
I updated the script with the Jorge_Luis' version of the calculation.
Rainy
Moderator
Posts: 6052
graph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#16714
Re:Incorrect Easter date 2 Years, 9 Months ago  
A small mistake (not affect the displayed) about Good Friday,
End Time earlier than Start Time in the Event-Dialog.
Suggestion: remove the line 89 - strEvent = strEvent .. "DTEND;VALUE=DATE:" .. string.format("%04i%02i%02i", date[1], date[2], date[3]) .. "\n"
anoob
Platinum Boarder
Posts: 508
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Location: TaiChung, Taiwan, R.O.C. Birthday: 02/12
The administrator has disabled public write access.
I couldn't speak English! This skin released to Customize.org(Do you want it? Click Picture) Please contact me if interested: jhg5702@gmail.com
 
Go to topPage: 12
get the latest posts directly to your desktop