ICU 68.2: calendar.h Source File

ICU 68.2 68.2

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
53 typedef int32_t UFieldResolutionTable[12][8];
54
55 class BasicTimeZone;
187 class U_I18N_API Calendar : public UObject {
188 public:
189 #ifndef U_FORCE_HIDE_DEPRECATED_API
190
196 enum EDateFields {
197 #ifndef U_HIDE_DEPRECATED_API
198 /*
199 * ERA may be defined on other platforms. To avoid any potential problems undefined it here.
200 */
201 #ifdef ERA
202 #undef ERA
203 #endif
204 ERA, // Example: 0..1
205 YEAR, // Example: 1..big number
206 MONTH, // Example: 0..11
207 WEEK_OF_YEAR, // Example: 1..53
208 WEEK_OF_MONTH, // Example: 1..4
209 DATE, // Example: 1..31
210 DAY_OF_YEAR, // Example: 1..365
211 DAY_OF_WEEK, // Example: 1..7
212 DAY_OF_WEEK_IN_MONTH, // Example: 1..4, may be specified as -1
213 AM_PM, // Example: 0..1
214 HOUR, // Example: 0..11
215 HOUR_OF_DAY, // Example: 0..23
216 MINUTE, // Example: 0..59
217 SECOND, // Example: 0..59
218 MILLISECOND, // Example: 0..999
219 ZONE_OFFSET, // Example: -12*U_MILLIS_PER_HOUR..12*U_MILLIS_PER_HOUR
220 DST_OFFSET, // Example: 0 or U_MILLIS_PER_HOUR
221 YEAR_WOY, // 'Y' Example: 1..big number - Year of Week of Year
222 DOW_LOCAL, // 'e' Example: 1..7 - Day of Week / Localized
223
224 EXTENDED_YEAR,
225 JULIAN_DAY,
226 MILLISECONDS_IN_DAY,
227 IS_LEAP_MONTH,
228
229 FIELD_COUNT = UCAL_FIELD_COUNT // See ucal.h for other fields.
230 #endif /* U_HIDE_DEPRECATED_API */
231 };
232 #endif // U_FORCE_HIDE_DEPRECATED_API
233
234 #ifndef U_HIDE_DEPRECATED_API
235
241 enum EDaysOfWeek {
242 SUNDAY = 1,
243 MONDAY,
244 TUESDAY,
245 WEDNESDAY,
246 THURSDAY,
247 FRIDAY,
248 SATURDAY
249 };
250
255 enum EMonths {
256 JANUARY,
257 FEBRUARY,
258 MARCH,
259 APRIL,
260 MAY,
261 JUNE,
262 JULY,
263 AUGUST,
264 SEPTEMBER,
265 OCTOBER,
266 NOVEMBER,
267 DECEMBER,
268 UNDECIMBER
269 };
270
275 enum EAmpm {
276 AM,
277 PM
278 };
279 #endif /* U_HIDE_DEPRECATED_API */
280
285 virtual ~Calendar();
286
293 virtual Calendar* clone() const = 0;
294
306 static Calendar* U_EXPORT2 createInstance(UErrorCode& success);
307
320 static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, UErrorCode& success);
321
333 static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, UErrorCode& success);
334
345 static Calendar* U_EXPORT2 createInstance(const Locale& aLocale, UErrorCode& success);
346
360 static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, const Locale& aLocale, UErrorCode& success);
361
374 static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
375
385 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
386
387
404 static StringEnumeration* U_EXPORT2 getKeywordValuesForLocale(const char* key,
405 const Locale& locale, UBool commonlyUsed, UErrorCode& status);
406
414 static UDate U_EXPORT2 getNow(void);
415
429 inline UDate getTime(UErrorCode& status) const { return getTimeInMillis(status); }
430
441 inline void setTime(UDate date, UErrorCode& status) { setTimeInMillis(date, status); }
442
454 virtual UBool operator==(const Calendar& that) const;
455
464 UBool operator!=(const Calendar& that) const {return !operator==(that);}
465
476 virtual UBool isEquivalentTo(const Calendar& other) const;
477
492 UBool equals(const Calendar& when, UErrorCode& status) const;
493
507 UBool before(const Calendar& when, UErrorCode& status) const;
508
522 UBool after(const Calendar& when, UErrorCode& status) const;
523
524 #ifndef U_FORCE_HIDE_DEPRECATED_API
525
545 virtual void add(EDateFields field, int32_t amount, UErrorCode& status);
546 #endif // U_FORCE_HIDE_DEPRECATED_API
547
568 virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status);
569
570 #ifndef U_HIDE_DEPRECATED_API
571
603 inline void roll(EDateFields field, UBool up, UErrorCode& status);
604 #endif /* U_HIDE_DEPRECATED_API */
605
638 inline void roll(UCalendarDateFields field, UBool up, UErrorCode& status);
639
640 #ifndef U_FORCE_HIDE_DEPRECATED_API
641
672 virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
673 #endif // U_FORCE_HIDE_DEPRECATED_API
674
706 virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
707
708 #ifndef U_FORCE_HIDE_DEPRECATED_API
709
764 virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode& status);
765 #endif // U_FORCE_HIDE_DEPRECATED_API
766
822 virtual int32_t fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status);
823
832 void adoptTimeZone(TimeZone* value);
833
841 void setTimeZone(const TimeZone& zone);
842
851 const TimeZone& getTimeZone(void) const;
852
861 TimeZone* orphanTimeZone(void);
862
871 virtual UBool inDaylightTime(UErrorCode& status) const = 0;
872
885 void setLenient(UBool lenient);
886
893 UBool isLenient(void) const;
894
915 void setRepeatedWallTimeOption(UCalendarWallTimeOption option);
916
926 UCalendarWallTimeOption getRepeatedWallTimeOption(void) const;
927
949 void setSkippedWallTimeOption(UCalendarWallTimeOption option);
950
961 UCalendarWallTimeOption getSkippedWallTimeOption(void) const;
962
963 #ifndef U_HIDE_DEPRECATED_API
964
970 void setFirstDayOfWeek(EDaysOfWeek value);
971 #endif /* U_HIDE_DEPRECATED_API */
972
979 void setFirstDayOfWeek(UCalendarDaysOfWeek value);
980
981 #ifndef U_HIDE_DEPRECATED_API
982
988 EDaysOfWeek getFirstDayOfWeek(void) const;
989 #endif /* U_HIDE_DEPRECATED_API */
990
998 UCalendarDaysOfWeek getFirstDayOfWeek(UErrorCode &status) const;
999
1009 void setMinimalDaysInFirstWeek(uint8_t value);
1010
1020 uint8_t getMinimalDaysInFirstWeek(void) const;
1021
1022 #ifndef U_FORCE_HIDE_DEPRECATED_API
1023
1031 virtual int32_t getMinimum(EDateFields field) const;
1032 #endif // U_FORCE_HIDE_DEPRECATED_API
1033
1042 virtual int32_t getMinimum(UCalendarDateFields field) const;
1043
1044 #ifndef U_FORCE_HIDE_DEPRECATED_API
1045
1053 virtual int32_t getMaximum(EDateFields field) const;
1054 #endif // U_FORCE_HIDE_DEPRECATED_API
1055
1064 virtual int32_t getMaximum(UCalendarDateFields field) const;
1065
1066 #ifndef U_FORCE_HIDE_DEPRECATED_API
1067
1075 virtual int32_t getGreatestMinimum(EDateFields field) const;
1076 #endif // U_FORCE_HIDE_DEPRECATED_API
1077
1086 virtual int32_t getGreatestMinimum(UCalendarDateFields field) const;
1087
1088 #ifndef U_FORCE_HIDE_DEPRECATED_API
1089
1097 virtual int32_t getLeastMaximum(EDateFields field) const;
1098 #endif // U_FORCE_HIDE_DEPRECATED_API
1099
1108 virtual int32_t getLeastMaximum(UCalendarDateFields field) const;
1109
1110 #ifndef U_HIDE_DEPRECATED_API
1111
1125 int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;
1126 #endif /* U_HIDE_DEPRECATED_API */
1127
1142 virtual int32_t getActualMinimum(UCalendarDateFields field, UErrorCode& status) const;
1143
1144 #ifndef U_HIDE_DEPRECATED_API
1145
1161 int32_t getActualMaximum(EDateFields field, UErrorCode& status) const;
1162 #endif /* U_HIDE_DEPRECATED_API */
1163
1180 virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
1181
1182 #ifndef U_HIDE_DEPRECATED_API
1183
1196 int32_t get(EDateFields field, UErrorCode& status) const;
1197 #endif /* U_HIDE_DEPRECATED_API */
1198
1212 int32_t get(UCalendarDateFields field, UErrorCode& status) const;
1213
1214 #ifndef U_HIDE_DEPRECATED_API
1215
1223 UBool isSet(EDateFields field) const;
1224 #endif /* U_HIDE_DEPRECATED_API */
1225
1234 UBool isSet(UCalendarDateFields field) const;
1235
1236 #ifndef U_HIDE_DEPRECATED_API
1237
1244 void set(EDateFields field, int32_t value);
1245 #endif /* U_HIDE_DEPRECATED_API */
1246
1254 void set(UCalendarDateFields field, int32_t value);
1255
1266 void set(int32_t year, int32_t month, int32_t date);
1267
1280 void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute);
1281
1295 void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second);
1296
1303 void clear(void);
1304
1305 #ifndef U_HIDE_DEPRECATED_API
1306
1314 void clear(EDateFields field);
1315 #endif /* U_HIDE_DEPRECATED_API */
1316
1325 void clear(UCalendarDateFields field);
1326
1342 virtual UClassID getDynamicClassID(void) const = 0;
1343
1376 virtual const char * getType() const = 0;
1377
1394 virtual UCalendarWeekdayType getDayOfWeekType(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
1395
1410 virtual int32_t getWeekendTransition(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
1411
1421 virtual UBool isWeekend(UDate date, UErrorCode &status) const;
1422
1430 virtual UBool isWeekend(void) const;
1431
1432 protected:
1433
1442 Calendar(UErrorCode& success);
1443
1450 Calendar(const Calendar& source);
1451
1458 Calendar& operator=(const Calendar& right);
1459
1470 Calendar(TimeZone* zone, const Locale& aLocale, UErrorCode& success);
1471
1481 Calendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
1482
1491 virtual void computeTime(UErrorCode& status);
1492
1504 virtual void computeFields(UErrorCode& status);
1505
1515 double getTimeInMillis(UErrorCode& status) const;
1516
1525 void setTimeInMillis( double millis, UErrorCode& status );
1526
1536 void complete(UErrorCode& status);
1537
1538 #ifndef U_HIDE_DEPRECATED_API
1539
1547 inline int32_t internalGet(EDateFields field) const {return fFields[field];}
1548 #endif /* U_HIDE_DEPRECATED_API */
1549
1550 #ifndef U_HIDE_INTERNAL_API
1551
1561 inline int32_t internalGet(UCalendarDateFields field, int32_t defaultValue) const {return fStamp[field]>kUnset ? fFields[field] : defaultValue;}
1562
1571 inline int32_t internalGet(UCalendarDateFields field) const {return fFields[field];}
1572 #endif /* U_HIDE_INTERNAL_API */
1573
1574 #ifndef U_HIDE_DEPRECATED_API
1575
1584 void internalSet(EDateFields field, int32_t value);
1585 #endif /* U_HIDE_DEPRECATED_API */
1586
1596 inline void internalSet(UCalendarDateFields field, int32_t value);
1597
1604 virtual void prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status);
1605
1610 enum ELimitType {
1611 #ifndef U_HIDE_INTERNAL_API
1612 UCAL_LIMIT_MINIMUM = 0,
1613 UCAL_LIMIT_GREATEST_MINIMUM,
1614 UCAL_LIMIT_LEAST_MAXIMUM,
1615 UCAL_LIMIT_MAXIMUM,
1616 UCAL_LIMIT_COUNT
1617 #endif /* U_HIDE_INTERNAL_API */
1618 };
1619
1641 virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const = 0;
1642
1650 virtual int32_t getLimit(UCalendarDateFields field, ELimitType limitType) const;
1651
1652
1666 virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
1667 UBool useMonth) const = 0;
1668
1676 virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const ;
1677
1685 virtual int32_t handleGetYearLength(int32_t eyear) const;
1686
1687
1696 virtual int32_t handleGetExtendedYear() = 0;
1697
1706 virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField);
1707
1716 virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
1717
1724 virtual void validateField(UCalendarDateFields field, UErrorCode &status);
1725
1726 #ifndef U_HIDE_INTERNAL_API
1727
1733 int32_t computeJulianDay();
1734
1742 double computeMillisInDay();
1743
1753 int32_t computeZoneOffset(double millis, double millisInDay, UErrorCode &ec);
1754
1755
1764 int32_t newestStamp(UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const;
1765
1771 enum {
1773 kResolveSTOP = -1,
1775 kResolveRemap = 32
1776 };
1777
1783 static const UFieldResolutionTable kDatePrecedence[];
1784
1790 static const UFieldResolutionTable kYearPrecedence[];
1791
1797 static const UFieldResolutionTable kDOWPrecedence[];
1798
1826 UCalendarDateFields resolveFields(const UFieldResolutionTable *precedenceTable);
1827 #endif /* U_HIDE_INTERNAL_API */
1828
1829
1833 virtual const UFieldResolutionTable* getFieldResolutionTable() const;
1834
1835 #ifndef U_HIDE_INTERNAL_API
1836
1841 UCalendarDateFields newerField(UCalendarDateFields defaultField, UCalendarDateFields alternateField) const;
1842 #endif /* U_HIDE_INTERNAL_API */
1843
1844
1845 private:
1854 int32_t getActualHelper(UCalendarDateFields field, int32_t startValue, int32_t endValue, UErrorCode &status) const;
1855
1856
1857 protected:
1862 UBool fIsTimeSet;
1863
1874 UBool fAreFieldsSet;
1875
1881 UBool fAreAllFieldsSet;
1882
1890 UBool fAreFieldsVirtuallySet;
1891
1898 UDate internalGetTime(void) const { return fTime; }
1899
1907 void internalSetTime(UDate time) { fTime = time; }
1908
1913 int32_t fFields[UCAL_FIELD_COUNT];
1914
1915 #ifndef U_FORCE_HIDE_DEPRECATED_API
1916
1920 UBool fIsSet[UCAL_FIELD_COUNT];
1921 #endif // U_FORCE_HIDE_DEPRECATED_API
1922
1926 enum {
1927 kUnset = 0,
1928 kInternallySet,
1929 kMinimumUserStamp
1930 };
1931
1938 int32_t fStamp[UCAL_FIELD_COUNT];
1939
1964 virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
1965
1966 #ifndef U_HIDE_INTERNAL_API
1967
1972 int32_t getGregorianYear() const {
1973 return fGregorianYear;
1974 }
1975
1981 int32_t getGregorianMonth() const {
1982 return fGregorianMonth;
1983 }
1984
1990 int32_t getGregorianDayOfYear() const {
1991 return fGregorianDayOfYear;
1992 }
1993
1999 int32_t getGregorianDayOfMonth() const {
2000 return fGregorianDayOfMonth;
2001 }
2002 #endif /* U_HIDE_INTERNAL_API */
2003
2010 virtual int32_t getDefaultMonthInYear(int32_t eyear) ;
2011
2012
2020 virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month);
2021
2022 //-------------------------------------------------------------------------
2023 // Protected utility methods for use by subclasses. These are very handy
2024 // for implementing add, roll, and computeFields.
2025 //-------------------------------------------------------------------------
2026
2056 virtual void pinField(UCalendarDateFields field, UErrorCode& status);
2057
2101 int32_t weekNumber(int32_t desiredDay, int32_t dayOfPeriod, int32_t dayOfWeek);
2102
2103
2104 #ifndef U_HIDE_INTERNAL_API
2105
2135 inline int32_t weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek);
2136
2141 int32_t getLocalDOW();
2142 #endif /* U_HIDE_INTERNAL_API */
2143
2144 private:
2145
2149 int32_t fNextStamp;// = MINIMUM_USER_STAMP;
2150
2155 void recalculateStamp();
2156
2160 UDate fTime;
2161
2165 UBool fLenient;
2166
2171 TimeZone* fZone;
2172
2177 UCalendarWallTimeOption fRepeatedWallTime;
2178
2183 UCalendarWallTimeOption fSkippedWallTime;
2184
2193 UCalendarDaysOfWeek fFirstDayOfWeek;
2194 uint8_t fMinimalDaysInFirstWeek;
2195 UCalendarDaysOfWeek fWeekendOnset;
2196 int32_t fWeekendOnsetMillis;
2197 UCalendarDaysOfWeek fWeekendCease;
2198 int32_t fWeekendCeaseMillis;
2199
2210 void setWeekData(const Locale& desiredLocale, const char *type, UErrorCode& success);
2211
2221 void updateTime(UErrorCode& status);
2222
2228 int32_t fGregorianYear;
2229
2235 int32_t fGregorianMonth;
2236
2242 int32_t fGregorianDayOfYear;
2243
2249 int32_t fGregorianDayOfMonth;
2250
2251 /* calculations */
2252
2259 void computeGregorianAndDOWFields(int32_t julianDay, UErrorCode &ec);
2260
2261 protected:
2262
2270 void computeGregorianFields(int32_t julianDay, UErrorCode &ec);
2271
2272 private:
2273
2294 void computeWeekFields(UErrorCode &ec);
2295
2296
2304 void validateFields(UErrorCode &status);
2305
2313 void validateField(UCalendarDateFields field, int32_t min, int32_t max, UErrorCode& status);
2314
2315 protected:
2316 #ifndef U_HIDE_INTERNAL_API
2317
2326 static uint8_t julianDayToDayOfWeek(double julian);
2327 #endif /* U_HIDE_INTERNAL_API */
2328
2329 private:
2330 char validLocale[ULOC_FULLNAME_CAPACITY];
2331 char actualLocale[ULOC_FULLNAME_CAPACITY];
2332
2333 public:
2334 #if !UCONFIG_NO_SERVICE
2335
2339 #ifndef U_HIDE_INTERNAL_API
2340
2346 static StringEnumeration* getAvailableLocales(void);
2347
2361 static URegistryKey registerFactory(ICUServiceFactory* toAdopt, UErrorCode& status);
2362
2378 static UBool unregister(URegistryKey key, UErrorCode& status);
2379 #endif /* U_HIDE_INTERNAL_API */
2380
2385 friend class CalendarFactory;
2386
2391 friend class CalendarService;
2392
2397 friend class DefaultCalendarFactory;
2398 #endif /* !UCONFIG_NO_SERVICE */
2399
2404 virtual UBool haveDefaultCentury() const = 0;
2405
2410 virtual UDate defaultCenturyStart() const = 0;
2415 virtual int32_t defaultCenturyStartYear() const = 0;
2416
2423 Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const;
2424
2430 virtual int32_t getRelatedYear(UErrorCode &status) const;
2431
2437 virtual void setRelatedYear(int32_t year);
2438
2439 #ifndef U_HIDE_INTERNAL_API
2440
2446 const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;
2447 #endif /* U_HIDE_INTERNAL_API */
2448
2449 private:
2454 BasicTimeZone* getBasicTimeZone() const;
2455
2463 UBool getImmediatePreviousZoneTransition(UDate base, UDate *transitionTime, UErrorCode& status) const;
2464
2465 public:
2466 #ifndef U_HIDE_INTERNAL_API
2467
2475 static Calendar * U_EXPORT2 makeInstance(
2476 const Locale &locale, UErrorCode &status);
2477
2488 static void U_EXPORT2 getCalendarTypeFromLocale(
2489 const Locale &locale,
2490 char *typeBuffer,
2491 int32_t typeBufferSize,
2492 UErrorCode &status);
2493 #endif /* U_HIDE_INTERNAL_API */
2494 };
2495
2496 // -------------------------------------
2497
2498 inline Calendar*
2499 Calendar::createInstance(TimeZone* zone, UErrorCode& errorCode)
2500 {
2501 // since the Locale isn't specified, use the default locale
2502 return createInstance(zone, Locale::getDefault(), errorCode);
2503 }
2504
2505 // -------------------------------------
2506
2507 inline void
2508 Calendar::roll(UCalendarDateFields field, UBool up, UErrorCode& status)
2509 {
2510 roll(field, (int32_t)(up ? +1 : -1), status);
2511 }
2512
2513 #ifndef U_HIDE_DEPRECATED_API
2514 inline void
2515 Calendar::roll(EDateFields field, UBool up, UErrorCode& status)
2516 {
2517 roll((UCalendarDateFields) field, up, status);
2518 }
2519 #endif /* U_HIDE_DEPRECATED_API */
2520
2521
2522 // -------------------------------------
2523
2529 inline void
2530 Calendar::internalSet(UCalendarDateFields field, int32_t value)
2531 {
2532 fFields[field] = value;
2533 fStamp[field] = kInternallySet;
2534 fIsSet[field] = true; // Remove later
2535 }
2536
2537
2538 #ifndef U_HIDE_INTERNAL_API
2539 inline int32_t Calendar::weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek)
2540 {
2541 return weekNumber(dayOfPeriod, dayOfPeriod, dayOfWeek);
2542 }
2543 #endif /* U_HIDE_INTERNAL_API */
2544
2545 U_NAMESPACE_END
2546
2547 #endif /* #if !UCONFIG_NO_FORMATTING */
2548
2549 #endif /* U_SHOW_CPLUSPLUS_API */
2550
2551 #endif // _CALENDAR
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::set
void set(int32_t year, int32_t month, int32_t date)
Sets the values for the fields YEAR, MONTH, and DATE.
icu::Calendar::prepareGetActual
virtual void prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status)
Prepare this calendar for computing the actual minimum or maximum.
icu::Calendar::getGregorianMonth
int32_t getGregorianMonth() const
Return the month (0-based) on the Gregorian calendar as computed by computeGregorianFields().
Definition: calendar.h:1981
icu::Calendar::getDefaultMonthInYear
virtual int32_t getDefaultMonthInYear(int32_t eyear)
Called by computeJulianDay.
icu::Calendar::getLocale
Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Get the locale for this calendar object.
icu::Calendar::getActualMaximum
int32_t getActualMaximum(EDateFields field, UErrorCode &status) const
Return the maximum value that this field could have, given the current date.
icu::Calendar::isSet
UBool isSet(UCalendarDateFields field) const
Determines if the given time field has a value set.
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::Calendar::handleGetLimit
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const =0
Subclass API for defining limits of different types.
icu::Calendar::clone
virtual Calendar * clone() const =0
Create and return a polymorphic copy of this calendar.
icu::Calendar::ELimitType
ELimitType
Limit enums.
Definition: calendar.h:1610
icu::Calendar::Calendar
Calendar(const Calendar &source)
Copy constructor.
icu::Calendar::isLenient
UBool isLenient(void) const
Tells whether date/time interpretation is to be lenient.
icu::Calendar::fAreAllFieldsSet
UBool fAreAllFieldsSet
True if all of the fields have been set.
Definition: calendar.h:1881
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UCalendarWallTimeOption
UCalendarWallTimeOption
Options for handling ambiguous wall time at time zone offset transitions.
Definition: ucal.h:965
icu::Calendar::internalGet
int32_t internalGet(EDateFields field) const
Gets the value for a given time field.
Definition: calendar.h:1547
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::registerFactory
static URegistryKey registerFactory(ICUServiceFactory *toAdopt, UErrorCode &status)
Register a new Calendar factory.
icu::Calendar::computeMillisInDay
double computeMillisInDay()
Compute the milliseconds in the day from the fields.
icu::Calendar::createInstance
static Calendar * createInstance(UErrorCode &success)
Creates a Calendar using the default timezone and locale.
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:301
icu::Calendar
Calendar is an abstract base class for converting between a UDate object and a set of integer fields ...
Definition: calendar.h:187
icu::Calendar::getMaximum
virtual int32_t getMaximum(UCalendarDateFields field) const
Gets the maximum value for the given time field.
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
icu::BasicTimeZone
BasicTimeZone is an abstract class extending TimeZone.
Definition: basictz.h:38
icu::Calendar::handleGetExtendedYearFromWeekFields
virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy)
Subclasses must override this to convert from week fields (YEAR_WOY and WEEK_OF_YEAR) to an extended ...
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:338
icu::Calendar::Calendar
Calendar(TimeZone *zone, const Locale &aLocale, UErrorCode &success)
Constructs a Calendar with the given time zone and locale.
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::validateField
virtual void validateField(UCalendarDateFields field, UErrorCode &status)
Validate a single field of this calendar.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::Calendar::operator!=
UBool operator!=(const Calendar &that) const
Compares the inequality of two Calendar objects.
Definition: calendar.h:464
icu::Calendar::internalGet
int32_t internalGet(UCalendarDateFields field, int32_t defaultValue) const
Gets the value for a given time field.
Definition: calendar.h:1561
icu::Calendar::internalGet
int32_t internalGet(UCalendarDateFields field) const
Gets the value for a given time field.
Definition: calendar.h:1571
icu::Calendar::newerField
UCalendarDateFields newerField(UCalendarDateFields defaultField, UCalendarDateFields alternateField) const
Return the field that is newer, either defaultField, or alternateField.
icu::Calendar::set
void set(UCalendarDateFields field, int32_t value)
Sets the given time field with the given value.
icu::Calendar::setFirstDayOfWeek
void setFirstDayOfWeek(EDaysOfWeek value)
Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
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::defaultCenturyStartYear
virtual int32_t defaultCenturyStartYear() const =0
icu::Calendar::defaultCenturyStart
virtual UDate defaultCenturyStart() const =0
icu::Calendar::internalGetTime
UDate internalGetTime(void) const
Get the current time without recomputing.
Definition: calendar.h:1898
icu::Calendar::haveDefaultCentury
virtual UBool haveDefaultCentury() const =0
icu::Calendar::setLenient
void setLenient(UBool lenient)
Specifies whether or not date/time interpretation is to be lenient.
icu::TimeZone
TimeZone represents a time zone offset, and also figures out daylight savings.
Definition: timezone.h:133
icu::Calendar::get
int32_t get(EDateFields field, UErrorCode &status) const
Gets the value for a given time field.
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::getLocaleID
const char * getLocaleID(ULocDataLocaleType type, UErrorCode &status) const
Get the locale for this calendar object.
icu::Calendar::add
virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode &status)
UDate Arithmetic function.
icu::Calendar::EAmpm
EAmpm
Useful constants for hour in 12-hour clock.
Definition: calendar.h:275
icu::Calendar::createInstance
static Calendar * createInstance(const TimeZone &zone, UErrorCode &success)
Creates a Calendar using the given timezone and the default locale.
icu::Calendar::operator==
virtual UBool operator==(const Calendar &that) const
Compares the equality of two Calendar objects.
icu::Calendar::clear
void clear(EDateFields field)
Clears the value in the given time field, both making it unset and assigning it a value of zero.
icu::Calendar::computeZoneOffset
int32_t computeZoneOffset(double millis, double millisInDay, UErrorCode &ec)
This method can assume EXTENDED_YEAR has been set.
umisc.h
C API:misc definitions.
icu::Calendar::getMinimum
virtual int32_t getMinimum(UCalendarDateFields field) const
Gets the minimum value for the given time field.
icu::Calendar::getLimit
virtual int32_t getLimit(UCalendarDateFields field, ELimitType limitType) const
Return a limit for a field.
icu::Calendar::clear
void clear(void)
Clears the values of all the time fields, making them both unset and assigning them a value of zero.
icu::Calendar::getFirstDayOfWeek
EDaysOfWeek getFirstDayOfWeek(void) const
Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
icu::Calendar::createInstance
static Calendar * createInstance(const TimeZone &zone, const Locale &aLocale, UErrorCode &success)
Gets a Calendar using the given timezone and given locale.
timezone.h
C++ API: TimeZone object.
icu::Calendar::orphanTimeZone
TimeZone * orphanTimeZone(void)
Returns the time zone owned by this calendar.
icu::Calendar::internalSetTime
void internalSetTime(UDate time)
Set the current time without affecting flags or fields.
Definition: calendar.h:1907
icu::Calendar::~Calendar
virtual ~Calendar()
destructor
icu::Calendar::getType
virtual const char * getType() const =0
Returns the calendar type name string for this Calendar object.
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...
URegistryKey
const void * URegistryKey
Opaque type returned by registerInstance, registerFactory and unregister for service registration.
Definition: umisc.h:57
icu::Calendar::resolveFields
UCalendarDateFields resolveFields(const UFieldResolutionTable *precedenceTable)
Given a precedence table, return the newest field combination in the table, or UCAL_FIELD_COUNT if no...
icu::Calendar::newestStamp
int32_t newestStamp(UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const
Determine the best stamp in a range.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::Calendar::getRelatedYear
virtual int32_t getRelatedYear(UErrorCode &status) const
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::isEquivalentTo
virtual UBool isEquivalentTo(const Calendar &other) const
Returns true if the given Calendar object is equivalent to this one.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
icu::Calendar::createInstance
static Calendar * createInstance(const Locale &aLocale, UErrorCode &success)
Creates a Calendar using the default timezone and the given locale.
icu::Calendar::setTimeInMillis
void setTimeInMillis(double millis, UErrorCode &status)
Sets this Calendar's current time from the given long value.
icu::StringEnumeration
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:61
icu::Calendar::getTimeInMillis
double getTimeInMillis(UErrorCode &status) const
Gets this Calendar's current time as a long.
icu::Calendar::getMaximum
virtual int32_t getMaximum(EDateFields field) const
Gets the maximum value for the given time field.
icu::Calendar::setRelatedYear
virtual void setRelatedYear(int32_t year)
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::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::isWeekend
virtual UBool isWeekend(void) const
Returns true if this Calendar's current date-time is in the weekend in this calendar system.
icu::Calendar::isSet
UBool isSet(EDateFields field) const
Determines if the given time field has a value set.
icu::Calendar::getRepeatedWallTimeOption
UCalendarWallTimeOption getRepeatedWallTimeOption(void) const
Gets the behavior for handling wall time repeating multiple times at negative time zone offset transi...
ucal.h
C API: Calendar.
icu::Calendar::handleComputeJulianDay
virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField)
Subclasses may override this.
icu::Calendar::inDaylightTime
virtual UBool inDaylightTime(UErrorCode &status) const =0
Queries if the current date for this Calendar is in Daylight Savings Time.
icu::Calendar::getAvailableLocales
static StringEnumeration * getAvailableLocales(void)
INTERNAL FOR 2.6 – Registration.
icu::Calendar::add
virtual void add(EDateFields field, int32_t amount, UErrorCode &status)
UDate Arithmetic function.
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::getMinimalDaysInFirstWeek
uint8_t getMinimalDaysInFirstWeek(void) 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::getAvailableLocales
static const Locale * getAvailableLocales(int32_t &count)
Returns a list of the locales for which Calendars are installed.
icu::Calendar::fAreFieldsVirtuallySet
UBool fAreFieldsVirtuallySet
True if all fields have been virtually set, but have not yet been computed.
Definition: calendar.h:1890
icu::Calendar::fAreFieldsSet
UBool fAreFieldsSet
True if the fields are in sync with the currently set time of this Calendar.
Definition: calendar.h:1874
icu::Calendar::getDefaultDayInMonth
virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month)
Called by computeJulianDay.
icu::Calendar::Calendar
Calendar(const TimeZone &zone, const Locale &aLocale, UErrorCode &success)
Constructs a Calendar with the given time zone and locale.
UCalendarWeekdayType
UCalendarWeekdayType
Weekday types, as returned by ucal_getDayOfWeekType().
Definition: ucal.h:1399
icu::Calendar::get
int32_t get(UCalendarDateFields field, UErrorCode &status) const
Gets the value for a given time field.
icu::Calendar::computeJulianDay
int32_t computeJulianDay()
Compute the Julian day from fields.
icu::Calendar::computeTime
virtual void computeTime(UErrorCode &status)
Converts Calendar's time field values to GMT as milliseconds.
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::computeFields
virtual void computeFields(UErrorCode &status)
Converts GMT as milliseconds to time field values.
UCAL_FIELD_COUNT
@ UCAL_FIELD_COUNT
One more than the highest normal UCalendarDateFields value.
Definition: ucal.h:452
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::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::getLeastMaximum
virtual int32_t getLeastMaximum(EDateFields field) const
Gets the lowest maximum value for the given field if varies.
icu::Calendar::handleGetMonthLength
virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const
Return the number of days in the given month of the given extended year of this calendar system.
icu::Calendar::getDynamicClassID
virtual UClassID getDynamicClassID(void) const =0
Returns a unique class ID POLYMORPHICALLY.
icu::Calendar::set
void set(EDateFields field, int32_t value)
Sets the given time field with the given value.
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::getLeastMaximum
virtual int32_t getLeastMaximum(UCalendarDateFields field) const
Gets the lowest maximum value for the given field if varies.
icu::Calendar::getLocalDOW
int32_t getLocalDOW()
returns the local DOW, valid range 0..6
icu::Calendar::roll
virtual void roll(EDateFields field, int32_t amount, UErrorCode &status)
Time Field Rolling function.
ULOC_FULLNAME_CAPACITY
#define ULOC_FULLNAME_CAPACITY
Useful constant for the maximum size of the whole locale ID (including the terminating NULL and all k...
Definition: uloc.h:264
icu::Calendar::handleGetExtendedYear
virtual int32_t handleGetExtendedYear()=0
Return the extended year defined by the current fields.
icu::Calendar::Calendar
Calendar(UErrorCode &success)
Constructs a Calendar with the default time zone as returned by TimeZone::createInstance(),...
icu::Calendar::getGreatestMinimum
virtual int32_t getGreatestMinimum(EDateFields field) const
Gets the highest minimum value for the given field if varies.
icu::Calendar::getSkippedWallTimeOption
UCalendarWallTimeOption getSkippedWallTimeOption(void) const
Gets the behavior for handling skipped wall time at positive time zone offset transitions.
icu::Calendar::adoptTimeZone
void adoptTimeZone(TimeZone *value)
Sets the calendar's time zone to be the one passed in.
UCalendarDaysOfWeek
UCalendarDaysOfWeek
Useful constant for days of week.
Definition: ucal.h:476
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::setSkippedWallTimeOption
void setSkippedWallTimeOption(UCalendarWallTimeOption option)
Sets the behavior for handling skipped wall time at positive time zone offset transitions.
UDate
double UDate
Date and Time data type.
Definition: utypes.h:203
icu::Calendar::getGreatestMinimum
virtual int32_t getGreatestMinimum(UCalendarDateFields field) const
Gets the highest minimum value for the given field if varies.
icu::UFieldResolutionTable
int32_t UFieldResolutionTable[12][8]
Definition: calendar.h:48
icu::Calendar::makeInstance
static Calendar * makeInstance(const Locale &locale, UErrorCode &status)
Creates a new Calendar from a Locale for the cache.
icu::Calendar::getNow
static UDate getNow(void)
Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70 (derived from the...
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::operator=
Calendar & operator=(const Calendar &right)
Default assignment operator.
UCalendarDateFields
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:202
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::internalSet
void internalSet(EDateFields field, int32_t value)
Sets the value for a given time field.
icu::Calendar::roll
virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode &status)
Time Field Rolling function.
icu::Calendar::handleComputeMonthStart
virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth) const =0
Return the Julian day number of day before the first day of the given month in the given extended yea...
icu::Calendar::EMonths
EMonths
Useful constants for month.
Definition: calendar.h:255
icu::Calendar::julianDayToDayOfWeek
static uint8_t julianDayToDayOfWeek(double julian)
Convert a quasi Julian date to the day of the week.
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::getGregorianYear
int32_t getGregorianYear() const
Return the extended year on the Gregorian calendar as computed by computeGregorianFields().
Definition: calendar.h:1972
locid.h
C++ API: Locale ID object.
icu::Calendar::getTimeZone
const TimeZone & getTimeZone(void) const
Returns a reference to the time zone owned by this calendar.
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::setTime
void setTime(UDate date, UErrorCode &status)
Sets this Calendar's current time with the given UDate.
Definition: calendar.h:441
icu::Calendar::EDaysOfWeek
EDaysOfWeek
Useful constant for days of week.
Definition: calendar.h:241
uobject.h
C++ API: Common ICU base class UObject.
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::getCalendarTypeFromLocale
static void getCalendarTypeFromLocale(const Locale &locale, char *typeBuffer, int32_t typeBufferSize, UErrorCode &status)
Get the calendar type for given locale.
icu::Calendar::getMinimum
virtual int32_t getMinimum(EDateFields field) const
Gets the minimum value for the given time field.
icu::Calendar::handleGetYearLength
virtual int32_t handleGetYearLength(int32_t eyear) const
Return the number of days in the given extended year of this calendar system.
icu::Calendar::getFieldResolutionTable
virtual const UFieldResolutionTable * getFieldResolutionTable() const
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::getGregorianDayOfMonth
int32_t getGregorianDayOfMonth() const
Return the day of month (1-based) on the Gregorian calendar as computed by computeGregorianFields().
Definition: calendar.h:1999
icu::Calendar::EDateFields
EDateFields
Field IDs for date and time.
Definition: calendar.h:196
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
icu::Calendar::fIsTimeSet
UBool fIsTimeSet
The flag which indicates if the current time is set in the calendar.
Definition: calendar.h:1862
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::setMinimalDaysInFirstWeek
void setMinimalDaysInFirstWeek(uint8_t value)
Sets what the minimal days required in the first week of the year are; For example,...
icu::Calendar::getTime
UDate getTime(UErrorCode &status) const
Gets this Calendar's time as milliseconds.
Definition: calendar.h:429
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::unregister
static UBool unregister(URegistryKey key, UErrorCode &status)
Unregister a previously-registered CalendarFactory using the key returned from the register call.
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:1990
icu::Calendar::createInstance
static Calendar * createInstance(TimeZone *zoneToAdopt, const Locale &aLocale, UErrorCode &success)
Creates a Calendar using the given timezone and given locale.