coptccal.cpp (2627B)
1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ******************************************************************************* 5 * Copyright (C) 2003 - 2013, International Business Machines Corporation and 6 * others. All Rights Reserved. 7 ******************************************************************************* 8 */ 9 10 #include "unicode/utypes.h" 11 12 #if !UCONFIG_NO_FORMATTING 13 14 #include "gregoimp.h" 15 #include "umutex.h" 16 #include "coptccal.h" 17 #include "cecal.h" 18 #include <float.h> 19 20 U_NAMESPACE_BEGIN 21 22 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CopticCalendar) 23 24 static const int32_t COPTIC_JD_EPOCH_OFFSET = 1824665; 25 26 //------------------------------------------------------------------------- 27 // Constructors... 28 //------------------------------------------------------------------------- 29 30 CopticCalendar::CopticCalendar(const Locale& aLocale, UErrorCode& success) 31 : CECalendar(aLocale, success) 32 { 33 } 34 35 CopticCalendar::CopticCalendar (const CopticCalendar& other) 36 : CECalendar(other) 37 { 38 } 39 40 CopticCalendar::~CopticCalendar() 41 { 42 } 43 44 CopticCalendar* 45 CopticCalendar::clone() const 46 { 47 return new CopticCalendar(*this); 48 } 49 50 const char* 51 CopticCalendar::getType() const 52 { 53 return "coptic"; 54 } 55 56 //------------------------------------------------------------------------- 57 // Calendar framework 58 //------------------------------------------------------------------------- 59 60 int32_t 61 CopticCalendar::handleGetExtendedYear(UErrorCode& status) 62 { 63 if (U_FAILURE(status)) { 64 return 0; 65 } 66 if (newerField(UCAL_EXTENDED_YEAR, UCAL_YEAR) == UCAL_EXTENDED_YEAR) { 67 return internalGet(UCAL_EXTENDED_YEAR, 1); // Default to year 1 68 } 69 // The year defaults to the epoch start 70 return internalGet(UCAL_YEAR, 1); // Default to year 1 71 } 72 73 IMPL_SYSTEM_DEFAULT_CENTURY(CopticCalendar, "@calendar=coptic") 74 75 int32_t 76 CopticCalendar::getJDEpochOffset() const 77 { 78 return COPTIC_JD_EPOCH_OFFSET; 79 } 80 81 int32_t CopticCalendar::extendedYearToEra(int32_t extendedYear) const { 82 return CE; 83 } 84 85 int32_t CopticCalendar::extendedYearToYear(int32_t extendedYear) const { 86 return extendedYear; 87 } 88 89 int32_t 90 CopticCalendar::handleGetLimit(UCalendarDateFields field, ELimitType limitType) const 91 { 92 if (field == UCAL_ERA) { 93 return 1; // Only one era, era is always 1 94 } 95 return CECalendar::handleGetLimit(field, limitType); 96 } 97 98 int32_t 99 CopticCalendar::getRelatedYearDifference() const { 100 constexpr int32_t kCopticCalendarRelatedYearDifference = 284; 101 return kCopticCalendarRelatedYearDifference; 102 } 103 104 105 U_NAMESPACE_END 106 107 #endif /* #if !UCONFIG_NO_FORMATTING */ 108 //eof