diff --git a/uppsrc/Core/TimeDate.cpp b/uppsrc/Core/TimeDate.cpp index 08ff6faef..a2f298d20 100644 --- a/uppsrc/Core/TimeDate.cpp +++ b/uppsrc/Core/TimeDate.cpp @@ -369,6 +369,19 @@ Date AddYears(Date date, int years) { return date; } +Date EasterDay(int year) +{ + int a = year % 19; + int b = year >> 2; + int c = b / 25 + 1; + int d = (c * 3) >> 2; + int e = ((a * 19) - ((c * 8 + 5) / 25) + d + 15) % 30; + e += (29578 - a - e * 32) >> 10; + e -= ((year % 7) + b - d + e + 2) % 7; + d = e >> 5; + return Date(year, d + 3, e - d * 31); +} + void Time::Serialize(Stream& s) { s % day % month % year % hour % minute % second; diff --git a/uppsrc/Core/TimeDate.h b/uppsrc/Core/TimeDate.h index 95670d3c7..573bd15c8 100644 --- a/uppsrc/Core/TimeDate.h +++ b/uppsrc/Core/TimeDate.h @@ -56,11 +56,12 @@ Date LastDayOfYear(Date d); Date FirstDayOfYear(Date d); int DayOfYear(Date d); - Date AddMonths(Date date, int months); int GetMonths(Date since, Date till); Date AddYears(Date date, int years); +Date EasterDay(int year); + Date GetSysDate(); String DayName(int i, int lang = 0); diff --git a/uppsrc/Core/src.tpp/DateTime$en-us.tpp b/uppsrc/Core/src.tpp/DateTime$en-us.tpp index 69b0afd74..e46042836 100644 --- a/uppsrc/Core/src.tpp/DateTime$en-us.tpp +++ b/uppsrc/Core/src.tpp/DateTime$en-us.tpp @@ -230,6 +230,10 @@ that this is not as simple as adding year attribute of Date because of leap years.&] [s3;%% &] [s4; &] +[s5;:EasterDay`(int`): [_^Date^ Date]_[* EasterDay]([@(0.0.255) int]_[*@3 year])&] +[s2;%% Returns the Easter day for given [%-*@3 year].&] +[s3;%% &] +[s4; &] [s5;:GetLeapSeconds`(Date`): [@(0.0.255) int]_[* GetLeapSeconds]([_^Date^ Date]_[*@3 dt])&] [s2;%% Returns the number of leap seconds that has occured since the start of adding leap seconds till [%-*@3 dt].&]