ICU 77.1 77.1

calendar.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ********************************************************************************
5 * Copyright (C) 1997-2014, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ********************************************************************************
8 *
9 * File CALENDAR.H
10 *
11 * Modification History:
12 *
13 * Date Name Description
14 * 04/22/97 aliu Expanded and corrected comments and other header
15 * contents.
16 * 05/01/97 aliu Made equals(), before(), after() arguments const.
17 * 05/20/97 aliu Replaced fAreFieldsSet with fAreFieldsInSync and
18 * fAreAllFieldsSet.
19 * 07/27/98 stephen Sync up with JDK 1.2
20 * 11/15/99 weiv added YEAR_WOY and DOW_LOCAL
21 * to EDateFields
22 * 8/19/2002 srl Removed Javaisms
23 * 11/07/2003 srl Update, clean up documentation.
24 ********************************************************************************
25 */
26
27 #ifndef CALENDAR_H
28 #define CALENDAR_H
29
30 #include "unicode/utypes.h"
31
32 #if U_SHOW_CPLUSPLUS_API
33
38 #if !UCONFIG_NO_FORMATTING
39
40 #include "unicode/uobject.h"
41 #include "unicode/locid.h"
42 #include "unicode/timezone.h"
43 #include "unicode/ucal.h"
44 #include "unicode/umisc.h"
45
46 U_NAMESPACE_BEGIN
47
48 class ICUServiceFactory;
49
50 // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
51 // it is a return type for a virtual method (@internal)
55 typedef int32_t UFieldResolutionTable[12][8];
56
57 class BasicTimeZone;
58 class CharString;
190 class U_I18N_API Calendar : public UObject {
191 public:
192 #ifndef U_FORCE_HIDE_DEPRECATED_API
199 enum EDateFields {
200 #ifndef U_HIDE_DEPRECATED_API
201 /*
202 * ERA may be defined on other platforms. To avoid any potential problems undefined it here.
203 */
204 #ifdef ERA
205 #undef ERA
206 #endif
207 ERA, // Example: 0..1
208 YEAR, // Example: 1..big number
209 MONTH, // Example: 0..11
210 WEEK_OF_YEAR, // Example: 1..53
211 WEEK_OF_MONTH, // Example: 1..4
212 DATE, // Example: 1..31
213 DAY_OF_YEAR, // Example: 1..365
214 DAY_OF_WEEK, // Example: 1..7
215 DAY_OF_WEEK_IN_MONTH, // Example: 1..4, may be specified as -1
216 AM_PM, // Example: 0..1
217 HOUR, // Example: 0..11
218 HOUR_OF_DAY, // Example: 0..23
219 MINUTE, // Example: 0..59
220 SECOND, // Example: 0..59
221 MILLISECOND, // Example: 0..999
222 ZONE_OFFSET, // Example: -12*U_MILLIS_PER_HOUR..12*U_MILLIS_PER_HOUR
223 DST_OFFSET, // Example: 0 or U_MILLIS_PER_HOUR
224 YEAR_WOY, // 'Y' Example: 1..big number - Year of Week of Year
225 DOW_LOCAL, // 'e' Example: 1..7 - Day of Week / Localized
226
227 EXTENDED_YEAR,
228 JULIAN_DAY,
229 MILLISECONDS_IN_DAY,
230 IS_LEAP_MONTH,
231
232 FIELD_COUNT = UCAL_FIELD_COUNT // See ucal.h for other fields.
233 #endif /* U_HIDE_DEPRECATED_API */
234 };
235 #endif // U_FORCE_HIDE_DEPRECATED_API
236
237 #ifndef U_HIDE_DEPRECATED_API
244 enum EDaysOfWeek {
245 SUNDAY = 1,
246 MONDAY,
247 TUESDAY,
248 WEDNESDAY,
249 THURSDAY,
250 FRIDAY,
251 SATURDAY
252 };
253
258 enum EMonths {
259 JANUARY,
260 FEBRUARY,
261 MARCH,
262 APRIL,
263 MAY,
264 JUNE,
265 JULY,
266 AUGUST,
267 SEPTEMBER,
268 OCTOBER,
269 NOVEMBER,
270 DECEMBER,
271 UNDECIMBER
272 };
273
278 enum EAmpm {
279 AM,
280 PM
281 };
282 #endif /* U_HIDE_DEPRECATED_API */
283
288 virtual ~Calendar();
289
296 virtual Calendar* clone() const = 0;
297
309 static Calendar* U_EXPORT2 createInstance(UErrorCode& success);
310
323 static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, UErrorCode& success);
324
336 static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, UErrorCode& success);
337
348 static Calendar* U_EXPORT2 createInstance(const Locale& aLocale, UErrorCode& success);
349
363 static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, const Locale& aLocale, UErrorCode& success);
364
377 static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
378
388 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
389
390
407 static StringEnumeration* U_EXPORT2 getKeywordValuesForLocale(const char* key,
408 const Locale& locale, UBool commonlyUsed, UErrorCode& status);
409
417 static UDate U_EXPORT2 getNow();
418
432 inline UDate getTime(UErrorCode& status) const { return getTimeInMillis(status); }
433
444 inline void setTime(UDate date, UErrorCode& status) { setTimeInMillis(date, status); }
445
457 virtual bool operator==(const Calendar& that) const;
458
467 bool operator!=(const Calendar& that) const {return !operator==(that);}
468
479 virtual UBool isEquivalentTo(const Calendar& other) const;
480
495 UBool equals(const Calendar& when, UErrorCode& status) const;
496
510 UBool before(const Calendar& when, UErrorCode& status) const;
511
525 UBool after(const Calendar& when, UErrorCode& status) const;
526
527 #ifndef U_FORCE_HIDE_DEPRECATED_API
548 virtual void add(EDateFields field, int32_t amount, UErrorCode& status);
549 #endif // U_FORCE_HIDE_DEPRECATED_API
550
571 virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status);
572
573 #ifndef U_HIDE_DEPRECATED_API
606 inline void roll(EDateFields field, UBool up, UErrorCode& status);
607 #endif /* U_HIDE_DEPRECATED_API */
608
641 inline void roll(UCalendarDateFields field, UBool up, UErrorCode& status);
642
643 #ifndef U_FORCE_HIDE_DEPRECATED_API
675 virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
676 #endif // U_FORCE_HIDE_DEPRECATED_API
677
709 virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
710
711 #ifndef U_FORCE_HIDE_DEPRECATED_API
767 virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode& status);
768 #endif // U_FORCE_HIDE_DEPRECATED_API
769
825 virtual int32_t fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status);
826
835 void adoptTimeZone(TimeZone* value);
836
844 void setTimeZone(const TimeZone& zone);
845
854 const TimeZone& getTimeZone() const;
855
864 TimeZone* orphanTimeZone();
865
874 virtual UBool inDaylightTime(UErrorCode& status) const;
875
888 void setLenient(UBool lenient);
889
896 UBool isLenient() const;
897
918 void setRepeatedWallTimeOption(UCalendarWallTimeOption option);
919
929 UCalendarWallTimeOption getRepeatedWallTimeOption() const;
930
952 void setSkippedWallTimeOption(UCalendarWallTimeOption option);
953
964 UCalendarWallTimeOption getSkippedWallTimeOption() const;
965
972 void setFirstDayOfWeek(UCalendarDaysOfWeek value);
973
974 #ifndef U_HIDE_DEPRECATED_API
981 EDaysOfWeek getFirstDayOfWeek() const;
982 #endif /* U_HIDE_DEPRECATED_API */
983
991 UCalendarDaysOfWeek getFirstDayOfWeek(UErrorCode &status) const;
992
1002 void setMinimalDaysInFirstWeek(uint8_t value);
1003
1013 uint8_t getMinimalDaysInFirstWeek() const;
1014
1015 #ifndef U_FORCE_HIDE_DEPRECATED_API
1024 virtual int32_t getMinimum(EDateFields field) const;
1025 #endif // U_FORCE_HIDE_DEPRECATED_API
1026
1035 virtual int32_t getMinimum(UCalendarDateFields field) const;
1036
1037 #ifndef U_FORCE_HIDE_DEPRECATED_API
1046 virtual int32_t getMaximum(EDateFields field) const;
1047 #endif // U_FORCE_HIDE_DEPRECATED_API
1048
1057 virtual int32_t getMaximum(UCalendarDateFields field) const;
1058
1059 #ifndef U_FORCE_HIDE_DEPRECATED_API
1068 virtual int32_t getGreatestMinimum(EDateFields field) const;
1069 #endif // U_FORCE_HIDE_DEPRECATED_API
1070
1079 virtual int32_t getGreatestMinimum(UCalendarDateFields field) const;
1080
1081 #ifndef U_FORCE_HIDE_DEPRECATED_API
1090 virtual int32_t getLeastMaximum(EDateFields field) const;
1091 #endif // U_FORCE_HIDE_DEPRECATED_API
1092
1101 virtual int32_t getLeastMaximum(UCalendarDateFields field) const;
1102
1103 #ifndef U_HIDE_DEPRECATED_API
1118 int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;
1119 #endif /* U_HIDE_DEPRECATED_API */
1120
1135 virtual int32_t getActualMinimum(UCalendarDateFields field, UErrorCode& status) const;
1136
1153 virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
1154
1168 int32_t get(UCalendarDateFields field, UErrorCode& status) const;
1169
1178 UBool isSet(UCalendarDateFields field) const;
1179
1187 void set(UCalendarDateFields field, int32_t value);
1188
1199 void set(int32_t year, int32_t month, int32_t date);
1200
1213 void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute);
1214
1228 void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second);
1229
1236 void clear();
1237
1247 void clear(UCalendarDateFields field);
1248
1264 virtual UClassID getDynamicClassID() const override = 0;
1265
1298 virtual const char * getType() const = 0;
1299
1316 virtual UCalendarWeekdayType getDayOfWeekType(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
1317
1332 virtual int32_t getWeekendTransition(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
1333
1343 virtual UBool isWeekend(UDate date, UErrorCode &status) const;
1344
1352 virtual UBool isWeekend() const;
1353
1368 virtual bool inTemporalLeapYear(UErrorCode& status) const;
1369
1388 virtual const char* getTemporalMonthCode(UErrorCode& status) const;
1389
1409 virtual void setTemporalMonthCode(const char* temporalMonth, UErrorCode& status);
1410
1411 protected:
1412
1421 Calendar(UErrorCode& success);
1422
1429 Calendar(const Calendar& source);
1430
1437 Calendar& operator=(const Calendar& right);
1438
1449 Calendar(TimeZone* zone, const Locale& aLocale, UErrorCode& success);
1450
1460 Calendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
1461
1470 virtual void computeTime(UErrorCode& status);
1471
1483 virtual void computeFields(UErrorCode& status);
1484
1494 double getTimeInMillis(UErrorCode& status) const;
1495
1504 void setTimeInMillis( double millis, UErrorCode& status );
1505
1515 void complete(UErrorCode& status);
1516
1517 #ifndef U_HIDE_DEPRECATED_API
1526 inline int32_t internalGet(EDateFields field) const {return fFields[field];}
1527 #endif /* U_HIDE_DEPRECATED_API */
1528
1529 #ifndef U_HIDE_INTERNAL_API
1540 inline int32_t internalGet(UCalendarDateFields field, int32_t defaultValue) const {return fStamp[field]>kUnset ? fFields[field] : defaultValue;}
1541
1550 inline int32_t internalGet(UCalendarDateFields field) const {return fFields[field];}
1551
1557 virtual bool isEra0CountingBackward() const { return false; }
1558 #endif /* U_HIDE_INTERNAL_API */
1559
1569 virtual int32_t internalGetMonth(UErrorCode& status) const;
1570
1584 virtual int32_t internalGetMonth(int32_t defaultValue, UErrorCode& status) const;
1585
1586 #ifndef U_HIDE_DEPRECATED_API
1596 void internalSet(EDateFields field, int32_t value);
1597 #endif /* U_HIDE_DEPRECATED_API */
1598
1608 inline void internalSet(UCalendarDateFields field, int32_t value);
1609
1616 virtual void prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status);
1617
1622 enum ELimitType {
1623 #ifndef U_HIDE_INTERNAL_API
1624 UCAL_LIMIT_MINIMUM = 0,
1625 UCAL_LIMIT_GREATEST_MINIMUM,
1626 UCAL_LIMIT_LEAST_MAXIMUM,
1627 UCAL_LIMIT_MAXIMUM,
1628 UCAL_LIMIT_COUNT
1629 #endif /* U_HIDE_INTERNAL_API */
1630 };
1631
1653 virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const = 0;
1654
1662 virtual int32_t getLimit(UCalendarDateFields field, ELimitType limitType) const;
1663
1679 virtual int64_t handleComputeMonthStart(int32_t eyear, int32_t month,
1680 UBool useMonth, UErrorCode& status) const = 0;
1681
1689 virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month, UErrorCode& status) const ;
1690
1698 virtual int32_t handleGetYearLength(int32_t eyear, UErrorCode& status) const;
1699
1709 virtual int32_t handleGetExtendedYear(UErrorCode& status) = 0;
1710
1720 virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField, UErrorCode &status);
1721
1730 virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy, UErrorCode& status);
1731
1738 virtual void validateField(UCalendarDateFields field, UErrorCode &status);
1739
1740 #ifndef U_HIDE_INTERNAL_API
1748 int32_t computeJulianDay(UErrorCode &status);
1749
1757 double computeMillisInDay();
1758
1768 int32_t computeZoneOffset(double millis, double millisInDay, UErrorCode &ec);
1769
1770
1779 int32_t newestStamp(UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const;
1780
1787 static constexpr int32_t kResolveSTOP = -1;
1797 static constexpr int32_t kResolveRemap = 32;
1798
1804 static const UFieldResolutionTable kDatePrecedence[];
1805
1811 static const UFieldResolutionTable kYearPrecedence[];
1812
1818 static const UFieldResolutionTable kDOWPrecedence[];
1819
1825 static const UFieldResolutionTable kMonthPrecedence[];
1826
1854 UCalendarDateFields resolveFields(const UFieldResolutionTable *precedenceTable) const;
1855 #endif /* U_HIDE_INTERNAL_API */
1856
1857
1861 virtual const UFieldResolutionTable* getFieldResolutionTable() const;
1862
1863 #ifndef U_HIDE_INTERNAL_API
1869 UCalendarDateFields newerField(UCalendarDateFields defaultField, UCalendarDateFields alternateField) const;
1870 #endif /* U_HIDE_INTERNAL_API */
1871
1872
1873 private:
1882 int32_t getActualHelper(UCalendarDateFields field, int32_t startValue, int32_t endValue, UErrorCode &status) const;
1883
1884 protected:
1891 UDate internalGetTime() const { return fTime; }
1892
1900 void internalSetTime(UDate time) { fTime = time; }
1901
1906 int32_t fFields[UCAL_FIELD_COUNT];
1907
1908 protected:
1912 enum {
1913 kUnset = 0,
1914 kInternallySet,
1915 kMinimumUserStamp
1916 };
1917
1918 private:
1924 int8_t fStamp[UCAL_FIELD_COUNT];
1925
1926 protected:
1951 virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
1952
1953 #ifndef U_HIDE_INTERNAL_API
1959 int32_t getGregorianYear() const {
1960 return fGregorianYear;
1961 }
1962
1968 int32_t getGregorianMonth() const {
1969 return fGregorianMonth;
1970 }
1971
1977 int32_t getGregorianDayOfYear() const {
1978 return fGregorianDayOfYear;
1979 }
1980
1986 int32_t getGregorianDayOfMonth() const {
1987 return fGregorianDayOfMonth;
1988 }
1989 #endif /* U_HIDE_INTERNAL_API */
1990
1999 virtual int32_t getDefaultMonthInYear(int32_t eyear, UErrorCode& status);
2000
2001
2011 virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month, UErrorCode& status);
2012
2013 //-------------------------------------------------------------------------
2014 // Protected utility methods for use by subclasses. These are very handy
2015 // for implementing add, roll, and computeFields.
2016 //-------------------------------------------------------------------------
2017
2047 virtual void pinField(UCalendarDateFields field, UErrorCode& status);
2048
2092 int32_t weekNumber(int32_t desiredDay, int32_t dayOfPeriod, int32_t dayOfWeek);
2093
2094
2095 #ifndef U_HIDE_INTERNAL_API
2126 inline int32_t weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek);
2127
2132 int32_t getLocalDOW(UErrorCode& status);
2133 #endif /* U_HIDE_INTERNAL_API */
2134
2135 private:
2136
2140 int8_t fNextStamp = kMinimumUserStamp;
2141
2146 void recalculateStamp();
2147
2151 UDate fTime = 0;
2152
2157 TimeZone* fZone = nullptr;
2158
2162 bool fIsTimeSet:1;
2163
2173 bool fAreFieldsSet:1;
2174
2179 bool fAreAllFieldsSet:1;
2180
2187 bool fAreFieldsVirtuallySet:1;
2188
2192 bool fLenient:1;
2193
2198 UCalendarWallTimeOption fRepeatedWallTime:3; // Somehow MSVC need 3 bits for UCalendarWallTimeOption
2199
2204 UCalendarWallTimeOption fSkippedWallTime:3; // Somehow MSVC need 3 bits for UCalendarWallTimeOption
2205
2214 UCalendarDaysOfWeek fFirstDayOfWeek:4; // Somehow MSVC need 4 bits for
2215 // UCalendarDaysOfWeek
2216 UCalendarDaysOfWeek fWeekendOnset:4; // Somehow MSVC need 4 bits for
2217 // UCalendarDaysOfWeek
2218 UCalendarDaysOfWeek fWeekendCease:4; // Somehow MSVC need 4 bits for
2219 // UCalendarDaysOfWeek
2220 uint8_t fMinimalDaysInFirstWeek;
2221 int32_t fWeekendOnsetMillis;
2222 int32_t fWeekendCeaseMillis;
2223
2234 void setWeekData(const Locale& desiredLocale, const char *type, UErrorCode& success);
2235
2245 void updateTime(UErrorCode& status);
2246
2252 int32_t fGregorianYear;
2253
2259 int8_t fGregorianMonth;
2260
2266 int8_t fGregorianDayOfMonth;
2267
2273 int16_t fGregorianDayOfYear;
2274
2275 /* calculations */
2276
2277 protected:
2278
2286 void computeGregorianFields(int32_t julianDay, UErrorCode &ec);
2287
2288 private:
2289
2310 void computeWeekFields(UErrorCode &ec);
2311
2312
2320 void validateFields(UErrorCode &status);
2321
2329 void validateField(UCalendarDateFields field, int32_t min, int32_t max, UErrorCode& status);
2330
2331 protected:
2332 #ifndef U_HIDE_INTERNAL_API
2342 static uint8_t julianDayToDayOfWeek(int32_t julian);
2343 #endif /* U_HIDE_INTERNAL_API */
2344
2345 private:
2346 CharString* validLocale = nullptr;
2347 CharString* actualLocale = nullptr;
2348
2349 public:
2350 #if !UCONFIG_NO_SERVICE
2355 #ifndef U_HIDE_INTERNAL_API
2362 static StringEnumeration* getAvailableLocales();
2363
2377 static URegistryKey registerFactory(ICUServiceFactory* toAdopt, UErrorCode& status);
2378
2394 static UBool unregister(URegistryKey key, UErrorCode& status);
2395 #endif /* U_HIDE_INTERNAL_API */
2396
2401 friend class CalendarFactory;
2402
2407 friend class CalendarService;
2408
2413 friend class DefaultCalendarFactory;
2414 #endif /* !UCONFIG_NO_SERVICE */
2415
2420 virtual UBool haveDefaultCentury() const = 0;
2421
2426 virtual UDate defaultCenturyStart() const = 0;
2431 virtual int32_t defaultCenturyStartYear() const = 0;
2432
2439 Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const;
2440
2446 virtual int32_t getRelatedYear(UErrorCode &status) const;
2447
2453 virtual void setRelatedYear(int32_t year);
2454
2455 #ifndef U_HIDE_INTERNAL_API
2462 const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;
2463 #endif /* U_HIDE_INTERNAL_API */
2464
2465 private:
2470 BasicTimeZone* getBasicTimeZone() const;
2471
2479 UBool getImmediatePreviousZoneTransition(UDate base, UDate *transitionTime, UErrorCode& status) const;
2480
2481 public:
2482 #ifndef U_HIDE_INTERNAL_API
2491 static Calendar * U_EXPORT2 makeInstance(
2492 const Locale &locale, UErrorCode &status);
2493
2504 static void U_EXPORT2 getCalendarTypeFromLocale(
2505 const Locale &locale,
2506 char *typeBuffer,
2507 int32_t typeBufferSize,
2508 UErrorCode &status);
2509 #endif /* U_HIDE_INTERNAL_API */
2510 };
2511
2512 // -------------------------------------
2513
2514 inline Calendar*
2515 Calendar::createInstance(TimeZone* zone, UErrorCode& errorCode)
2516 {
2517 // since the Locale isn't specified, use the default locale
2518 return createInstance(zone, Locale::getDefault(), errorCode);
2519 }
2520
2521 // -------------------------------------
2522
2523 inline void
2524 Calendar::roll(UCalendarDateFields field, UBool up, UErrorCode& status)
2525 {
2526 roll(field, static_cast<int32_t>(up ? +1 : -1), status);
2527 }
2528
2529 #ifndef U_HIDE_DEPRECATED_API
2530 inline void
2531 Calendar::roll(EDateFields field, UBool up, UErrorCode& status)
2532 {
2533 roll(static_cast<UCalendarDateFields>(field), up, status);
2534 }
2535 #endif /* U_HIDE_DEPRECATED_API */
2536
2537
2538 // -------------------------------------
2539
2545 inline void
2546 Calendar::internalSet(UCalendarDateFields field, int32_t value)
2547 {
2548 fFields[field] = value;
2549 fStamp[field] = kInternallySet;
2550 }
2551
2558 #define DECLARE_OVERRIDE_SYSTEM_DEFAULT_CENTURY \
2559 virtual UBool haveDefaultCentury() const override; \
2560 virtual UDate defaultCenturyStart() const override; \
2561 virtual int32_t defaultCenturyStartYear() const override;
2562
2563 #ifndef U_HIDE_INTERNAL_API
2564 inline int32_t Calendar::weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek)
2565 {
2566 return weekNumber(dayOfPeriod, dayOfPeriod, dayOfWeek);
2567 }
2568 #endif /* U_HIDE_INTERNAL_API */
2569
2570 U_NAMESPACE_END
2571
2572 #endif /* #if !UCONFIG_NO_FORMATTING */
2573
2574 #endif /* U_SHOW_CPLUSPLUS_API */
2575
2576 #endif // _CALENDAR
icu::BasicTimeZone
BasicTimeZone is an abstract class extending TimeZone.
Definition: basictz.h:38
icu::Calendar
Calendar is an abstract base class for converting between a UDate object and a set of integer fields ...
Definition: calendar.h:190
icu::Calendar::after
UBool after(const Calendar &when, UErrorCode &status) const
Returns true if this Calendar's current time is after "when"'s current time.
icu::Calendar::getTemporalMonthCode
virtual const char * getTemporalMonthCode(UErrorCode &status) const
Gets The Temporal monthCode value corresponding to the month for the date.
icu::Calendar::getGreatestMinimum
virtual int32_t getGreatestMinimum(EDateFields field) const
Gets the highest minimum value for the given field if varies.
icu::Calendar::setTime
void setTime(UDate date, UErrorCode &status)
Sets this Calendar's current time with the given UDate.
Definition: calendar.h:444
icu::Calendar::setSkippedWallTimeOption
void setSkippedWallTimeOption(UCalendarWallTimeOption option)
Sets the behavior for handling skipped wall time at positive time zone offset transitions.
icu::Calendar::internalGet
int32_t internalGet(UCalendarDateFields field) const
Gets the value for a given time field.
Definition: calendar.h:1550
icu::Calendar::newestStamp
int32_t newestStamp(UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const
Determine the best stamp in a range.
icu::Calendar::set
void set(UCalendarDateFields field, int32_t value)
Sets the given time field with the given value.
icu::Calendar::getLocale
Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Get the locale for this calendar object.
icu::Calendar::get
int32_t get(UCalendarDateFields field, UErrorCode &status) const
Gets the value for a given time field.
icu::Calendar::operator=
Calendar & operator=(const Calendar &right)
Default assignment operator.
icu::Calendar::getLocalDOW
int32_t getLocalDOW(UErrorCode &status)
returns the local DOW, valid range 0..6
icu::Calendar::clone
virtual Calendar * clone() const =0
Create and return a polymorphic copy of this calendar.
icu::Calendar::getMinimum
virtual int32_t getMinimum(EDateFields field) const
Gets the minimum value for the given time field.
icu::Calendar::internalGetTime
UDate internalGetTime() const
Get the current time without recomputing.
Definition: calendar.h:1891
icu::Calendar::roll
virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode &status)
Time Field Rolling function.
icu::Calendar::getRepeatedWallTimeOption
UCalendarWallTimeOption getRepeatedWallTimeOption() const
Gets the behavior for handling wall time repeating multiple times at negative time zone offset transi...
icu::Calendar::fieldDifference
virtual int32_t fieldDifference(UDate when, UCalendarDateFields field, UErrorCode &status)
Return the difference between the given time and the time this calendar object is set to.
icu::Calendar::weekNumber
int32_t weekNumber(int32_t desiredDay, int32_t dayOfPeriod, int32_t dayOfWeek)
Return the week number of a day, within a period.
icu::Calendar::getDynamicClassID
virtual UClassID getDynamicClassID() const override=0
Returns a unique class ID POLYMORPHICALLY.
icu::Calendar::computeJulianDay
int32_t computeJulianDay(UErrorCode &status)
Compute the Julian day from fields.
icu::Calendar::getLeastMaximum
virtual int32_t getLeastMaximum(UCalendarDateFields field) const
Gets the lowest maximum value for the given field if varies.
icu::Calendar::setTimeInMillis
void setTimeInMillis(double millis, UErrorCode &status)
Sets this Calendar's current time from the given long value.
icu::Calendar::getAvailableLocales
static StringEnumeration * getAvailableLocales()
INTERNAL FOR 2.6 – Registration.
icu::Calendar::complete
void complete(UErrorCode &status)
Recomputes the current time from currently set fields, and then fills in any unset fields in the time...
icu::Calendar::getCalendarTypeFromLocale
static void getCalendarTypeFromLocale(const Locale &locale, char *typeBuffer, int32_t typeBufferSize, UErrorCode &status)
Get the calendar type for given locale.
icu::Calendar::julianDayToDayOfWeek
static uint8_t julianDayToDayOfWeek(int32_t julian)
Convert a quasi Julian date to the day of the week.
icu::Calendar::isSet
UBool isSet(UCalendarDateFields field) const
Determines if the given time field has a value set.
icu::Calendar::setLenient
void setLenient(UBool lenient)
Specifies whether or not date/time interpretation is to be lenient.
icu::Calendar::handleGetExtendedYearFromWeekFields
virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy, UErrorCode &status)
Subclasses must override this to convert from week fields (YEAR_WOY and WEEK_OF_YEAR) to an extended ...
icu::Calendar::getGregorianMonth
int32_t getGregorianMonth() const
Return the month (0-based) on the Gregorian calendar as computed by computeGregorianFields().
Definition: calendar.h:1968
icu::Calendar::clear
void clear()
Clears the values of all the time fields, making them both unset and assigning them a value of zero.
icu::Calendar::computeGregorianFields
void computeGregorianFields(int32_t julianDay, UErrorCode &ec)
Compute the Gregorian calendar year, month, and day of month from the Julian day.
icu::Calendar::getGregorianDayOfYear
int32_t getGregorianDayOfYear() const
Return the day of year (1-based) on the Gregorian calendar as computed by computeGregorianFields().
Definition: calendar.h:1977
icu::Calendar::haveDefaultCentury
virtual UBool haveDefaultCentury() const =0
icu::Calendar::EDaysOfWeek
EDaysOfWeek
Useful constant for days of week.
Definition: calendar.h:244
icu::Calendar::getLeastMaximum
virtual int32_t getLeastMaximum(EDateFields field) const
Gets the lowest maximum value for the given field if varies.
icu::Calendar::~Calendar
virtual ~Calendar()
destructor
icu::Calendar::isLenient
UBool isLenient() const
Tells whether date/time interpretation is to be lenient.
icu::Calendar::EDateFields
EDateFields
Field IDs for date and time.
Definition: calendar.h:199
icu::Calendar::handleGetYearLength
virtual int32_t handleGetYearLength(int32_t eyear, UErrorCode &status) const
Return the number of days in the given extended year of this calendar system.
icu::Calendar::getFirstDayOfWeek
EDaysOfWeek getFirstDayOfWeek() const
Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
icu::Calendar::handleComputeMonthStart
virtual int64_t handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth, UErrorCode &status) const =0
Return the Julian day number of day before the first day of the given month in the given extended yea...
icu::Calendar::operator==
virtual bool operator==(const Calendar &that) const
Compares the equality of two Calendar objects.
icu::Calendar::roll
virtual void roll(EDateFields field, int32_t amount, UErrorCode &status)
Time Field Rolling function.
icu::Calendar::getKeywordValuesForLocale
static StringEnumeration * getKeywordValuesForLocale(const char *key, const Locale &locale, UBool commonlyUsed, UErrorCode &status)
Given a key and a locale, returns an array of string values in a preferred order that would make a di...
icu::Calendar::ELimitType
ELimitType
Limit enums.
Definition: calendar.h:1622
icu::Calendar::Calendar
Calendar(UErrorCode &success)
Constructs a Calendar with the default time zone as returned by TimeZone::createInstance(),...
icu::Calendar::makeInstance
static Calendar * makeInstance(const Locale &locale, UErrorCode &status)
Creates a new Calendar from a Locale for the cache.
icu::Calendar::equals
UBool equals(const Calendar &when, UErrorCode &status) const
Compares the Calendar time, whereas Calendar::operator== compares the equality of Calendar objects.
icu::Calendar::operator!=
bool operator!=(const Calendar &that) const
Compares the inequality of two Calendar objects.
Definition: calendar.h:467
icu::Calendar::getRelatedYear
virtual int32_t getRelatedYear(UErrorCode &status) const
icu::Calendar::getType
virtual const char * getType() const =0
Returns the calendar type name string for this Calendar object.
icu::Calendar::clear
void clear(UCalendarDateFields field)
Clears the value in the given time field, both making it unset and assigning it a value of zero.
icu::Calendar::handleComputeFields
virtual void handleComputeFields(int32_t julianDay, UErrorCode &status)
Subclasses may override this method to compute several fields specific to each calendar system.
icu::Calendar::setTemporalMonthCode
virtual void setTemporalMonthCode(const char *temporalMonth, UErrorCode &status)
Sets The Temporal monthCode which is a string identifier that starts with the literal grapheme "M" fo...
icu::Calendar::getFieldResolutionTable
virtual const UFieldResolutionTable * getFieldResolutionTable() const
icu::Calendar::getTimeInMillis
double getTimeInMillis(UErrorCode &status) const
Gets this Calendar's current time as a long.
icu::Calendar::getFirstDayOfWeek
UCalendarDaysOfWeek getFirstDayOfWeek(UErrorCode &status) const
Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
icu::Calendar::internalGet
int32_t internalGet(EDateFields field) const
Gets the value for a given time field.
Definition: calendar.h:1526
icu::Calendar::registerFactory
static URegistryKey registerFactory(ICUServiceFactory *toAdopt, UErrorCode &status)
Register a new Calendar factory.
icu::Calendar::getDefaultMonthInYear
virtual int32_t getDefaultMonthInYear(int32_t eyear, UErrorCode &status)
Called by computeJulianDay.
icu::Calendar::Calendar
Calendar(const Calendar &source)
Copy constructor.
icu::Calendar::computeFields
virtual void computeFields(UErrorCode &status)
Converts GMT as milliseconds to time field values.
icu::Calendar::getNow
static UDate getNow()
Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70 (derived from the...
icu::Calendar::getActualMaximum
virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode &status) const
Return the maximum value that this field could have, given the current date.
icu::Calendar::createInstance
static Calendar * createInstance(const TimeZone &zone, UErrorCode &success)
Creates a Calendar using the given timezone and the default locale.
icu::Calendar::prepareGetActual
virtual void prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status)
Prepare this calendar for computing the actual minimum or maximum.
icu::Calendar::adoptTimeZone
void adoptTimeZone(TimeZone *value)
Sets the calendar's time zone to be the one passed in.
icu::Calendar::before
UBool before(const Calendar &when, UErrorCode &status) const
Returns true if this Calendar's current time is before "when"'s current time.
icu::Calendar::orphanTimeZone
TimeZone * orphanTimeZone()
Returns the time zone owned by this calendar.
icu::Calendar::defaultCenturyStartYear
virtual int32_t defaultCenturyStartYear() const =0
icu::Calendar::setMinimalDaysInFirstWeek
void setMinimalDaysInFirstWeek(uint8_t value)
Sets what the minimal days required in the first week of the year are; For example,...
icu::Calendar::getTimeZone
const TimeZone & getTimeZone() const
Returns a reference to the time zone owned by this calendar.
icu::Calendar::inDaylightTime
virtual UBool inDaylightTime(UErrorCode &status) const
Queries if the current date for this Calendar is in Daylight Savings Time.
icu::Calendar::defaultCenturyStart
virtual UDate defaultCenturyStart() const =0
icu::Calendar::getMaximum
virtual int32_t getMaximum(UCalendarDateFields field) const
Gets the maximum value for the given time field.
icu::Calendar::pinField
virtual void pinField(UCalendarDateFields field, UErrorCode &status)
Adjust the specified field so that it is within the allowable range for the date to which this calend...
icu::Calendar::getGregorianYear
int32_t getGregorianYear() const
Return the extended year on the Gregorian calendar as computed by computeGregorianFields().
Definition: calendar.h:1959
icu::Calendar::internalGet
int32_t internalGet(UCalendarDateFields field, int32_t defaultValue) const
Gets the value for a given time field.
Definition: calendar.h:1540
icu::Calendar::internalSetTime
void internalSetTime(UDate time)
Set the current time without affecting flags or fields.
Definition: calendar.h:1900
icu::Calendar::getActualMinimum
virtual int32_t getActualMinimum(UCalendarDateFields field, UErrorCode &status) const
Return the minimum value that this field could have, given the current date.
icu::Calendar::getTime
UDate getTime(UErrorCode &status) const
Gets this Calendar's time as milliseconds.
Definition: calendar.h:432
icu::Calendar::handleGetLimit
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const =0
Subclass API for defining limits of different types.
icu::Calendar::getWeekendTransition
virtual int32_t getWeekendTransition(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const
Returns the time during the day at which the weekend begins or ends in this calendar system.
icu::Calendar::getDefaultDayInMonth
virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month, UErrorCode &status)
Called by computeJulianDay.
icu::Calendar::getActualMinimum
int32_t getActualMinimum(EDateFields field, UErrorCode &status) const
Return the minimum value that this field could have, given the current date.
icu::Calendar::internalGetMonth
virtual int32_t internalGetMonth(UErrorCode &status) const
Use this function instead of internalGet(UCAL_MONTH).
icu::Calendar::newerField
UCalendarDateFields newerField(UCalendarDateFields defaultField, UCalendarDateFields alternateField) const
Return the field that is newer, either defaultField, or alternateField.
icu::Calendar::isEquivalentTo
virtual UBool isEquivalentTo(const Calendar &other) const
Returns true if the given Calendar object is equivalent to this one.
icu::Calendar::computeMillisInDay
double computeMillisInDay()
Compute the milliseconds in the day from the fields.
icu::Calendar::isEra0CountingBackward
virtual bool isEra0CountingBackward() const
The year in this calendar is counting from 1 backward if the era is 0.
Definition: calendar.h:1557
icu::Calendar::getGreatestMinimum
virtual int32_t getGreatestMinimum(UCalendarDateFields field) const
Gets the highest minimum value for the given field if varies.
icu::Calendar::getLocaleID
const char * getLocaleID(ULocDataLocaleType type, UErrorCode &status) const
Get the locale for this calendar object.
icu::Calendar::Calendar
Calendar(const TimeZone &zone, const Locale &aLocale, UErrorCode &success)
Constructs a Calendar with the given time zone and locale.
icu::Calendar::setTimeZone
void setTimeZone(const TimeZone &zone)
Sets the calendar's time zone to be the same as the one passed in.
icu::Calendar::EAmpm
EAmpm
Useful constants for hour in 12-hour clock.
Definition: calendar.h:278
icu::Calendar::internalSet
void internalSet(EDateFields field, int32_t value)
Sets the value for a given time field.
icu::Calendar::createInstance
static Calendar * createInstance(const Locale &aLocale, UErrorCode &success)
Creates a Calendar using the default timezone and the given locale.
icu::Calendar::createInstance
static Calendar * createInstance(const TimeZone &zone, const Locale &aLocale, UErrorCode &success)
Gets a Calendar using the given timezone and given locale.
icu::Calendar::setRelatedYear
virtual void setRelatedYear(int32_t year)
icu::Calendar::getMinimum
virtual int32_t getMinimum(UCalendarDateFields field) const
Gets the minimum value for the given time field.
icu::Calendar::resolveFields
UCalendarDateFields resolveFields(const UFieldResolutionTable *precedenceTable) const
Given a precedence table, return the newest field combination in the table, or UCAL_FIELD_COUNT if no...
icu::Calendar::handleComputeJulianDay
virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField, UErrorCode &status)
Subclasses may override this.
icu::Calendar::setRepeatedWallTimeOption
void setRepeatedWallTimeOption(UCalendarWallTimeOption option)
Sets the behavior for handling wall time repeating multiple times at negative time zone offset transi...
icu::Calendar::internalGetMonth
virtual int32_t internalGetMonth(int32_t defaultValue, UErrorCode &status) const
Use this function instead of internalGet(UCAL_MONTH, defaultValue).
icu::Calendar::setFirstDayOfWeek
void setFirstDayOfWeek(UCalendarDaysOfWeek value)
Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
icu::Calendar::getAvailableLocales
static const Locale * getAvailableLocales(int32_t &count)
Returns a list of the locales for which Calendars are installed.
icu::Calendar::createInstance
static Calendar * createInstance(UErrorCode &success)
Creates a Calendar using the default timezone and locale.
icu::Calendar::isWeekend
virtual UBool isWeekend() const
Returns true if this Calendar's current date-time is in the weekend in this calendar system.
icu::Calendar::inTemporalLeapYear
virtual bool inTemporalLeapYear(UErrorCode &status) const
Returns true if the date is in a leap year.
icu::Calendar::set
void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second)
Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, MINUTE, and SECOND.
icu::Calendar::handleGetMonthLength
virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month, UErrorCode &status) const
Return the number of days in the given month of the given extended year of this calendar system.
icu::Calendar::getDayOfWeekType
virtual UCalendarWeekdayType getDayOfWeekType(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const
Returns whether the given day of the week is a weekday, a weekend day, or a day that transitions from...
icu::Calendar::EMonths
EMonths
Useful constants for month.
Definition: calendar.h:258
icu::Calendar::computeTime
virtual void computeTime(UErrorCode &status)
Converts Calendar's time field values to GMT as milliseconds.
icu::Calendar::getLimit
virtual int32_t getLimit(UCalendarDateFields field, ELimitType limitType) const
Return a limit for a field.
icu::Calendar::isWeekend
virtual UBool isWeekend(UDate date, UErrorCode &status) const
Returns true if the given UDate is in the weekend in this calendar system.
icu::Calendar::getMaximum
virtual int32_t getMaximum(EDateFields field) const
Gets the maximum value for the given time field.
icu::Calendar::handleGetExtendedYear
virtual int32_t handleGetExtendedYear(UErrorCode &status)=0
Return the extended year defined by the current fields.
icu::Calendar::getSkippedWallTimeOption
UCalendarWallTimeOption getSkippedWallTimeOption() const
Gets the behavior for handling skipped wall time at positive time zone offset transitions.
icu::Calendar::add
virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode &status)
UDate Arithmetic function.
icu::Calendar::unregister
static UBool unregister(URegistryKey key, UErrorCode &status)
Unregister a previously-registered CalendarFactory using the key returned from the register call.
icu::Calendar::validateField
virtual void validateField(UCalendarDateFields field, UErrorCode &status)
Validate a single field of this calendar.
icu::Calendar::add
virtual void add(EDateFields field, int32_t amount, UErrorCode &status)
UDate Arithmetic function.
icu::Calendar::getGregorianDayOfMonth
int32_t getGregorianDayOfMonth() const
Return the day of month (1-based) on the Gregorian calendar as computed by computeGregorianFields().
Definition: calendar.h:1986
icu::Calendar::getMinimalDaysInFirstWeek
uint8_t getMinimalDaysInFirstWeek() const
Gets what the minimal days required in the first week of the year are; e.g., if the first week is def...
icu::Calendar::Calendar
Calendar(TimeZone *zone, const Locale &aLocale, UErrorCode &success)
Constructs a Calendar with the given time zone and locale.
icu::Calendar::computeZoneOffset
int32_t computeZoneOffset(double millis, double millisInDay, UErrorCode &ec)
This method can assume EXTENDED_YEAR has been set.
icu::Calendar::createInstance
static Calendar * createInstance(TimeZone *zoneToAdopt, const Locale &aLocale, UErrorCode &success)
Creates a Calendar using the given timezone and given locale.
icu::Calendar::set
void set(int32_t year, int32_t month, int32_t date)
Sets the values for the fields YEAR, MONTH, and DATE.
icu::Calendar::set
void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute)
Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, and MINUTE.
icu::Calendar::fieldDifference
virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode &status)
Return the difference between the given time and the time this calendar object is set to.
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
icu::StringEnumeration
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:61
icu::TimeZone
TimeZone represents a time zone offset, and also figures out daylight savings.
Definition: timezone.h:133
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
locid.h
C++ API: Locale ID object.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::UFieldResolutionTable
int32_t UFieldResolutionTable[12][8]
Definition: calendar.h:48
timezone.h
C++ API: TimeZone object.
ucal.h
C API: Calendar.
UCalendarDateFields
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:202
UCAL_FIELD_COUNT
@ UCAL_FIELD_COUNT
One more than the highest normal UCalendarDateFields value.
Definition: ucal.h:477
UCalendarWallTimeOption
UCalendarWallTimeOption
Options for handling ambiguous wall time at time zone offset transitions.
Definition: ucal.h:991
UCalendarWeekdayType
UCalendarWeekdayType
Weekday types, as returned by ucal_getDayOfWeekType().
Definition: ucal.h:1455
UCalendarDaysOfWeek
UCalendarDaysOfWeek
Useful constant for days of week.
Definition: ucal.h:502
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:338
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:247
umisc.h
C API: Miscellaneous definitions.
URegistryKey
const void * URegistryKey
Opaque type returned by registerInstance, registerFactory and unregister for service registration.
Definition: umisc.h:57
uobject.h
C++ API: Common ICU base class UObject.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:430
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:316
UDate
double UDate
Date and Time data type.
Definition: utypes.h:218