Easter date and Easter Monday date

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
BAM
Newbie
Posts: 4
Joined: Fri Nov 24, 2017 6:56 pm

Easter date and Easter Monday date

Post by BAM » Sat Feb 19, 2022 8:13 am

Here is a little SRT to calculate the Easter and the Easter Monday based on the year. It's use the Vbscript written by me vbs_PadString and you can find it below.

The results variables are:
pasqua_1 = Easter date
pasqua_2 = Easter Monday date

Return date are in dd/mm/yyyy format


/*

Calcola data pasqua e lunedì dell'Angelo in base all'anno

Var_1: (I) Anno

*/
SRT>get_EASTER_DATE
Let>anno=get_EASTER_DATE_Var_1

Let>nc={Int(%anno%/100)}
Let>nn={%anno%-19*(Int(%anno%/19))}
Let>nk={Int((%nc%-17)/25)}
Let>ni1={(%nc%-Int(%nc%/4)-Int((%nc%-%nk%)/3)+(19*%nn%)+15)}
Let>ni2={%ni1%-30*Int(%ni1%/30)}
Let>ni3={%ni2%-Int(%ni2%/28)*(1-Int(%ni2%/28)*Int(29/(%ni2%+1))*Int((21-%nn%)/11))}
Let>nj1={%anno%+Int(%anno%/4)+%ni3%+2-%nc%+Int(%nc%/4)}
Let>nj2={%nj1%-7*(Int(%nj1%/7))}
Let>nl={%ni3%-%nj2%}
Let>Pmese={3+Int((%nl%+40)/44)}
Let>Pgiorno={%nl%+28-31*Int(%Pmese%/4)}
IF>{(%Pmese%=3) AND (%Pgiorno%=31)}
Let>Lmese=4
Let>Lgiorno=1
else
Let>Lmese=%Pmese%
Let>Lgiorno={(%PGiorno%+1)}
ENDIF
Let>length=2
VBEval>vbs_PadString("%Pmese%",2,"0","left"),Pmese
VBEval>vbs_PadString("%Pgiorno%",2,"0","left"),Pgiorno
VBEval>vbs_PadString("%Lmese%",2,"0","left"),Lmese
VBEval>vbs_PadString("%Lgiorno%",2,"0","left"),Lgiorno
Let>pasqua_1=%Pgiorno%/%Pmese%/%anno%
Let>pasqua_2=%Lgiorno%/%Lmese%/%anno%

END>get_EASTER_DATE

VBSTART
' This function pads a string to a specified length
' pString - String to pad
' pLength - Required length
' pChar - Single character to use for padding
' pSide - Add padding on the "left" or "right"
' If the string is already longer than pLength it will be truncated.
Function vbs_PadString(pString,pLength,pChar,pSide)
strString = pString
strPadding = String(pLength,pChar)
If lcase(pSide)="left" then
strString = strPadding & strString
strString = Right(strString,pLength)
else
strString = strString & strPadding
strString = Left(strString,pLength)
End if
vbs_PadString = strString
End Function
VBEND
Massimo Tivan
RPA Developer

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts