|
ICU 72.1 72.1
|
Calendar is an abstract base class for converting between a UDate object and a set of integer fields such as YEAR, MONTH, DAY, HOUR, and so on.
More...
#include <calendar.h>
Public Types | |
| enum | EDateFields { ERA , YEAR , MONTH , WEEK_OF_YEAR , WEEK_OF_MONTH , DATE , DAY_OF_YEAR , DAY_OF_WEEK , DAY_OF_WEEK_IN_MONTH , AM_PM , HOUR , HOUR_OF_DAY , MINUTE , SECOND , MILLISECOND , ZONE_OFFSET , DST_OFFSET , YEAR_WOY , DOW_LOCAL , EXTENDED_YEAR , JULIAN_DAY , MILLISECONDS_IN_DAY , IS_LEAP_MONTH , FIELD_COUNT = UCAL_FIELD_COUNT } |
| Field IDs for date and time. More... | |
| enum | EDaysOfWeek { SUNDAY = 1 , MONDAY , TUESDAY , WEDNESDAY , THURSDAY , FRIDAY , SATURDAY } |
| Useful constant for days of week. More... | |
| enum | EMonths { JANUARY , FEBRUARY , MARCH , APRIL , MAY , JUNE , JULY , AUGUST , SEPTEMBER , OCTOBER , NOVEMBER , DECEMBER , UNDECIMBER } |
| Useful constants for month. More... | |
| enum | EAmpm { AM , PM } |
| Useful constants for hour in 12-hour clock. More... | |
Public Member Functions | |
| virtual | ~Calendar () |
| destructor More... | |
| virtual Calendar * | clone () const =0 |
| Create and return a polymorphic copy of this calendar. More... | |
| UDate | getTime (UErrorCode &status) const |
| Gets this Calendar's time as milliseconds. More... | |
| void | setTime (UDate date, UErrorCode &status) |
| Sets this Calendar's current time with the given UDate. More... | |
| virtual bool | operator== (const Calendar &that) const |
| Compares the equality of two Calendar objects. More... | |
| bool | operator!= (const Calendar &that) const |
| Compares the inequality of two Calendar objects. More... | |
| virtual UBool | isEquivalentTo (const Calendar &other) const |
| Returns true if the given Calendar object is equivalent to this one. More... | |
| UBool | equals (const Calendar &when, UErrorCode &status) const |
| Compares the Calendar time, whereas Calendar::operator== compares the equality of Calendar objects. More... | |
| UBool | before (const Calendar &when, UErrorCode &status) const |
| Returns true if this Calendar's current time is before "when"'s current time. More... | |
| UBool | after (const Calendar &when, UErrorCode &status) const |
| Returns true if this Calendar's current time is after "when"'s current time. More... | |
| virtual void | add (EDateFields field, int32_t amount, UErrorCode &status) |
| UDate Arithmetic function. More... | |
| virtual void | add (UCalendarDateFields field, int32_t amount, UErrorCode &status) |
| UDate Arithmetic function. More... | |
| void | roll (EDateFields field, UBool up, UErrorCode &status) |
| Time Field Rolling function. More... | |
| void | roll (UCalendarDateFields field, UBool up, UErrorCode &status) |
| Time Field Rolling function. More... | |
| virtual void | roll (EDateFields field, int32_t amount, UErrorCode &status) |
| Time Field Rolling function. More... | |
| virtual void | roll (UCalendarDateFields field, int32_t amount, UErrorCode &status) |
| Time Field Rolling function. More... | |
| 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. More... | |
| 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. More... | |
| void | adoptTimeZone (TimeZone *value) |
| Sets the calendar's time zone to be the one passed in. More... | |
| void | setTimeZone (const TimeZone &zone) |
| Sets the calendar's time zone to be the same as the one passed in. More... | |
| const TimeZone & | getTimeZone (void) const |
| Returns a reference to the time zone owned by this calendar. More... | |
| TimeZone * | orphanTimeZone (void) |
| Returns the time zone owned by this calendar. More... | |
| virtual UBool | inDaylightTime (UErrorCode &status) const =0 |
| Queries if the current date for this Calendar is in Daylight Savings Time. More... | |
| void | setLenient (UBool lenient) |
| Specifies whether or not date/time interpretation is to be lenient. More... | |
| UBool | isLenient (void) const |
| Tells whether date/time interpretation is to be lenient. More... | |
| void | setRepeatedWallTimeOption (UCalendarWallTimeOption option) |
| Sets the behavior for handling wall time repeating multiple times at negative time zone offset transitions. More... | |
| UCalendarWallTimeOption | getRepeatedWallTimeOption (void) const |
| Gets the behavior for handling wall time repeating multiple times at negative time zone offset transitions. More... | |
| void | setSkippedWallTimeOption (UCalendarWallTimeOption option) |
| Sets the behavior for handling skipped wall time at positive time zone offset transitions. More... | |
| UCalendarWallTimeOption | getSkippedWallTimeOption (void) const |
| Gets the behavior for handling skipped wall time at positive time zone offset transitions. More... | |
| void | setFirstDayOfWeek (UCalendarDaysOfWeek value) |
| Sets what the first day of the week is; e.g., Sunday in US, Monday in France. More... | |
| EDaysOfWeek | getFirstDayOfWeek (void) const |
| Gets what the first day of the week is; e.g., Sunday in US, Monday in France. More... | |
| UCalendarDaysOfWeek | getFirstDayOfWeek (UErrorCode &status) const |
| Gets what the first day of the week is; e.g., Sunday in US, Monday in France. More... | |
| void | setMinimalDaysInFirstWeek (uint8_t value) |
| Sets what the minimal days required in the first week of the year are; For example, if the first week is defined as one that contains the first day of the first month of a year, call the method with value 1. More... | |
| 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 defined as one that contains the first day of the first month of a year, getMinimalDaysInFirstWeek returns 1. More... | |
| virtual int32_t | getMinimum (EDateFields field) const |
| Gets the minimum value for the given time field. More... | |
| virtual int32_t | getMinimum (UCalendarDateFields field) const |
| Gets the minimum value for the given time field. More... | |
| virtual int32_t | getMaximum (EDateFields field) const |
| Gets the maximum value for the given time field. More... | |
| virtual int32_t | getMaximum (UCalendarDateFields field) const |
| Gets the maximum value for the given time field. More... | |
| virtual int32_t | getGreatestMinimum (EDateFields field) const |
| Gets the highest minimum value for the given field if varies. More... | |
| virtual int32_t | getGreatestMinimum (UCalendarDateFields field) const |
| Gets the highest minimum value for the given field if varies. More... | |
| virtual int32_t | getLeastMaximum (EDateFields field) const |
| Gets the lowest maximum value for the given field if varies. More... | |
| virtual int32_t | getLeastMaximum (UCalendarDateFields field) const |
| Gets the lowest maximum value for the given field if varies. More... | |
| int32_t | getActualMinimum (EDateFields field, UErrorCode &status) const |
| Return the minimum value that this field could have, given the current date. More... | |
| virtual int32_t | getActualMinimum (UCalendarDateFields field, UErrorCode &status) const |
| Return the minimum value that this field could have, given the current date. More... | |
| virtual int32_t | getActualMaximum (UCalendarDateFields field, UErrorCode &status) const |
| Return the maximum value that this field could have, given the current date. More... | |
| int32_t | get (UCalendarDateFields field, UErrorCode &status) const |
| Gets the value for a given time field. More... | |
| UBool | isSet (UCalendarDateFields field) const |
| Determines if the given time field has a value set. More... | |
| void | set (UCalendarDateFields field, int32_t value) |
| Sets the given time field with the given value. More... | |
| void | set (int32_t year, int32_t month, int32_t date) |
| Sets the values for the fields YEAR, MONTH, and DATE. More... | |
| 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. More... | |
| 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. More... | |
| void | clear (void) |
| Clears the values of all the time fields, making them both unset and assigning them a value of zero. More... | |
| void | clear (UCalendarDateFields field) |
| Clears the value in the given time field, both making it unset and assigning it a value of zero. More... | |
| virtual UClassID | getDynamicClassID (void) const override=0 |
| Returns a unique class ID POLYMORPHICALLY. More... | |
| virtual const char * | getType () const =0 |
| Returns the calendar type name string for this Calendar object. More... | |
| 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 one to the other, for the locale and calendar system associated with this Calendar (the locale's region is often the most determinant factor). More... | |
| 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. More... | |
| virtual UBool | isWeekend (UDate date, UErrorCode &status) const |
| Returns true if the given UDate is in the weekend in this calendar system. More... | |
| virtual UBool | isWeekend (void) const |
| Returns true if this Calendar's current date-time is in the weekend in this calendar system. More... | |
| virtual UBool | haveDefaultCentury () const =0 |
| virtual UDate | defaultCenturyStart () const =0 |
| virtual int32_t | defaultCenturyStartYear () const =0 |
| Locale | getLocale (ULocDataLocaleType type, UErrorCode &status) const |
| Get the locale for this calendar object. More... | |
| virtual int32_t | getRelatedYear (UErrorCode &status) const |
| virtual void | setRelatedYear (int32_t year) |
| const char * | getLocaleID (ULocDataLocaleType type, UErrorCode &status) const |
| Get the locale for this calendar object. More... | |
Public Member Functions inherited from icu::UObject | |
| virtual | ~UObject () |
| Destructor. More... | |
| virtual UClassID | getDynamicClassID () const |
| ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class. More... | |
Static Public Member Functions | |
| static Calendar * | createInstance (UErrorCode &success) |
| Creates a Calendar using the default timezone and locale. More... | |
| static Calendar * | createInstance (TimeZone *zoneToAdopt, UErrorCode &success) |
| Creates a Calendar using the given timezone and the default locale. More... | |
| static Calendar * | createInstance (const TimeZone &zone, UErrorCode &success) |
| Creates a Calendar using the given timezone and the default locale. More... | |
| static Calendar * | createInstance (const Locale &aLocale, UErrorCode &success) |
| Creates a Calendar using the default timezone and the given locale. More... | |
| static Calendar * | createInstance (TimeZone *zoneToAdopt, const Locale &aLocale, UErrorCode &success) |
| Creates a Calendar using the given timezone and given locale. More... | |
| static Calendar * | createInstance (const TimeZone &zone, const Locale &aLocale, UErrorCode &success) |
| Gets a Calendar using the given timezone and given locale. More... | |
| static const Locale * | getAvailableLocales (int32_t &count) |
| Returns a list of the locales for which Calendars are installed. More... | |
| 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 difference. More... | |
| static UDate | getNow (void) |
| Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70 (derived from the system time). More... | |
| static StringEnumeration * | getAvailableLocales (void) |
| INTERNAL FOR 2.6 – Registration. More... | |
| static URegistryKey | registerFactory (ICUServiceFactory *toAdopt, UErrorCode &status) |
| Register a new Calendar factory. More... | |
| static UBool | unregister (URegistryKey key, UErrorCode &status) |
| Unregister a previously-registered CalendarFactory using the key returned from the register call. More... | |
| static Calendar * | makeInstance (const Locale &locale, UErrorCode &status) |
| Creates a new Calendar from a Locale for the cache. More... | |
| static void | getCalendarTypeFromLocale (const Locale &locale, char *typeBuffer, int32_t typeBufferSize, UErrorCode &status) |
| Get the calendar type for given locale. More... | |
Protected Types | |
| enum | ELimitType { UCAL_LIMIT_MINIMUM = 0 , UCAL_LIMIT_GREATEST_MINIMUM , UCAL_LIMIT_LEAST_MAXIMUM , UCAL_LIMIT_MAXIMUM , UCAL_LIMIT_COUNT } |
| Limit enums. More... | |
| enum | { kUnset = 0 , kInternallySet , kMinimumUserStamp } |
| Special values of stamp[]. More... | |
Protected Member Functions | |
| Calendar (UErrorCode &success) | |
| Constructs a Calendar with the default time zone as returned by TimeZone::createInstance(), and the default locale. More... | |
| Calendar (const Calendar &source) | |
| Copy constructor. More... | |
| Calendar & | operator= (const Calendar &right) |
| Default assignment operator. More... | |
| Calendar (TimeZone *zone, const Locale &aLocale, UErrorCode &success) | |
| Constructs a Calendar with the given time zone and locale. More... | |
| Calendar (const TimeZone &zone, const Locale &aLocale, UErrorCode &success) | |
| Constructs a Calendar with the given time zone and locale. More... | |
| virtual void | computeTime (UErrorCode &status) |
| Converts Calendar's time field values to GMT as milliseconds. More... | |
| virtual void | computeFields (UErrorCode &status) |
| Converts GMT as milliseconds to time field values. More... | |
| double | getTimeInMillis (UErrorCode &status) const |
| Gets this Calendar's current time as a long. More... | |
| void | setTimeInMillis (double millis, UErrorCode &status) |
| Sets this Calendar's current time from the given long value. More... | |
| void | complete (UErrorCode &status) |
| Recomputes the current time from currently set fields, and then fills in any unset fields in the time field list. More... | |
| int32_t | internalGet (EDateFields field) const |
| Gets the value for a given time field. More... | |
| int32_t | internalGet (UCalendarDateFields field, int32_t defaultValue) const |
| Gets the value for a given time field. More... | |
| int32_t | internalGet (UCalendarDateFields field) const |
| Gets the value for a given time field. More... | |
| void | internalSet (EDateFields field, int32_t value) |
| Sets the value for a given time field. More... | |
| void | internalSet (UCalendarDateFields field, int32_t value) |
| Sets the value for a given time field. More... | |
| virtual void | prepareGetActual (UCalendarDateFields field, UBool isMinimum, UErrorCode &status) |
| Prepare this calendar for computing the actual minimum or maximum. More... | |
| virtual int32_t | handleGetLimit (UCalendarDateFields field, ELimitType limitType) const =0 |
| Subclass API for defining limits of different types. More... | |
| virtual int32_t | getLimit (UCalendarDateFields field, ELimitType limitType) const |
| Return a limit for a field. More... | |