mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core: EasterDay function
git-svn-id: svn://ultimatepp.org/upp/trunk@6502 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
b155dc565d
commit
19146ca454
3 changed files with 19 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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].&]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue