| 43 | } |
| 44 | |
| 45 | bool isChineseNewYearMode(const String & local_tz) |
| 46 | { |
| 47 | /// Days of Dec. 20 in Chinese calendar starting from year 2019 to year 2105 |
| 48 | static constexpr UInt16 chineseNewYearIndicators[] |
| 49 | = {18275, 18659, 19014, 19368, 19752, 20107, 20491, 20845, 21199, 21583, 21937, 22292, 22676, 23030, 23414, 23768, 24122, 24506, |
| 50 | 24860, 25215, 25599, 25954, 26308, 26692, 27046, 27430, 27784, 28138, 28522, 28877, 29232, 29616, 29970, 30354, 30708, 31062, |
| 51 | 31446, 31800, 32155, 32539, 32894, 33248, 33632, 33986, 34369, 34724, 35078, 35462, 35817, 36171, 36555, 36909, 37293, 37647, |
| 52 | 38002, 38386, 38740, 39095, 39479, 39833, 40187, 40571, 40925, 41309, 41664, 42018, 42402, 42757, 43111, 43495, 43849, 44233, |
| 53 | 44587, 44942, 45326, 45680, 46035, 46418, 46772, 47126, 47510, 47865, 48249, 48604, 48958, 49342}; |
| 54 | |
| 55 | /// All time zone names are acquired from https://www.iana.org/time-zones |
| 56 | static constexpr const char * chineseNewYearTimeZoneIndicators[] = { |
| 57 | /// Time zones celebrating Chinese new year. |
| 58 | "Asia/Shanghai", |
| 59 | "Asia/Chongqing", |
| 60 | "Asia/Harbin", |
| 61 | "Asia/Urumqi", |
| 62 | "Asia/Hong_Kong", |
| 63 | "Asia/Chungking", |
| 64 | "Asia/Macao", |
| 65 | "Asia/Macau", |
| 66 | "Asia/Taipei", |
| 67 | "Asia/Singapore", |
| 68 | |
| 69 | /// Time zones celebrating Chinese new year but with different festival names. Let's not print the message for now. |
| 70 | // "Asia/Brunei", |
| 71 | // "Asia/Ho_Chi_Minh", |
| 72 | // "Asia/Hovd", |
| 73 | // "Asia/Jakarta", |
| 74 | // "Asia/Jayapura", |
| 75 | // "Asia/Kashgar", |
| 76 | // "Asia/Kuala_Lumpur", |
| 77 | // "Asia/Kuching", |
| 78 | // "Asia/Makassar", |
| 79 | // "Asia/Pontianak", |
| 80 | // "Asia/Pyongyang", |
| 81 | // "Asia/Saigon", |
| 82 | // "Asia/Seoul", |
| 83 | // "Asia/Ujung_Pandang", |
| 84 | // "Asia/Ulaanbaatar", |
| 85 | // "Asia/Ulan_Bator", |
| 86 | }; |
| 87 | static constexpr size_t M = sizeof(chineseNewYearTimeZoneIndicators) / sizeof(chineseNewYearTimeZoneIndicators[0]); |
| 88 | |
| 89 | time_t current_time = time(nullptr); |
| 90 | |
| 91 | if (chineseNewYearTimeZoneIndicators + M |
| 92 | == std::find_if(chineseNewYearTimeZoneIndicators, chineseNewYearTimeZoneIndicators + M, [&local_tz](const char * tz) |
| 93 | { |
| 94 | return tz == local_tz; |
| 95 | })) |
| 96 | return false; |
| 97 | |
| 98 | /// It's bad to be intrusive. |
| 99 | if (current_time % 3 != 0) |
| 100 | return false; |
| 101 | |
| 102 | auto days = DateLUT::instance().toDayNum(current_time).toUnderType(); |
no test coverage detected