Coverage Report

Created: 2025-06-13 06:34

/src/icu/icu4c/source/i18n/coptccal.cpp
Line
Count
Source (jump to first uncovered line)
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
0
: CECalendar(aLocale, success)
32
0
{
33
0
}
34
35
CopticCalendar::CopticCalendar (const CopticCalendar& other) 
36
0
: CECalendar(other)
37
0
{
38
0
}
39
40
CopticCalendar::~CopticCalendar()
41
0
{
42
0
}
43
44
CopticCalendar*
45
CopticCalendar::clone() const
46
0
{
47
0
    return new CopticCalendar(*this);
48
0
}
49
50
const char*
51
CopticCalendar::getType() const
52
0
{
53
0
    return "coptic";
54
0
}
55
56
//-------------------------------------------------------------------------
57
// Calendar framework
58
//-------------------------------------------------------------------------
59
60
int32_t
61
CopticCalendar::handleGetExtendedYear(UErrorCode& status)
62
0
{
63
0
    if (U_FAILURE(status)) {
64
0
        return 0;
65
0
    }
66
0
    if (newerField(UCAL_EXTENDED_YEAR, UCAL_YEAR) == UCAL_EXTENDED_YEAR) {
67
0
        return internalGet(UCAL_EXTENDED_YEAR, 1); // Default to year 1
68
0
    }
69
    // The year defaults to the epoch start, the era to CE
70
0
    int32_t era = internalGet(UCAL_ERA, CE);
71
0
    if (era == BCE) {
72
0
        return 1 - internalGet(UCAL_YEAR, 1); // Convert to extended year
73
0
    }
74
0
    if (era == CE){
75
0
        return internalGet(UCAL_YEAR, 1); // Default to year 1
76
0
    }
77
0
    status = U_ILLEGAL_ARGUMENT_ERROR;
78
0
    return 0;
79
0
}
80
81
IMPL_SYSTEM_DEFAULT_CENTURY(CopticCalendar, "@calendar=coptic")
82
83
int32_t
84
CopticCalendar::getJDEpochOffset() const
85
0
{
86
0
    return COPTIC_JD_EPOCH_OFFSET;
87
0
}
88
89
0
int32_t CopticCalendar::extendedYearToEra(int32_t extendedYear) const {
90
0
    return extendedYear <= 0 ? BCE : CE;
91
0
}
92
93
0
int32_t CopticCalendar::extendedYearToYear(int32_t extendedYear) const {
94
0
    return extendedYear <= 0 ? 1 - extendedYear : extendedYear;
95
0
}
96
97
0
bool CopticCalendar::isEra0CountingBackward() const {
98
0
    return true;
99
0
}
100
101
int32_t
102
0
CopticCalendar::getRelatedYearDifference() const {
103
0
    constexpr int32_t kCopticCalendarRelatedYearDifference = 284;
104
0
    return kCopticCalendarRelatedYearDifference;
105
0
}
106
107
108
U_NAMESPACE_END
109
110
#endif /* #if !UCONFIG_NO_FORMATTING */
111
//eof