| 79 | } |
| 80 | |
| 81 | static bool time_iseasterday(time_t time_data, tm time_info) |
| 82 | { |
| 83 | // compute Easter day (Sunday) using https://en.wikipedia.org/w/index.php?title=Computus&oldid=890710285#Anonymous_Gregorian_algorithm |
| 84 | int Y = time_info.tm_year + 1900; |
| 85 | int a = Y % 19; |
| 86 | int b = Y / 100; |
| 87 | int c = Y % 100; |
| 88 | int d = b / 4; |
| 89 | int e = b % 4; |
| 90 | int f = (b + 8) / 25; |
| 91 | int g = (b - f + 1) / 3; |
| 92 | int h = (19 * a + b - d - g + 15) % 30; |
| 93 | int i = c / 4; |
| 94 | int k = c % 4; |
| 95 | int L = (32 + 2 * e + 2 * i - h - k) % 7; |
| 96 | int m = (a + 11 * h + 22 * L) / 451; |
| 97 | int month = (h + L - 7 * m + 114) / 31; |
| 98 | int day = ((h + L - 7 * m + 114) % 31) + 1; |
| 99 | |
| 100 | // (now-1d ≤ easter ≤ now+2d) <=> (easter-2d ≤ now ≤ easter+1d) <=> (Good Friday ≤ now ≤ Easter Monday) |
| 101 | for(int day_offset = -1; day_offset <= 2; day_offset++) |
| 102 | { |
| 103 | time_data = time_data + day_offset * 60 * 60 * 24; |
| 104 | const tm offset_time_info = time_localtime_threadlocal(&time_data); |
| 105 | if(offset_time_info.tm_mon == month - 1 && offset_time_info.tm_mday == day) |
| 106 | return true; |
| 107 | } |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | ETimeSeason time_season() |
| 112 | { |
no test coverage detected