ICU 50.2 50.2
calendar.h
Go to the documentation of this file.
1/*
2********************************************************************************
3* Copyright (C) 1997-2012, International Business Machines
4* Corporation and others. All Rights Reserved.
5********************************************************************************
6*
7* File CALENDAR.H
8*
9* Modification History:
10*
11* Date Name Description
12* 04/22/97 aliu Expanded and corrected comments and other header
13* contents.
14* 05/01/97 aliu Made equals(), before(), after() arguments const.
15* 05/20/97 aliu Replaced fAreFieldsSet with fAreFieldsInSync and
16* fAreAllFieldsSet.
17* 07/27/98 stephen Sync up with JDK 1.2
18* 11/15/99 weiv added YEAR_WOY and DOW_LOCAL
19* to EDateFields
20* 8/19/2002 srl Removed Javaisms
21* 11/07/2003 srl Update, clean up documentation.
22********************************************************************************
23*/
24
25#ifndef CALENDAR_H
26#define CALENDAR_H
27
28#include "unicode/utypes.h"
29
34#if !UCONFIG_NO_FORMATTING
35
36#include "unicode/uobject.h"
37#include "unicode/locid.h"
38#include "unicode/timezone.h"
39#include "unicode/ucal.h"
40#include "unicode/umisc.h"
41
43
44class ICUServiceFactory;
45
49typedef int32_t UFieldResolutionTable[12][8];
50
51class BasicTimeZone;
201public:
202
210#ifndef U_HIDE_DEPRECATED_API
211/*
212 * ERA may be defined on other platforms. To avoid any potential problems undefined it here.
213 */
214#ifdef ERA
215#undef ERA
216#endif
217 ERA, // Example: 0..1
218 YEAR, // Example: 1..big number
219 MONTH, // Example: 0..11
220 WEEK_OF_YEAR, // Example: 1..53
221 WEEK_OF_MONTH, // Example: 1..4
222 DATE, // Example: 1..31
223 DAY_OF_YEAR, // Example: 1..365
224 DAY_OF_WEEK, // Example: 1..7
225 DAY_OF_WEEK_IN_MONTH, // Example: 1..4, may be specified as -1
226 AM_PM, // Example: 0..1
227 HOUR, // Example: 0..11
228 HOUR_OF_DAY, // Example: 0..23
229 MINUTE, // Example: 0..59
230 SECOND, // Example: 0..59
231 MILLISECOND, // Example: 0..999
232 ZONE_OFFSET, // Example: -12*U_MILLIS_PER_HOUR..12*U_MILLIS_PER_HOUR
233 DST_OFFSET, // Example: 0 or U_MILLIS_PER_HOUR
234 YEAR_WOY, // 'Y' Example: 1..big number - Year of Week of Year
235 DOW_LOCAL, // 'e' Example: 1..7 - Day of Week / Localized
236
237 EXTENDED_YEAR,
238 JULIAN_DAY,
239 MILLISECONDS_IN_DAY,
240 IS_LEAP_MONTH,
241
242 FIELD_COUNT = UCAL_FIELD_COUNT // See ucal.h for other fields.
243#endif /* U_HIDE_DEPRECATED_API */
244 };
245
246#ifndef U_HIDE_DEPRECATED_API
254 SUNDAY = 1,
255 MONDAY,
256 TUESDAY,
257 WEDNESDAY,
258 THURSDAY,
259 FRIDAY,
260 SATURDAY
261 };
262
267 enum EMonths {
268 JANUARY,
269 FEBRUARY,
270 MARCH,
271 APRIL,
272 MAY,
273 JUNE,
274 JULY,
275 AUGUST,
276 SEPTEMBER,
277 OCTOBER,
278 NOVEMBER,
279 DECEMBER,
280 UNDECIMBER
281 };
282
287 enum EAmpm {
288 AM,
289 PM
290 };
291#endif /* U_HIDE_DEPRECATED_API */
292
297 virtual ~Calendar();
298
305 virtual Calendar* clone(void) const = 0;
306
318 static Calendar* U_EXPORT2 createInstance(UErrorCode& success);
319
332 static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, UErrorCode& success);
333
345 static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, UErrorCode& success);
346
357 static Calendar* U_EXPORT2 createInstance(const Locale& aLocale, UErrorCode& success);
358
372 static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, const Locale& aLocale, UErrorCode& success);
373
386 static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
387
397 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
398
399
416 static StringEnumeration* U_EXPORT2 getKeywordValuesForLocale(const char* key,
417 const Locale& locale, UBool commonlyUsed, UErrorCode& status);
418
426 static UDate U_EXPORT2 getNow(void);
427
441 inline UDate getTime(UErrorCode& status) const { return getTimeInMillis(status); }
442
453 inline void setTime(UDate date, UErrorCode& status) { setTimeInMillis(date, status); }
454
466 virtual UBool operator==(const Calendar& that) const;
467
476 UBool operator!=(const Calendar& that) const {return !operator==(that);}
477
488 virtual UBool isEquivalentTo(const Calendar& other) const;
489
504 UBool equals(const Calendar& when, UErrorCode& status) const;
505
519 UBool before(const Calendar& when, UErrorCode& status) const;
520
534 UBool after(const Calendar& when, UErrorCode& status) const;
535
556 virtual void add(EDateFields field, int32_t amount, UErrorCode& status);
557
578 virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status);
579
580#ifndef U_HIDE_DEPRECATED_API
613 inline void roll(EDateFields field, UBool up, UErrorCode& status);
614#endif /* U_HIDE_DEPRECATED_API */
615
648 inline void roll(UCalendarDateFields field, UBool up, UErrorCode& status);
649
681 virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
682
714 virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
715
771 virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode& status);
772
828 virtual int32_t fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status);
829
839
847 void setTimeZone(const TimeZone& zone);
848
857 const TimeZone& getTimeZone(void) const;
858
868
877 virtual UBool inDaylightTime(UErrorCode& status) const = 0;
878
891 void setLenient(UBool lenient);
892
899 UBool isLenient(void) const;
900
901#ifndef U_HIDE_DRAFT_API
923
934
957
969#endif /* U_HIDE_DRAFT_API */
970
971#ifndef U_HIDE_DEPRECATED_API
979#endif /* U_HIDE_DEPRECATED_API */
980
988
989#ifndef U_HIDE_DEPRECATED_API
997#endif /* U_HIDE_DEPRECATED_API */
998
1007
1017 void setMinimalDaysInFirstWeek(uint8_t value);
1018
1028 uint8_t getMinimalDaysInFirstWeek(void) const;
1029
1038 virtual int32_t getMinimum(EDateFields field) const;
1039
1048 virtual int32_t getMinimum(UCalendarDateFields field) const;
1049
1058 virtual int32_t getMaximum(EDateFields field) const;
1059
1068 virtual int32_t getMaximum(UCalendarDateFields field) const;
1069
1078 virtual int32_t getGreatestMinimum(EDateFields field) const;
1079
1088 virtual int32_t getGreatestMinimum(UCalendarDateFields field) const;
1089
1098 virtual int32_t getLeastMaximum(EDateFields field) const;
1099
1108 virtual int32_t getLeastMaximum(UCalendarDateFields field) const;
1109
1110#ifndef U_HIDE_DEPRECATED_API
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
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
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
1224#endif /* U_HIDE_DEPRECATED_API */
1225
1235
1236#ifndef U_HIDE_DEPRECATED_API
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
1314 void clear(EDateFields field);
1315#endif /* U_HIDE_DEPRECATED_API */
1316
1326
1342 virtual UClassID getDynamicClassID(void) const = 0;
1343
1376 virtual const char * getType() const = 0;
1377
1394
1409 virtual int32_t getWeekendTransition(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
1410
1420 virtual UBool isWeekend(UDate date, UErrorCode &status) const;
1421
1429 virtual UBool isWeekend(void) const;
1430
1431protected:
1432
1442
1449 Calendar(const Calendar& source);
1450
1458
1469 Calendar(TimeZone* zone, const Locale& aLocale, UErrorCode& success);
1470
1480 Calendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
1481
1490 virtual void computeTime(UErrorCode& status);
1491
1503 virtual void computeFields(UErrorCode& status);
1504
1514 double getTimeInMillis(UErrorCode& status) const;
1515
1524 void setTimeInMillis( double millis, UErrorCode& status );
1525
1535 void complete(UErrorCode& status);
1536
1537#ifndef U_HIDE_DEPRECATED_API
1546 inline int32_t internalGet(EDateFields field) const {return fFields[field];}
1547#endif /* U_HIDE_DEPRECATED_API */
1548
1549#ifndef U_HIDE_INTERNAL_API
1560 inline int32_t internalGet(UCalendarDateFields field, int32_t defaultValue) const {return fStamp[field]>kUnset ? fFields[field] : defaultValue;}
1561
1570 inline int32_t internalGet(UCalendarDateFields field) const {return fFields[field];}
1571#endif /* U_HIDE_INTERNAL_API */
1572
1573#ifndef U_HIDE_DEPRECATED_API
1583 void internalSet(EDateFields field, int32_t value);
1584#endif /* U_HIDE_DEPRECATED_API */
1585
1595 inline void internalSet(UCalendarDateFields field, int32_t value);
1596
1603 virtual void prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status);
1604
1610 UCAL_LIMIT_MINIMUM = 0,
1611 UCAL_LIMIT_GREATEST_MINIMUM,
1612 UCAL_LIMIT_LEAST_MAXIMUM,
1613 UCAL_LIMIT_MAXIMUM,
1614 UCAL_LIMIT_COUNT
1615 };
1616
1638 virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const = 0;
1639
1647 virtual int32_t getLimit(UCalendarDateFields field, ELimitType limitType) const;
1648
1649
1663 virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
1664 UBool useMonth) const = 0;
1665
1673 virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const ;
1674
1682 virtual int32_t handleGetYearLength(int32_t eyear) const;
1683
1684
1693 virtual int32_t handleGetExtendedYear() = 0;
1694
1704
1713 virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
1714
1715#ifndef U_HIDE_INTERNAL_API
1723
1732
1742 int32_t computeZoneOffset(double millis, int32_t millisInDay, UErrorCode &ec);
1743
1744
1753 int32_t newestStamp(UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const;
1754
1760 enum {
1765 };
1766
1773
1780
1787
1816#endif /* U_HIDE_INTERNAL_API */
1817
1818
1823
1824#ifndef U_HIDE_INTERNAL_API
1831#endif /* U_HIDE_INTERNAL_API */
1832
1833
1834private:
1843 int32_t getActualHelper(UCalendarDateFields field, int32_t startValue, int32_t endValue, UErrorCode &status) const;
1844
1845
1846protected:
1852
1864
1871
1880
1887 UDate internalGetTime(void) const { return fTime; }
1888
1896 void internalSetTime(UDate time) { fTime = time; }
1897
1903
1909
1913 enum {
1914 kUnset = 0,
1915 kInternallySet,
1916 kMinimumUserStamp
1917 };
1918
1926
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
1997 virtual int32_t getDefaultMonthInYear(int32_t eyear) ;
1998
1999
2007 virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month);
2008
2009 //-------------------------------------------------------------------------
2010 // Protected utility methods for use by subclasses. These are very handy
2011 // for implementing add, roll, and computeFields.
2012 //-------------------------------------------------------------------------
2013
2043 virtual void pinField(UCalendarDateFields field, UErrorCode& status);
2044
2088 int32_t weekNumber(int32_t desiredDay, int32_t dayOfPeriod, int32_t dayOfWeek);
2089
2090
2091#ifndef U_HIDE_INTERNAL_API
2122 inline int32_t weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek);
2123
2128 int32_t getLocalDOW();
2129#endif /* U_HIDE_INTERNAL_API */
2130
2131private:
2132
2136 int32_t fNextStamp;// = MINIMUM_USER_STAMP;
2137
2142 void recalculateStamp();
2143
2147 UDate fTime;
2148
2152 UBool fLenient;
2153
2158 TimeZone* fZone;
2159
2164 UCalendarWallTimeOption fRepeatedWallTime;
2165
2170 UCalendarWallTimeOption fSkippedWallTime;
2171
2180 UCalendarDaysOfWeek fFirstDayOfWeek;
2181 uint8_t fMinimalDaysInFirstWeek;
2182 UCalendarDaysOfWeek fWeekendOnset;
2183 int32_t fWeekendOnsetMillis;
2184 UCalendarDaysOfWeek fWeekendCease;
2185 int32_t fWeekendCeaseMillis;
2186
2197 void setWeekData(const Locale& desiredLocale, const char *type, UErrorCode& success);
2198
2208 void updateTime(UErrorCode& status);
2209
2215 int32_t fGregorianYear;
2216
2222 int32_t fGregorianMonth;
2223
2229 int32_t fGregorianDayOfYear;
2230
2236 int32_t fGregorianDayOfMonth;
2237
2238 /* calculations */
2239
2246 void computeGregorianAndDOWFields(int32_t julianDay, UErrorCode &ec);
2247
2248protected:
2249
2257 void computeGregorianFields(int32_t julianDay, UErrorCode &ec);
2258
2259private:
2260
2281 void computeWeekFields(UErrorCode &ec);
2282
2283
2292 void validateFields(UErrorCode &status);
2293
2302 virtual void validateField(UCalendarDateFields field, UErrorCode &status);
2303
2312 void validateField(UCalendarDateFields field, int32_t min, int32_t max, UErrorCode& status);
2313
2314 protected:
2315#ifndef U_HIDE_INTERNAL_API
2325 static uint8_t julianDayToDayOfWeek(double julian);
2326#endif /* U_HIDE_INTERNAL_API */
2327
2328 private:
2329 char validLocale[ULOC_FULLNAME_CAPACITY];
2330 char actualLocale[ULOC_FULLNAME_CAPACITY];
2331
2332 public:
2333#if !UCONFIG_NO_SERVICE
2337
2338#ifndef U_HIDE_INTERNAL_API
2346
2355 static URegistryKey registerFactory(ICUServiceFactory* toAdopt, UErrorCode& status);
2356
2368#endif /* U_HIDE_INTERNAL_API */
2369
2374 friend class CalendarFactory;
2375
2380 friend class CalendarService;
2381
2387#endif /* !UCONFIG_NO_SERVICE */
2388
2393 virtual UBool haveDefaultCentury() const = 0;
2394
2399 virtual UDate defaultCenturyStart() const = 0;
2404 virtual int32_t defaultCenturyStartYear() const = 0;
2405
2413
2414#ifndef U_HIDE_INTERNAL_API
2421 const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;
2422#endif /* U_HIDE_INTERNAL_API */
2423
2424private:
2429 BasicTimeZone* getBasicTimeZone() const;
2430};
2431
2432// -------------------------------------
2433
2434inline Calendar*
2436{
2437 // since the Locale isn't specified, use the default locale
2438 return createInstance(zone, Locale::getDefault(), errorCode);
2439}
2440
2441// -------------------------------------
2442
2443inline void
2445{
2446 roll(field, (int32_t)(up ? +1 : -1), status);
2447}
2448
2449#ifndef U_HIDE_DEPRECATED_API
2450inline void
2452{
2453 roll((UCalendarDateFields) field, up, status);
2454}
2455#endif
2456
2457
2458// -------------------------------------
2459
2464
2465inline void
2467{
2468 fFields[field] = value;
2469 fStamp[field] = kInternallySet;
2470 fIsSet[field] = TRUE; // Remove later
2471}
2472
2473
2474#ifndef U_HIDE_INTERNAL_API
2475inline int32_t Calendar::weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek)
2476{
2477 return weekNumber(dayOfPeriod, dayOfPeriod, dayOfWeek);
2478}
2479#endif
2480
2482
2483#endif /* #if !UCONFIG_NO_FORMATTING */
2484
2485#endif // _CALENDAR
int32_t UFieldResolutionTable[12][8]
Definition calendar.h:49
BasicTimeZone is an abstract class extending TimeZone.
Definition basictz.h:34
Calendar is an abstract base class for converting between a UDate object and a set of integer fields ...
Definition calendar.h:200
virtual int32_t getLeastMaximum(EDateFields field) const
Gets the lowest maximum value for the given field if varies.
virtual int32_t getMaximum(UCalendarDateFields field) const
Gets the maximum value for the given time field.
int32_t getLocalDOW()
returns the local DOW, valid range 0..6
void set(int32_t year, int32_t month, int32_t date)
Sets the values for the fields YEAR, MONTH, and DATE.
UCalendarDateFields resolveFields(const UFieldResolutionTable *precedenceTable)
Given a precedence table, return the newest field combination in the table, or UCAL_FIELD_COUNT if no...
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 ...
virtual UClassID getDynamicClassID(void) const =0
Returns a unique class ID POLYMORPHICALLY.
UCalendarWallTimeOption getSkippedWallTimeOption(void) const
Gets the behavior for handling skipped wall time at positive time zone offset transitions.
TimeZone * orphanTimeZone(void)
Returns the time zone owned by this calendar.
int32_t computeZoneOffset(double millis, int32_t millisInDay, UErrorCode &ec)
This method can assume EXTENDED_YEAR has been set.
Calendar(UErrorCode &success)
Constructs a Calendar with the default time zone as returned by TimeZone::createInstance(),...
virtual void handleComputeFields(int32_t julianDay, UErrorCode &status)
Subclasses may override this method to compute several fields specific to each calendar system.
void internalSet(EDateFields field, int32_t value)
Sets the value for a given time field.
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.
virtual int32_t getLimit(UCalendarDateFields field, ELimitType limitType) const
Return a limit for a field.
Calendar & operator=(const Calendar &right)
Default assignment operator.
UBool fAreFieldsVirtuallySet
True if all fields have been virtually set, but have not yet been computed.
Definition calendar.h:1879
static const UFieldResolutionTable kDOWPrecedence[]
Precedence table for Day of Week.
Definition calendar.h:1786
void setTimeZone(const TimeZone &zone)
Sets the calendar's time zone to be the same as the one passed in.
EMonths
Useful constants for month.
Definition calendar.h:267
EDaysOfWeek
Useful constant for days of week.
Definition calendar.h:253
virtual UBool operator==(const Calendar &that) const
Compares the equality of two Calendar objects.
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...
UCalendarDaysOfWeek getFirstDayOfWeek(UErrorCode &status) const
Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
int32_t internalGet(UCalendarDateFields field) const
Gets the value for a given time field.
Definition calendar.h:1570
int32_t internalGet(EDateFields field) const
Gets the value for a given time field.
Definition calendar.h:1546
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...
static UBool unregister(URegistryKey key, UErrorCode &status)
Unregister a previously-registered CalendarFactory using the key returned from the register call.
virtual ~Calendar()
destructor
virtual UBool isWeekend(void) const
Returns TRUE if this Calendar's current date-time is in the weekend in this calendar system.
virtual int32_t getDefaultMonthInYear(int32_t eyear)
Called by computeJulianDay.
Calendar(const TimeZone &zone, const Locale &aLocale, UErrorCode &success)
Constructs a Calendar with the given time zone and locale.
void setSkippedWallTimeOption(UCalendarWallTimeOption option)
Sets the behavior for handling skipped wall time at positive time zone offset transitions.
static const UFieldResolutionTable kDatePrecedence[]
Precedence table for Dates.
Definition calendar.h:1772
int32_t get(EDateFields field, UErrorCode &status) const
Gets the value for a given time field.
int32_t getActualMaximum(EDateFields field, UErrorCode &status) const
Return the maximum value that this field could have, given the current date.
virtual int32_t handleGetExtendedYear()=0
Return the extended year defined by the current fields.
int32_t fFields[UCAL_FIELD_COUNT]
The time fields containing values into which the millis is computed.
Definition calendar.h:1902
virtual int32_t getLeastMaximum(UCalendarDateFields field) const
Gets the lowest maximum value for the given field if varies.
void setTime(UDate date, UErrorCode &status)
Sets this Calendar's current time with the given UDate.
Definition calendar.h:453
virtual void add(EDateFields field, int32_t amount, UErrorCode &status)
UDate Arithmetic function.
static Calendar * createInstance(const Locale &aLocale, UErrorCode &success)
Creates a Calendar using the default timezone and the given locale.
void setTimeInMillis(double millis, UErrorCode &status)
Sets this Calendar's current time from the given long value.
virtual int32_t defaultCenturyStartYear() const =0
void internalSetTime(UDate time)
Set the current time without affecting flags or fields.
Definition calendar.h:1896
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.
UBool fIsSet[UCAL_FIELD_COUNT]
The flags which tell if a specified time field for the calendar is set.
Definition calendar.h:1908
void set(UCalendarDateFields field, int32_t value)
Sets the given time field with the given value.
int32_t getGregorianMonth() const
Return the month (0-based) on the Gregorian calendar as computed by computeGregorianFields().
Definition calendar.h:1968
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.
virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode &status) const
Return the maximum value that this field could have, given the current date.
virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode &status)
Time Field Rolling function.
UDate getTime(UErrorCode &status) const
Gets this Calendar's time as milliseconds.
Definition calendar.h:441
void computeGregorianFields(int32_t julianDay, UErrorCode &ec)
Compute the Gregorian calendar year, month, and day of month from the Julian day.
EDaysOfWeek getFirstDayOfWeek(void) const
Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
virtual void prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status)
Prepare this calendar for computing the actual minimum or maximum.
virtual const UFieldResolutionTable * getFieldResolutionTable() const
UBool fIsTimeSet
The flag which indicates if the current time is set in the calendar.
Definition calendar.h:1851
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.
int32_t getGregorianDayOfMonth() const
Return the day of month (1-based) on the Gregorian calendar as computed by computeGregorianFields().
Definition calendar.h:1986
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.
virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode &status)
UDate Arithmetic function.
virtual UDate defaultCenturyStart() const =0
virtual int32_t getGreatestMinimum(EDateFields field) const
Gets the highest minimum value for the given field if varies.
double getTimeInMillis(UErrorCode &status) const
Gets this Calendar's current time as a long.
friend class CalendarFactory
Multiple Calendar Implementation.
Definition calendar.h:2374
UBool before(const Calendar &when, UErrorCode &status) const
Returns true if this Calendar's current time is before "when"'s current time.
void setLenient(UBool lenient)
Specifies whether or not date/time interpretation is to be lenient.
void clear(void)
Clears the values of all the time fields, making them both unset and assigning them a value of zero.
static URegistryKey registerFactory(ICUServiceFactory *toAdopt, UErrorCode &status)
Register a new Calendar factory.
int32_t getActualMinimum(EDateFields field, UErrorCode &status) const
Return the minimum value that this field could have, given the current date.
virtual int32_t handleGetYearLength(int32_t eyear) const
Return the number of days in the given extended year of this calendar system.
virtual UBool inDaylightTime(UErrorCode &status) const =0
Queries if the current date for this Calendar is in Daylight Savings Time.
static StringEnumeration * getAvailableLocales(void)
INTERNAL FOR 2.6 – Registration.
int32_t get(UCalendarDateFields field, UErrorCode &status) const
Gets the value for a given time field.
UBool equals(const Calendar &when, UErrorCode &status) const
Compares the Calendar time, whereas Calendar::operator== compares the equality of Calendar objects.
UBool operator!=(const Calendar &that) const
Compares the inequality of two Calendar objects.
Definition calendar.h:476
virtual const char * getType() const =0
Returns the calendar type name string for this Calendar object.
int32_t computeMillisInDay()
Compute the milliseconds in the day from the fields.
virtual int32_t getMaximum(EDateFields field) const
Gets the maximum value for the given time field.
virtual int32_t getGreatestMinimum(UCalendarDateFields field) const
Gets the highest minimum value for the given field if varies.
void complete(UErrorCode &status)
Recomputes the current time from currently set fields, and then fills in any unset fields in the time...
UBool after(const Calendar &when, UErrorCode &status) const
Returns true if this Calendar's current time is after "when"'s current time.
static Calendar * createInstance(const TimeZone &zone, const Locale &aLocale, UErrorCode &success)
Gets a Calendar using the given timezone and given locale.
void set(EDateFields field, int32_t value)
Sets the given time field with the given value.
void roll(EDateFields field, UBool up, UErrorCode &status)
Time Field Rolling function.
Definition calendar.h:2451
EDateFields
Field IDs for date and time.
Definition calendar.h:209
static Calendar * createInstance(TimeZone *zoneToAdopt, const Locale &aLocale, UErrorCode &success)
Creates a Calendar using the given timezone and given locale.
virtual UBool isEquivalentTo(const Calendar &other) const
Returns TRUE if the given Calendar object is equivalent to this one.
UBool fAreAllFieldsSet
True if all of the fields have been set.
Definition calendar.h:1870
static UDate getNow(void)
Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70 (derived from the...
void clear(UCalendarDateFields field)
Clears the value in the given time field, both making it unset and assigning it a value of zero.
UBool isSet(UCalendarDateFields field) const
Determines if the given time field has a value set.
EAmpm
Useful constants for hour in 12-hour clock.
Definition calendar.h:287
UBool isLenient(void) const
Tells whether date/time interpretation is to be lenient.
void setFirstDayOfWeek(EDaysOfWeek value)
Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
static Calendar * createInstance(const TimeZone &zone, UErrorCode &success)
Creates a Calendar using the given timezone and the default locale.
UDate internalGetTime(void) const
Get the current time without recomputing.
Definition calendar.h:1887
virtual void roll(EDateFields field, int32_t amount, UErrorCode &status)
Time Field Rolling function.
int32_t weekNumber(int32_t desiredDay, int32_t dayOfPeriod, int32_t dayOfWeek)
Return the week number of a day, within a period.
virtual UBool isWeekend(UDate date, UErrorCode &status) const
Returns TRUE if the given UDate is in the weekend in this calendar system.
void clear(EDateFields field)
Clears the value in the given time field, both making it unset and assigning it a value of zero.
Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Get the locale for this calendar object.
static uint8_t julianDayToDayOfWeek(double julian)
Convert a quasi Julian date to the day of the week.
virtual int32_t getMinimum(EDateFields field) const
Gets the minimum value for the given time field.
Calendar(const Calendar &source)
Copy constructor.
int32_t getGregorianYear() const
Return the extended year on the Gregorian calendar as computed by computeGregorianFields().
Definition calendar.h:1959
virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month)
Called by computeJulianDay.
virtual void computeTime(UErrorCode &status)
Converts Calendar's time field values to GMT as milliseconds.
virtual int32_t getActualMinimum(UCalendarDateFields field, UErrorCode &status) const
Return the minimum value that this field could have, given the current date.
int32_t newestStamp(UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const
Determine the best stamp in a range.
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.
Calendar(TimeZone *zone, const Locale &aLocale, UErrorCode &success)
Constructs a Calendar with the given time zone and locale.
virtual void computeFields(UErrorCode &status)
Converts GMT as milliseconds to time field values.
void setFirstDayOfWeek(UCalendarDaysOfWeek value)
Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
int32_t computeJulianDay()
Compute the Julian day from fields.
void setMinimalDaysInFirstWeek(uint8_t value)
Sets what the minimal days required in the first week of the year are; For example,...
const TimeZone & getTimeZone(void) const
Returns a reference to the time zone owned by this calendar.
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...
int32_t internalGet(UCalendarDateFields field, int32_t defaultValue) const
Gets the value for a given time field.
Definition calendar.h:1560
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...
static Calendar * createInstance(UErrorCode &success)
Creates a Calendar using the default timezone and locale.
static const UFieldResolutionTable kYearPrecedence[]
Precedence table for Year.
Definition calendar.h:1779
int32_t getGregorianDayOfYear() const
Return the day of year (1-based) on the Gregorian calendar as computed by computeGregorianFields().
Definition calendar.h:1977
int32_t fStamp[UCAL_FIELD_COUNT]
Pseudo-time-stamps which specify when each field was set.
Definition calendar.h:1925
virtual Calendar * clone(void) const =0
Create and return a polymorphic copy of this calendar.
virtual UBool haveDefaultCentury() const =0
@ kResolveSTOP
Marker for end of resolve set (row or group).
Definition calendar.h:1762
@ kResolveRemap
Value to be bitwised "ORed" against resolve table field values for remapping.
Definition calendar.h:1764
void setRepeatedWallTimeOption(UCalendarWallTimeOption option)
Sets the behavior for handling wall time repeating multiple times at negative time zone offset transi...
ELimitType
Limit enums.
Definition calendar.h:1609
friend class CalendarService
Multiple Calendar Implementation.
Definition calendar.h:2380
UBool isSet(EDateFields field) const
Determines if the given time field has a value set.
void adoptTimeZone(TimeZone *value)
Sets the calendar's time zone to be the one passed in.
UBool fAreFieldsSet
True if the fields are in sync with the currently set time of this Calendar.
Definition calendar.h:1863
static const Locale * getAvailableLocales(int32_t &count)
Returns a list of the locales for which Calendars are installed.
virtual int32_t getMinimum(UCalendarDateFields field) const
Gets the minimum value for the given time field.
UCalendarWallTimeOption getRepeatedWallTimeOption(void) const
Gets the behavior for handling wall time repeating multiple times at negative time zone offset transi...
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...
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const =0
Subclass API for defining limits of different types.
virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField)
Subclasses may override this.
const char * getLocaleID(ULocDataLocaleType type, UErrorCode &status) const
Get the locale for this calendar object.
UCalendarDateFields newerField(UCalendarDateFields defaultField, UCalendarDateFields alternateField) const
Return the field that is newer, either defaultField, or alternateField.
friend class DefaultCalendarFactory
Multiple Calendar Implementation.
Definition calendar.h:2386
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:182
static const Locale & getDefault(void)
Common methods of getting the current default Locale.
Base class for 'pure' C++ implementations of uenum api.
Definition strenum.h:55
TimeZone represents a time zone offset, and also figures out daylight savings.
Definition timezone.h:129
UObject is the common ICU "boilerplate" class.
Definition uobject.h:229
C++ API: Locale ID object.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
C++ API: TimeZone object.
C API: Calendar.
UCalendarDateFields
Possible fields in a UCalendar.
Definition ucal.h:183
@ UCAL_FIELD_COUNT
Field count.
Definition ucal.h:430
UCalendarWallTimeOption
Options for handling ambiguous wall time at time zone offset transitions.
Definition ucal.h:890
UCalendarWeekdayType
Weekday types, as returned by ucal_getDayOfWeekType().
Definition ucal.h:1327
UCalendarDaysOfWeek
Useful constant for days of week.
Definition ucal.h:453
#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:262
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition uloc.h:336
int8_t UBool
The ICU boolean type.
Definition umachine.h:200
#define TRUE
The TRUE value of a UBool.
Definition umachine.h:204
C API:misc definitions.
const void * URegistryKey
Opaque type returned by registerInstance, registerFactory and unregister for service registration.
Definition umisc.h:55
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:476
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:358
double UDate
Date and Time data type.
Definition utypes.h:201
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129