Make UEFI boot-platform build again
[haiku.git] / headers / private / shared / Holiday.h
blob85a4f9f2cf104d09a26edb7ec5cd388d451b027e
1 /*
2 * Copyright 2010, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _HOLIDAY_H_
6 #define _HOLIDAY_H_
9 #include <DateTime.h>
12 namespace BPrivate {
15 class BHoliday {
16 public:
17 virtual ~BHoliday() { };
21 class BEasterHoliday : public BHoliday {
22 public:
23 static BDate EasterSunday(int32 year);
24 static BDate AscensionDay(int32 year);
25 static BDate PentecostDay(int32 year);
29 /*!
30 Returns the date for easter sunday for the \c year.
32 /*static*/ BDate
33 BEasterHoliday::EasterSunday(int32 year)
35 // http://bloggingabout.net/blogs/jschreuder/archive/2005/06/24/7019.aspx
36 int32 gold = year % 19;
37 int32 century = year / 100;
38 int32 h = (century - (int32)(century / 4)
39 - (int32)((century * 8 + 13) / 25) + 19 * gold + 15) % 30;
40 int32 i = h - (int32)(h / 28) * (1 - (int32)(h / 28)
41 * (int32)(29 / (h + 1)) * (int32)((21 - gold) / 11));
43 int32 day = i - ((year + (int32)(year / 4) + i + 2 - century
44 + (int32)(century / 4)) % 7) + 28;
45 BDate date;
46 if (day > 31)
47 date.SetDate(year, 4, day - 31);
48 else
49 date.SetDate(year, 3, day);
50 return date;
54 /*!
55 Returns the date for ascension day for the \c year.
57 /*static*/ BDate
58 BEasterHoliday::AscensionDay(int32 year)
60 BDate date = EasterSunday(year);
61 date.AddDays(39);
62 return date;
66 /*!
67 Returns the date for pentecost day for the \c year.
69 /*static*/ BDate
70 BEasterHoliday::PentecostDay(int32 year)
72 BDate date = EasterSunday(year);
73 date.AddDays(49);
74 return date;
78 } // namespace BPrivate
81 using BPrivate::BHoliday;
82 using BPrivate::BEasterHoliday;
85 #endif // _HOLIDAY_H_