Jump to content


Photo
- - - - -

[download] CalculateEaster


  • Please log in to reply
7 replies to this topic

#1 chucklyons

chucklyons

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 803 posts
  • Software:Premise

Posted 04 April 2015 - 08:31 PM

File Name: CalculateEaster
File Submitter: chucklyons
File Submitted: 04 Apr 2015
File Category: Premise
Author: chucklyons
Contact: [email protected]

For those that use 123's Newscaster Module, this scriptmacro will calculate Easter (allegedly for many years to come) and creates a NewsEvent called 'Easter'
 
Unzip. Import. Go to Modules->Newscaster->Macros->CalculateEaster. Select 'Trigger' in the properties pane
 
Navigate to Media->Newscaster and you should see a NewEvent called 'Easter'.
 
(I'll prob need to add an autodelete or something so that it can force the recalculation)

Click here to download this file

#2 123

123

    Cocoonut

  • Registered
  • PipPipPipPip
  • 2170 posts
  • Location:Montreal, QC
  • Experience:average
  • Software:Premise
  • Hardware:Elk M1

Posted 07 April 2015 - 11:20 AM

Chuck,

 

FWIW, Newscaster includes the following: Module >Global>Globalscripts>gTimeDate.

 

gTimeDate contains 31 date, solar and lunar-related functions including "gGetEasterDay":

  1. function gIsDST(dDate)
  2. function gIsLeapYear (ByVal iYear)
  3. function gNthSomedayOfMonth(dDate, iNth, iDayOfWeek)
  4. function gLastSomedayOfMonth(dDate, iDayOfWeek)
  5. function gDaysInMonth(iMonth)
  6. function gWeeksInMonth(iMonth)
  7. function gWeekOfMonth(dDate)
  8. function gIsWeekday(dDate)
  9. function gInNthWeek(dDate, iNthWeek)
  10. function gInLastWeek(dDate)
  11. function gClockTime(dTime, b24Hour)
  12. function gTimeInRange(ByVal startTime, ByVal endTime)
  13. function gGetEasterDay(iYear, iEventID)
  14. function gIsEventDay(dDate, iEventID)
  15. function gRiseAndSetTimes(ByVal dDate, ByVal gLong, ByVal gLat, ByVal iTimeZone, ByVal iDST, ByVal sEvent, ByRef sRiseTime, ByRef sSetTime, ByRef sStatus)
  16. function gMoonsAge(ByVal dDate)
  17. function gModifiedJulianDate(Y, m, d, h)
  18. function gSinAlt(bIsSun, mjd0, hr, gLong, cphi, sphi)
  19. function gFractional(X)
  20. function gHrMn(ut, iDST)
  21. function gLMST(mjd, gLong)
  22. function gMoonPhase(iMoonAge)
  23. function gMoonPhaseName(iMoonPhaseNumber)
  24. function gGetSeasonStart(iSeasonNumber)
  25. function gGetSeasonEnd(iSeasonNumber)
  26. function gGetSeason
  27. function gGetSeasonName(iSeasonNumber)
  28. function gDayOfSeason
  29. function gWeekOfSeason
  30. function gWeeksInSeason(iSeasonNumber)
  31. function gDaysInSeason(iSeasonNumber)
gGetEasterDay takes two arguments:
  1. Year
  2. Event
where Event is a number from 0-13 corresponding to the following easter-related events:
0  Easter
1  Palm Sunday
2  Mardi Gras
3  Ash Wednesday
4  Holy Thursday
5  Good Friday
6  Christian Passover
7  Pentecost
8  Ascension
9  Pentecost
10 Rogation Sunday
11 Corpus Christi
12 Quasimodo Sunday
13 Easter Monday
 
gGetEasterDay returns the date in dateserial format.
 
 
 
My recollection of NewsCaster is foggy but I think I had planned (but never implemented) a Timer that would run annually (say 12:05 AM on January 1st) and automatically populate the new year with Events like Easter, Labor Day, Thanksgiving, etc.
 
The function called gIsEventDay is used by NewsCaster to determine if the current day has any significance (New Year's Day, Christmas, etc) and will announce it (but not create an Event like your Macro does). gIsEventDay knows about the following significant days:
  • April Fools
  • Black Friday, Fourth Friday of November
  • Boxing
  • Canada Day
  • Christmas
  • Columbus Day, Second Monday of October
  • Easter, First Sunday after Full Moon after vernal equinox
  • Easter Monday, First Monday after Easter
  • Fathers Day, Third Sunday of June
  • Good Friday, Friday before Easter
  • Ground Hog
  • Halloween
  • Independence Day
  • Labor Day, First Monday of September
  • Mardi Gras, Forty-six days before Easter
  • Martin Luther King Jr Day, Third Monday of January
  • Memorial Day, Last Monday of May
  • Mothers Day, Second Sunday of May
  • New Years 
  • New Years Eve
  • Palm Sunday, Sunday before Easter
  • Presidents Day, Third Monday of February
  • Remembrance
  • Saint Patricks
  • Thanksgiving CAN, Second Monday in October
  • Thanksgiving Day USA, Fourth Thursday of November
  • Valentines
  • Veterans
  • Victoria Day, Last Monday before May 25th
 

Edited by 123, 07 April 2015 - 11:27 AM.


#3 chucklyons

chucklyons

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 803 posts
  • Software:Premise

Posted 09 April 2015 - 10:18 AM

Fantastic! Now I can redo the WU module, as well! Finding all of those formulas must have taken quite a while..



#4 chucklyons

chucklyons

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 803 posts
  • Software:Premise

Posted 05 May 2015 - 12:31 AM

123, given my rudimentary coding skills, as an example, how would I use the gDateTime in global to show Memorial Day in Newscaster?



#5 123

123

    Cocoonut

  • Registered
  • PipPipPipPip
  • 2170 posts
  • Location:Montreal, QC
  • Experience:average
  • Software:Premise
  • Hardware:Elk M1

Posted 05 May 2015 - 01:52 PM

Memorial Day is the last Monday in May so I'd use the "gLastSomedayInMonth" function. It returns the last "someday" (Sunday or Monday or etc) for a given month and year.

 

It takes two arguments:

  • dDate 
    This function is only interested in the month and year in "dDate". Just supply the first day of May (i.e. "5/1/2015").
  • iDayOfWeek 
    "iDayOfWeek" follows VBScript's default convention of numbering the days of the week (i.e. Sunday=1). Therefore Monday is "2".

 

Example:

When is  Memorial Day in 2018?

 

Answer = gLastSomedayOfMonth("5/1/2018", 2)

 

Answer is "5/28/2018".



#6 John in VA

John in VA

    Dedicated Cocooner

  • -=Gold Supporter=-
  • 240 posts
  • Location:Reston, VA
  • Experience:average
  • Software:Premise
  • Tech:INSTEON
  • Audio:Nuvo
  • Video:Windows Media Center
  • CCTV:analog, ip, dvr
  • Phone:Vonage

Posted 05 May 2015 - 04:38 PM

And, what about Orthodox Easter?  You have at least one Greek using this system.

 

All kidding aside, this is very cool!!!  Great job!



#7 samgreco

samgreco

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 676 posts
  • Location:Villa Park, IL
  • Experience:average
  • Software:Premise
  • Tech:UPB, Z-Wave, ZigBee
  • Audio:Custom
  • Video:Custom

Posted 05 May 2015 - 06:59 PM

Amd one Greco...



#8 chucklyons

chucklyons

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 803 posts
  • Software:Premise

Posted 12 May 2015 - 10:39 PM

Sooo...I took 123's Global 'gIsEventDay' and created a macro. So when you initialize, it creates all of the holidays in that function. I did find an equation for the Greek Orthodox Easter. I'll leave it up to those who are interested to verify the accuracy of the dates.

 

I'll post this weekend after I beat on it a bit more...and wait for a volunteer for the Greek Easter ^_^






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users