File indexing completed on 2024-04-21 08:29:50

0001 /*
0002     SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "easter_p.h"
0008 
0009 #include <QDate>
0010 
0011 using namespace KOpeningHours;
0012 
0013 QDate Easter::easterDate(int year)
0014 {
0015     // algorithm from KHolidays
0016     const int g = year % 19;
0017     const int c = year / 100;
0018     const int h = (c - (c / 4) - (((8 * c) + 13) / 25) + (19 * g) + 15) % 30;
0019     const int i = h - ((h / 28) * (1 - ((29 / (h + 1)) * ((21 - g) / 11))));
0020     const int j = (year + (year / 4) + i + 2 - c + (c / 4)) % 7;
0021     const int l = i - j;
0022     const int month = 3 + ((l + 40) / 44);
0023     const int day = l + 28 - (31 * (month / 4));
0024 
0025     return QDate(year, month, day);
0026 }