// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ****************************************************************************** * Copyright (C) 2007-2014, International Business Machines Corporation * and others. All Rights Reserved. ****************************************************************************** * * File CHNSECAL.CPP * * Modification History: * * Date Name Description * 9/18/2007 ajmacher ported from java ChineseCalendar ***************************************************************************** */ #include "chnsecal.h" #include <cstdint> #if !UCONFIG_NO_FORMATTING #include "umutex.h" #include <float.h> #include "gregoimp.h" // Math #include "astro.h" // CalendarAstronomer #include "unicode/simpletz.h" #include "uhash.h" #include "ucln_in.h" #include "cstring.h" // Debugging #ifdef U_DEBUG_CHNSECAL # include <stdio.h> # include <stdarg.h> static void debug_chnsecal_loc(const char *f, int32_t l) { fprintf(stderr, "%s:%d: ", f, l); } static void debug_chnsecal_msg(const char *pat, ...) { va_list ap; va_start(ap, pat); vfprintf(stderr, pat, ap); fflush(stderr); } // must use double parens, i.e.: U_DEBUG_CHNSECAL_MSG(("four is: %d",4)); #define U_DEBUG_CHNSECAL_MSG … #else #define U_DEBUG_CHNSECAL_MSG(x) … #endif // --- The cache -- static icu::UMutex astroLock; static icu::CalendarAstronomer *gChineseCalendarAstro = …; // Lazy Creation & Access synchronized by class CalendarCache with a mutex. static icu::CalendarCache *gChineseCalendarWinterSolsticeCache = …; static icu::CalendarCache *gChineseCalendarNewYearCache = …; static icu::TimeZone *gChineseCalendarZoneAstroCalc = …; static icu::UInitOnce gChineseCalendarZoneAstroCalcInitOnce { … }; /** * The start year of the Chinese calendar, the 61st year of the reign * of Huang Di. Some sources use the first year of his reign, * resulting in EXTENDED_YEAR values 60 years greater and ERA (cycle) * values one greater. */ static const int32_t CHINESE_EPOCH_YEAR = …; // Gregorian year /** * The offset from GMT in milliseconds at which we perform astronomical * computations. Some sources use a different historically accurate * offset of GMT+7:45:40 for years before 1929; we do not do this. */ static const int32_t CHINA_OFFSET = …; /** * Value to be added or subtracted from the local days of a new moon to * get close to the next or prior new moon, but not cross it. Must be * >= 1 and < CalendarAstronomer.SYNODIC_MONTH. */ static const int32_t SYNODIC_GAP = …; U_CDECL_BEGIN static UBool calendar_chinese_cleanup() { … } U_CDECL_END U_NAMESPACE_BEGIN #endif