xref: /aosp_15_r20/external/icu/icu4c/source/i18n/iso8601cal.cpp (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1 // © 2022 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 #include "unicode/utypes.h"
4 
5 #if !UCONFIG_NO_FORMATTING
6 
7 #include "iso8601cal.h"
8 #include "unicode/gregocal.h"
9 
10 U_NAMESPACE_BEGIN
11 
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ISO8601Calendar)12 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ISO8601Calendar)
13 
14 ISO8601Calendar::ISO8601Calendar(const Locale& aLocale, UErrorCode& success)
15 :   GregorianCalendar(aLocale, success)
16 {
17     UErrorCode tempStatus = U_ZERO_ERROR;
18     int32_t length = aLocale.getKeywordValue("fw", nullptr, 0, tempStatus) +
19         aLocale.getKeywordValue("rg", nullptr, 0, tempStatus);
20     // Do not set first day of week for iso8601 to Monday if we have fw or rg keywords
21     // and let the value set by the Calendar constructor to take care of it.
22     if (U_SUCCESS(tempStatus) && length == 0) {
23         setFirstDayOfWeek(UCAL_MONDAY);
24     }
25     setMinimalDaysInFirstWeek(4);
26 }
27 
~ISO8601Calendar()28 ISO8601Calendar::~ISO8601Calendar()
29 {
30 }
31 
clone() const32 ISO8601Calendar* ISO8601Calendar::clone() const
33 {
34     return new ISO8601Calendar(*this);
35 }
36 
getType() const37 const char *ISO8601Calendar::getType() const
38 {
39     return "iso8601";
40 }
41 
42 U_NAMESPACE_END
43 
44 #endif
45