Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

Calendar Class Reference

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>

Inheritance diagram for Calendar:

UObject UMemory GregorianCalendar

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, FIELD_COUNT,
  DAY_OF_MONTH = DATE
}
 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 ICU 2.0

virtual Calendarclone (void) const=0
 Create and return a polymorphic copy of this calendar.

UDate getTime (UErrorCode &status) const
 Gets this Calendar's time as milliseconds.

void setTime (UDate date, UErrorCode &status)
 Sets this Calendar's current time with the given UDate.

virtual UBool operator== (const Calendar &that) const
 Compares the equality of two Calendar objects.

UBool operator!= (const Calendar &that) const
 Compares the inequality of two Calendar objects.

virtual UBool isEquivalentTo (const Calendar &other) const
 Returns TRUE if the given Calendar object is equivalent to this one.

UBool equals (const Calendar &when, UErrorCode &status) const
 Compares the Calendar time, whereas Calendar::operator== compares the equality of Calendar objects.

UBool before (const Calendar &when, UErrorCode &status) const
 Returns true if this Calendar's current time is before "when"'s current time.

UBool after (const Calendar &when, UErrorCode &status) const
 Returns true if this Calendar's current time is after "when"'s current time.

virtual void add (EDateFields field, int32_t amount, UErrorCode &status)=0
 UDate Arithmetic function.

virtual void add (UCalendarDateFields field, int32_t amount, UErrorCode &status)=0
 UDate Arithmetic function.

void roll (EDateFields field, UBool up, UErrorCode &status)
 Time Field Rolling function.

void roll (UCalendarDateFields field, UBool up, UErrorCode &status)
 Time Field Rolling function.

virtual void roll (EDateFields field, int32_t amount, UErrorCode &status)=0
 Time Field Rolling function.

virtual void roll (UCalendarDateFields field, int32_t amount, UErrorCode &status)=0
 Time Field Rolling function.

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.

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.

void adoptTimeZone (TimeZone *value)
 Sets the calendar's time zone to be the one passed in.

void setTimeZone (const TimeZone &zone)
 Sets the calendar's time zone to be the same as the one passed in.

const TimeZonegetTimeZone (void) const
 Returns a reference to the time zone owned by this calendar.

TimeZoneorphanTimeZone (void)
 Returns the time zone owned by this calendar.

virtual UBool inDaylightTime (UErrorCode &status) const=0
 Queries if the current date for this Calendar is in Daylight Savings Time.

void setLenient (UBool lenient)
 Specifies whether or not date/time interpretation is to be lenient.

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.

void setFirstDayOfWeek (UCalendarDaysOfWeek value)
 Sets what the first day of the week is; e.g., Sunday in US, Monday in France.

EDaysOfWeek getFirstDayOfWeek (void) const
 Gets what the first day of the week is; e.g., Sunday in US, Monday in France.

UCalendarDaysOfWeek getFirstDayOfWeek (UErrorCode &status) const
 Gets what the first day of the week is; e.g., Sunday in US, Monday in France.

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.

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.

virtual int32_t getMinimum (EDateFields field) const=0
 Gets the minimum value for the given time field.

virtual int32_t getMinimum (UCalendarDateFields field) const=0
 Gets the minimum value for the given time field.

virtual int32_t getMaximum (EDateFields field) const=0
 Gets the maximum value for the given time field.

virtual int32_t getMaximum (UCalendarDateFields field) const=0
 Gets the maximum value for the given time field.

virtual int32_t getGreatestMinimum (EDateFields field) const=0
 Gets the highest minimum value for the given field if varies.

virtual int32_t getGreatestMinimum (UCalendarDateFields field) const=0
 Gets the highest minimum value for the given field if varies.

virtual int32_t getLeastMaximum (EDateFields field) const=0
 Gets the lowest maximum value for the given field if varies.

virtual int32_t getLeastMaximum (UCalendarDateFields field) const=0
 Gets the lowest maximum value for the given field if varies.

int32_t getActualMinimum (EDateFields field, UErrorCode &status) const
 Return the minimum value that this field could have, given the current date.

int32_t getActualMinimum (UCalendarDateFields field, UErrorCode &status) const
 Return the minimum value that this field could have, given the current date.

int32_t getActualMaximum (EDateFields field, UErrorCode &status) const
 Return the maximum value that this field could have, given the current date.

int32_t getActualMaximum (UCalendarDateFields field, UErrorCode &status) const
 Return the maximum value that this field could have, given the current date.

int32_t get (EDateFields field, UErrorCode &status) const
 Gets the value for a given time field.

int32_t get (UCalendarDateFields field, UErrorCode &status) const
 Gets the value for a given time field.

UBool isSet (EDateFields field) const
 Determines if the given time field has a value set.

UBool isSet (UCalendarDateFields field) const
 Determines if the given time field has a value set.

void set (EDateFields field, int32_t value)
 Sets the given time field with the given value.

void set (UCalendarDateFields field, int32_t value)
 Sets the given time field with the given value.

void set (int32_t year, int32_t month, int32_t date)
 Sets the values for the fields YEAR, MONTH, and DATE.

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.

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.

void clear (void)
 Clears the values of all the time fields, making them both unset and assigning them a value of zero.

void clear (EDateFields field)
 Clears the value in the given time field, both making it unset and assigning it a value of zero.

void clear (UCalendarDateFields field)
 Clears the value in the given time field, both making it unset and assigning it a value of zero.

virtual UClassID getDynamicClassID (void) const=0
 Returns a unique class ID POLYMORPHICALLY.

virtual const char * getType () const=0
 Returns the resource key string used for this calendar type.

virtual UBool haveDefaultCentury () const=0
virtual UDate defaultCenturyStart () const=0
virtual int32_t defaultCenturyStartYear () const=0

Static Public Member Functions

CalendarcreateInstance (UErrorCode &success)
 Creates a Calendar using the default timezone and locale.

CalendarcreateInstance (TimeZone *zoneToAdopt, UErrorCode &success)
 Creates a Calendar using the given timezone and the default locale.

CalendarcreateInstance (const TimeZone &zone, UErrorCode &success)
 Creates a Calendar using the given timezone and the default locale.

CalendarcreateInstance (const Locale &aLocale, UErrorCode &success)
 Creates a Calendar using the default timezone and the given locale.

CalendarcreateInstance (TimeZone *zoneToAdopt, const Locale &aLocale, UErrorCode &success)
 Creates a Calendar using the given timezone and given locale.

CalendarcreateInstance (const TimeZone &zoneToAdopt, const Locale &aLocale, UErrorCode &success)
 Gets a Calendar using the given timezone and given locale.

const LocalegetAvailableLocales (int32_t &count)
 Returns a list of the locales for which Calendars are installed.

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).

StringEnumerationgetAvailableLocales (void)
 Return a StringEnumeration over the locales available at the time of the call, including registered locales.

URegistryKey registerFactory (ICUServiceFactory *toAdopt, UErrorCode &status)
 Register a new Calendar factory.

UBool unregister (URegistryKey key, UErrorCode &status)
 Unregister a previously-registered CalendarFactory using the key returned from the register call.


Protected Types

enum  { kUnset = 0, kInternallySet, kMinimumUserStamp }
 Special values of stamp[] ICU 2.0.


Protected Member Functions

 Calendar (UErrorCode &success)
 Constructs a Calendar with the default time zone as returned by TimeZone::createInstance(), and the default locale.

 Calendar (const Calendar &source)
 Copy constructor.

Calendaroperator= (const Calendar &right)
 Default assignment operator.

 Calendar (TimeZone *zone, const Locale &aLocale, UErrorCode &success)
 Constructs a Calendar with the given time zone and locale.

 Calendar (const TimeZone &zone, const Locale &aLocale, UErrorCode &success)
 Constructs a Calendar with the given time zone and locale.

virtual void computeTime (UErrorCode &status)=0
 Converts Calendar's time field values to GMT as milliseconds.

virtual void computeFields (UErrorCode &status)=0
 Converts GMT as milliseconds to time field values.

double getTimeInMillis (UErrorCode &status) const
 Gets this Calendar's current time as a long.

void setTimeInMillis (double millis, UErrorCode &status)
 Sets this Calendar's current time from the given long value.

void complete (UErrorCode &status)
 Recomputes the current time from currently set fields, and then fills in any unset fields in the time field list.

int32_t internalGet (EDateFields field) const
 Gets the value for a given time field.

int32_t internalGet (UCalendarDateFields field) const
 Gets the value for a given time field.

void internalSet (EDateFields field, int32_t value)
 Sets the value for a given time field.

void internalSet (UCalendarDateFields field, int32_t value)
 Sets the value for a given time field.

UDate internalGetTime (void) const
 Get the current time without recomputing.

void internalSetTime (UDate time)
 Set the current time without affecting flags or fields.


Protected Attributes

UBool fIsTimeSet
 The flag which indicates if the current time is set in the calendar.

UBool fAreFieldsSet
 True if the fields are in sync with the currently set time of this Calendar.

UBool fAreAllFieldsSet
 True if all of the fields have been set.

int32_t fFields [UCAL_FIELD_COUNT]
 The time fields containing values into which the millis is computed.

UBool fIsSet [UCAL_FIELD_COUNT]
 The flags which tell if a specified time field for the calendar is set.

int32_t fStamp [UCAL_FIELD_COUNT]
 Pseudo-time-stamps which specify when each field was set.


Friends

class CalendarFactory
 Multiple Calendar Implementation.

class CalendarService
 Multiple Calendar Implementation.

class DefaultCalendarFactory
 Multiple Calendar Implementation.


Detailed Description

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.

(A UDate object represents a specific instant in time with millisecond precision. See UDate for information about the UDate class.)

Subclasses of Calendar interpret a UDate according to the rules of a specific calendar system. The most commonly used subclass of Calendar is GregorianCalendar. Other subclasses could represent the various types of lunar calendars in use in many parts of the world.

NOTE: (ICU 2.6) The subclass interface should be considered unstable

Like other locale-sensitive classes, Calendar provides a static method, createInstance, for getting a generally useful object of this type. Calendar's createInstance method returns the appropriate Calendar subclass whose time fields have been initialized with the current date and time:

Calendar *rightNow = Calendar::createInstance(errCode);

A Calendar object can produce all the time field values needed to implement the date-time formatting for a particular language and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).

When computing a UDate from time fields, two special circumstances may arise: there may be insufficient information to compute the UDate (such as only year and month but no day in the month), or there may be inconsistent information (such as "Tuesday, July 15, 1996" -- July 15, 1996 is actually a Monday).

Insufficient information. The calendar will use default information to specify the missing fields. This may vary by calendar; for the Gregorian calendar, the default for a field is the same as that of the start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc.

Inconsistent information. If fields conflict, the calendar will give preference to fields set more recently. For example, when determining the day, the calendar will look for one of the following combinations of fields. The most recent combination, as determined by the most recently set single field, will be used.

MONTH + DAY_OF_MONTH MONTH + WEEK_OF_MONTH + DAY_OF_WEEK MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK DAY_OF_YEAR DAY_OF_WEEK + WEEK_OF_YEAR

For the time of day:

HOUR_OF_DAY AM_PM + HOUR

Note: for some non-Gregorian calendars, different fields may be necessary for complete disambiguation. For example, a full specification of the historial Arabic astronomical calendar requires year, month, day-of-month and day-of-week in some cases.

Note: There are certain possible ambiguities in interpretation of certain singular times, which are resolved in the following ways:

  1. 24:00:00 "belongs" to the following day. That is, 23:59 on Dec 31, 1969 < 24:00 on Jan 1, 1970 < 24:01:00 on Jan 1, 1970

  2. Although historically not precise, midnight also belongs to "am", and noon belongs to "pm", so on the same day, 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm

The date or time format strings are not part of the definition of a calendar, as those must be modifiable or overridable by the user at runtime. Use DateFormat to format dates.

Calendar provides an API for field "rolling", where fields can be incremented or decremented, but wrap around. For example, rolling the month up in the date December 12, 1996 results in January 12, 1996.

Calendar also provides a date arithmetic function for adding the specified (signed) amount of time to a particular time field. For example, subtracting 5 days from the date September 12, 1996 results in September 7, 1996.

ICU 2.0


Member Enumeration Documentation

enum Calendar::EAmpm
 

Useful constants for hour in 12-hour clock.

Used in GregorianCalendar.

Deprecated:
ICU 2.6. Use C enum UCalendarAMPMs defined in ucal.h

enum Calendar::EDateFields
 

Field IDs for date and time.

Used to specify date/time fields. ERA is calendar specific. Example ranges given are for illustration only; see specific Calendar subclasses for actual ranges.

Deprecated:
ICU 2.6. Use C enum UCalendarDateFields defined in ucal.h

enum Calendar::EDaysOfWeek
 

Useful constant for days of week.

Note: Calendar day-of-week is 1-based. Clients who create locale resources for the field of first-day-of-week should be aware of this. For instance, in US locale, first-day-of-week is set to 1, i.e., SUNDAY.

Deprecated:
ICU 2.6. Use C enum UCalendarDaysOfWeek defined in ucal.h

enum Calendar::EMonths
 

Useful constants for month.

Note: Calendar month is 0-based.

Deprecated:
ICU 2.6. Use C enum UCalendarMonths defined in ucal.h


Constructor & Destructor Documentation

Calendar::Calendar UErrorCode success  )  [protected]
 

Constructs a Calendar with the default time zone as returned by TimeZone::createInstance(), and the default locale.

Parameters:
success Indicates the status of Calendar object construction. Returns U_ZERO_ERROR if constructed successfully. ICU 2.0

Calendar::Calendar const Calendar source  )  [protected]
 

Copy constructor.

Parameters:
source Calendar object to be copied from ICU 2.0

Calendar::Calendar TimeZone zone,
const Locale aLocale,
UErrorCode success
[protected]
 

Constructs a Calendar with the given time zone and locale.

Clients are no longer responsible for deleting the given time zone object after it's adopted.

Parameters:
zone The given time zone.
aLocale The given locale.
success Indicates the status of Calendar object construction. Returns U_ZERO_ERROR if constructed successfully. ICU 2.0

Calendar::Calendar const TimeZone zone,
const Locale aLocale,
UErrorCode success
[protected]
 

Constructs a Calendar with the given time zone and locale.

Parameters:
zone The given time zone.
aLocale The given locale.
success Indicates the status of Calendar object construction. Returns U_ZERO_ERROR if constructed successfully. ICU 2.0


Member Function Documentation

virtual void Calendar::add UCalendarDateFields  field,
int32_t  amount,
UErrorCode status
[pure virtual]
 

UDate Arithmetic function.

Adds the specified (signed) amount of time to the given time field, based on the calendar's rules. For example, to subtract 5 days from the current time of the calendar, call add(Calendar::DATE, -5). When adding on the month or Calendar::MONTH field, other fields like date might conflict and need to be changed. For instance, adding 1 month on the date 01/31/96 will result in 02/29/96.

Parameters:
field Specifies which date field to modify.
amount The amount of time to be added to the field, in the natural unit for that field (e.g., days for the day fields, hours for the hour field.)
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status. ICU 2.6.

Implemented in GregorianCalendar.

virtual void Calendar::add EDateFields  field,
int32_t  amount,
UErrorCode status
[pure virtual]
 

UDate Arithmetic function.

Adds the specified (signed) amount of time to the given time field, based on the calendar's rules. For example, to subtract 5 days from the current time of the calendar, call add(Calendar::DATE, -5). When adding on the month or Calendar::MONTH field, other fields like date might conflict and need to be changed. For instance, adding 1 month on the date 01/31/96 will result in 02/29/96.

Parameters:
field Specifies which date field to modify.
amount The amount of time to be added to the field, in the natural unit for that field (e.g., days for the day fields, hours for the hour field.)
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status.
Deprecated:
ICU 2.6. use add(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.

Implemented in GregorianCalendar.

void Calendar::adoptTimeZone TimeZone value  ) 
 

Sets the calendar's time zone to be the one passed in.

The Calendar takes ownership of the TimeZone; the caller is no longer responsible for deleting it. If the given time zone is NULL, this function has no effect.

Parameters:
value The given time zone. ICU 2.0

UBool Calendar::after const Calendar when,
UErrorCode status
const
 

Returns true if this Calendar's current time is after "when"'s current time.

Parameters:
when The Calendar to be compared with this Calendar. Although this is a const parameter, the object may be modified physically (semantically const).
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status.
Returns:
True if the current time of this Calendar is after the time of Calendar when; false otherwise. ICU 2.0

UBool Calendar::before const Calendar when,
UErrorCode status
const
 

Returns true if this Calendar's current time is before "when"'s current time.

Parameters:
when The Calendar to be compared with this Calendar. Although this is a const parameter, the object may be modified physically (semantically const).
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status.
Returns:
True if the current time of this Calendar is before the time of Calendar when; false otherwise. ICU 2.0

void Calendar::clear UCalendarDateFields  field  ) 
 

Clears the value in the given time field, both making it unset and assigning it a value of zero.

This field value will be determined during the next resolving of time into time fields.

Parameters:
field The time field to be cleared. ICU 2.6.

void Calendar::clear EDateFields  field  ) 
 

Clears the value in the given time field, both making it unset and assigning it a value of zero.

This field value will be determined during the next resolving of time into time fields.

Parameters:
field The time field to be cleared.
Deprecated:
ICU 2.6. Use clear(UCalendarDateFields field) instead.

void Calendar::clear void   ) 
 

Clears the values of all the time fields, making them both unset and assigning them a value of zero.

The field values will be determined during the next resolving of time into time fields. ICU 2.0

virtual Calendar* Calendar::clone void   )  const [pure virtual]
 

Create and return a polymorphic copy of this calendar.

Returns:
a polymorphic copy of this calendar. ICU 2.0

Implemented in GregorianCalendar.

void Calendar::complete UErrorCode status  )  [protected]
 

Recomputes the current time from currently set fields, and then fills in any unset fields in the time field list.

Parameters:
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status. ICU 2.0

virtual void Calendar::computeFields UErrorCode status  )  [protected, pure virtual]
 

Converts GMT as milliseconds to time field values.

This allows you to sync up the time field values with a new time that is set for the calendar. This method does NOT recompute the time first; to recompute the time, then the fields, use the method complete().

Parameters:
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status. ICU 2.0

Implemented in GregorianCalendar.

virtual void Calendar::computeTime UErrorCode status  )  [protected, pure virtual]
 

Converts Calendar's time field values to GMT as milliseconds.

Parameters:
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status. ICU 2.0

Implemented in GregorianCalendar.

Calendar* Calendar::createInstance const TimeZone zoneToAdopt,
const Locale aLocale,
UErrorCode success
[static]
 

Gets a Calendar using the given timezone and given locale.

The TimeZone is _not_ adopted; the client is still responsible for deleting it.

Parameters:
zoneToAdopt The given timezone to be adopted.
aLocale The given locale.
success Indicates the success/failure of Calendar creation. Filled in with U_ZERO_ERROR if created successfully, set to a failure result otherwise.
Returns:
A Calendar if created successfully. NULL otherwise. ICU 2.0

Calendar* Calendar::createInstance TimeZone zoneToAdopt,
const Locale aLocale,
UErrorCode success
[static]
 

Creates a Calendar using the given timezone and given locale.

The Calendar takes ownership of zoneToAdopt; the client must not delete it.

Parameters:
zoneToAdopt The given timezone to be adopted.
aLocale The given locale.
success Indicates the success/failure of Calendar creation. Filled in with U_ZERO_ERROR if created successfully, set to a failure result otherwise.
Returns:
A Calendar if created successfully. NULL otherwise. ICU 2.0

Calendar* Calendar::createInstance const Locale aLocale,
UErrorCode success
[static]
 

Creates a Calendar using the default timezone and the given locale.

Parameters:
aLocale The given locale.
success Indicates the success/failure of Calendar creation. Filled in with U_ZERO_ERROR if created successfully, set to a failure result otherwise.
Returns:
A Calendar if created successfully. NULL otherwise. ICU 2.0

Calendar* Calendar::createInstance const TimeZone zone,
UErrorCode success
[static]
 

Creates a Calendar using the given timezone and the default locale.

The TimeZone is _not_ adopted; the client is still responsible for deleting it.

Parameters:
zone The timezone.
success Indicates the success/failure of Calendar creation. Filled in with U_ZERO_ERROR if created successfully, set to a failure result otherwise.
Returns:
A Calendar if created successfully. NULL otherwise. ICU 2.0

Calendar * Calendar::createInstance TimeZone zoneToAdopt,
UErrorCode success
[inline, static]
 

Creates a Calendar using the given timezone and the default locale.

The Calendar takes ownership of zoneToAdopt; the client must not delete it.

Parameters:
zoneToAdopt The given timezone to be adopted.
success Indicates the success/failure of Calendar creation. Filled in with U_ZERO_ERROR if created successfully, set to a failure result otherwise.
Returns:
A Calendar if created successfully. NULL otherwise. ICU 2.0

Calendar* Calendar::createInstance UErrorCode success  )  [static]
 

Creates a Calendar using the default timezone and locale.

Clients are responsible for deleting the object returned.

Parameters:
success Indicates the success/failure of Calendar creation. Filled in with U_ZERO_ERROR if created successfully, set to a failure result otherwise. U_MISSING_RESOURCE_ERROR will be returned if the resource data requests a calendar type which has not been installed.
Returns:
A Calendar if created successfully. NULL otherwise. ICU 2.0

virtual UDate Calendar::defaultCenturyStart  )  const [pure virtual]
 

For internal use only.

Returns:
the start of the default century, as a UDate

Implemented in GregorianCalendar.

virtual int32_t Calendar::defaultCenturyStartYear  )  const [pure virtual]
 

For internal use only.

Returns:
the beginning year of the default century, as a year

Implemented in GregorianCalendar.

UBool Calendar::equals const Calendar when,
UErrorCode status
const
 

Compares the Calendar time, whereas Calendar::operator== compares the equality of Calendar objects.

Parameters:
when The Calendar to be compared with this Calendar. Although this is a const parameter, the object may be modified physically (semantically const).
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status.
Returns:
True if the current time of this Calendar is equal to the time of Calendar when; false otherwise. ICU 2.0

virtual int32_t Calendar::fieldDifference UDate  when,
UCalendarDateFields  field,
UErrorCode status
[virtual]
 

Return the difference between the given time and the time this calendar object is set to.

If this calendar is set before the given time, the returned value will be positive. If this calendar is set after the given time, the returned value will be negative. The field parameter specifies the units of the return value. For example, if fieldDifference(when, Calendar::MONTH) returns 3, then this calendar is set to 3 months before when, and possibly some addition time less than one month.

As a side effect of this call, this calendar is advanced toward when by the given amount. That is, calling this method has the side effect of calling add(field, n), where n is the return value.

Usage: To use this method, call it first with the largest field of interest, then with progressively smaller fields. For example:

int y = cal->fieldDifference(when, Calendar::YEAR, err); int m = cal->fieldDifference(when, Calendar::MONTH, err); int d = cal->fieldDifference(when, Calendar::DATE, err);

computes the difference between cal and when in years, months, and days.

Note: fieldDifference() is asymmetrical. That is, in the following code:

cal->setTime(date1, err); int m1 = cal->fieldDifference(date2, Calendar::MONTH, err); int d1 = cal->fieldDifference(date2, Calendar::DATE, err); cal->setTime(date2, err); int m2 = cal->fieldDifference(date1, Calendar::MONTH, err); int d2 = cal->fieldDifference(date1, Calendar::DATE, err);

one might expect that m1 == -m2 && d1 == -d2. However, this is not generally the case, because of irregularities in the underlying calendar system (e.g., the Gregorian calendar has a varying number of days per month).

Parameters:
when the date to compare this calendar's time to
field the field in which to compute the result
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid, this will be set to an error status.
Returns:
the difference, either positive or negative, between this calendar's time and when, in terms of field. ICU 2.6.

virtual int32_t Calendar::fieldDifference UDate  when,
EDateFields  field,
UErrorCode status
[virtual]
 

Return the difference between the given time and the time this calendar object is set to.

If this calendar is set before the given time, the returned value will be positive. If this calendar is set after the given time, the returned value will be negative. The field parameter specifies the units of the return value. For example, if fieldDifference(when, Calendar::MONTH) returns 3, then this calendar is set to 3 months before when, and possibly some addition time less than one month.

As a side effect of this call, this calendar is advanced toward when by the given amount. That is, calling this method has the side effect of calling add(field, n), where n is the return value.

Usage: To use this method, call it first with the largest field of interest, then with progressively smaller fields. For example:

int y = cal->fieldDifference(when, Calendar::YEAR, err); int m = cal->fieldDifference(when, Calendar::MONTH, err); int d = cal->fieldDifference(when, Calendar::DATE, err);

computes the difference between cal and when in years, months, and days.

Note: fieldDifference() is asymmetrical. That is, in the following code:

cal->setTime(date1, err); int m1 = cal->fieldDifference(date2, Calendar::MONTH, err); int d1 = cal->fieldDifference(date2, Calendar::DATE, err); cal->setTime(date2, err); int m2 = cal->fieldDifference(date1, Calendar::MONTH, err); int d2 = cal->fieldDifference(date1, Calendar::DATE, err);

one might expect that m1 == -m2 && d1 == -d2. However, this is not generally the case, because of irregularities in the underlying calendar system (e.g., the Gregorian calendar has a varying number of days per month).

Parameters:
when the date to compare this calendar's time to
field the field in which to compute the result
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid, this will be set to an error status.
Returns:
the difference, either positive or negative, between this calendar's time and when, in terms of field.
Deprecated:
ICU 2.6. Use fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status).

int32_t Calendar::get UCalendarDateFields  field,
UErrorCode status
const
 

Gets the value for a given time field.

Recalculate the current time field values if the time value has been changed by a call to setTime(). Return zero for unset fields if any fields have been explicitly set by a call to set(). To force a recomputation of all fields regardless of the previous state, call complete(). This method is semantically const, but may alter the object in memory.

Parameters:
field The given time field.
status Fill-in parameter which receives the status of the operation.
Returns:
The value for the given time field, or zero if the field is unset, and set() has been called for any other field. ICU 2.6.

int32_t Calendar::get EDateFields  field,
UErrorCode status
const
 

Gets the value for a given time field.

Recalculate the current time field values if the time value has been changed by a call to setTime(). Return zero for unset fields if any fields have been explicitly set by a call to set(). To force a recomputation of all fields regardless of the previous state, call complete(). This method is semantically const, but may alter the object in memory.

Parameters:
field The given time field.
status Fill-in parameter which receives the status of the operation.
Returns:
The value for the given time field, or zero if the field is unset, and set() has been called for any other field.
Deprecated:
ICU 2.6. Use get(UCalendarDateFields field, UErrorCode& status) instead.

int32_t Calendar::getActualMaximum UCalendarDateFields  field,
UErrorCode status
const
 

Return the maximum value that this field could have, given the current date.

For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a Hebrew calendar, for some years the actual maximum for MONTH is 12, and for others 13.

The version of this function on Calendar uses an iterative algorithm to determine the actual maximum value for the field. There is almost always a more efficient way to accomplish this (in most cases, you can simply return getMaximum()). GregorianCalendar overrides this function with a more efficient implementation.

Parameters:
field the field to determine the maximum of
status Fill-in parameter which receives the status of this operation.
Returns:
the maximum of the given field for the current date of this Calendar ICU 2.6.

int32_t Calendar::getActualMaximum EDateFields  field,
UErrorCode status
const
 

Return the maximum value that this field could have, given the current date.

For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a Hebrew calendar, for some years the actual maximum for MONTH is 12, and for others 13.

The version of this function on Calendar uses an iterative algorithm to determine the actual maximum value for the field. There is almost always a more efficient way to accomplish this (in most cases, you can simply return getMaximum()). GregorianCalendar overrides this function with a more efficient implementation.

Parameters:
field the field to determine the maximum of
status Fill-in parameter which receives the status of this operation.
Returns:
the maximum of the given field for the current date of this Calendar
Deprecated:
ICU 2.6. Use getActualMaximum(UCalendarDateFields field, UErrorCode& status) instead.

int32_t Calendar::getActualMinimum UCalendarDateFields  field,
UErrorCode status
const
 

Return the minimum value that this field could have, given the current date.

For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().

The version of this function on Calendar uses an iterative algorithm to determine the actual minimum value for the field. There is almost always a more efficient way to accomplish this (in most cases, you can simply return getMinimum()). GregorianCalendar overrides this function with a more efficient implementation.

Parameters:
field the field to determine the minimum of
status Fill-in parameter which receives the status of this operation.
Returns:
the minimum of the given field for the current date of this Calendar ICU 2.6.

int32_t Calendar::getActualMinimum EDateFields  field,
UErrorCode status
const
 

Return the minimum value that this field could have, given the current date.

For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().

The version of this function on Calendar uses an iterative algorithm to determine the actual minimum value for the field. There is almost always a more efficient way to accomplish this (in most cases, you can simply return getMinimum()). GregorianCalendar overrides this function with a more efficient implementation.

Parameters:
field the field to determine the minimum of
status Fill-in parameter which receives the status of this operation.
Returns:
the minimum of the given field for the current date of this Calendar
Deprecated:
ICU 2.6. Use getActualMinimum(UCalendarDateFields field, UErrorCode& status) instead.

StringEnumeration* Calendar::getAvailableLocales void   )  [static]
 

Return a StringEnumeration over the locales available at the time of the call, including registered locales.

Returns:
a StringEnumeration over the locales available at the time of the call

For internal use only.

const Locale* Calendar::getAvailableLocales int32_t &  count  )  [static]
 

Returns a list of the locales for which Calendars are installed.

Parameters:
count Number of locales returned.
Returns:
An array of Locale objects representing the set of locales for which Calendars are installed. The system retains ownership of this list; the caller must NOT delete it. Does not include user-registered Calendars. ICU 2.0

virtual UClassID Calendar::getDynamicClassID void   )  const [pure virtual]
 

Returns a unique class ID POLYMORPHICALLY.

Pure virtual method. This method is to implement a simple version of RTTI, since not all C++ compilers support genuine RTTI. Polymorphic operator==() and clone() methods call this method.

Concrete subclasses of Calendar must implement getDynamicClassID() and also a static method and data member:

static UClassID getStaticClassID() { return (UClassID) } static char fgClassID;

Returns:
The class ID for this object. All objects of a given class have the same class ID. Objects of other classes have different class IDs. ICU 2.0

Implements UObject.

Implemented in GregorianCalendar.

UCalendarDaysOfWeek Calendar::getFirstDayOfWeek UErrorCode status  )  const
 

Gets what the first day of the week is; e.g., Sunday in US, Monday in France.

Parameters:
status error code
Returns:
The first day of the week. ICU 2.6

EDaysOfWeek Calendar::getFirstDayOfWeek void   )  const
 

Gets what the first day of the week is; e.g., Sunday in US, Monday in France.

Returns:
The first day of the week.
Deprecated:
ICU 2.6 use the overload with error code

virtual int32_t Calendar::getGreatestMinimum UCalendarDateFields  field  )  const [pure virtual]
 

Gets the highest minimum value for the given field if varies.

Otherwise same as getMinimum(). For Gregorian, no difference.

Parameters:
field The given time field.
Returns:
The highest minimum value for the given time field. ICU 2.6.

Implemented in GregorianCalendar.

virtual int32_t Calendar::getGreatestMinimum EDateFields  field  )  const [pure virtual]
 

Gets the highest minimum value for the given field if varies.

Otherwise same as getMinimum(). For Gregorian, no difference.

Parameters:
field The given time field.
Returns:
The highest minimum value for the given time field.
Deprecated:
ICU 2.6. Use getGreatestMinimum(UCalendarDateFields field) instead.

Implemented in GregorianCalendar.

virtual int32_t Calendar::getLeastMaximum UCalendarDateFields  field  )  const [pure virtual]
 

Gets the lowest maximum value for the given field if varies.

Otherwise same as getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.

Parameters:
field The given time field.
Returns:
The lowest maximum value for the given time field. ICU 2.6.

Implemented in GregorianCalendar.

virtual int32_t Calendar::getLeastMaximum EDateFields  field  )  const [pure virtual]
 

Gets the lowest maximum value for the given field if varies.

Otherwise same as getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.

Parameters:
field The given time field.
Returns:
The lowest maximum value for the given time field.
Deprecated:
ICU 2.6. Use getLeastMaximum(UCalendarDateFields field) instead.

Implemented in GregorianCalendar.

virtual int32_t Calendar::getMaximum UCalendarDateFields  field  )  const [pure virtual]
 

Gets the maximum value for the given time field.

e.g. for Gregorian DAY_OF_MONTH, 31.

Parameters:
field The given time field.
Returns:
The maximum value for the given time field. ICU 2.6.

Implemented in GregorianCalendar.

virtual int32_t Calendar::getMaximum EDateFields  field  )  const [pure virtual]
 

Gets the maximum value for the given time field.

e.g. for Gregorian DAY_OF_MONTH, 31.

Parameters:
field The given time field.
Returns:
The maximum value for the given time field.
Deprecated:
ICU 2.6. Use getMaximum(UCalendarDateFields field) instead.

Implemented in GregorianCalendar.

uint8_t Calendar::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.

If the minimal days required must be a full week, getMinimalDaysInFirstWeek returns 7.

Returns:
The minimal days required in the first week of the year. ICU 2.0

virtual int32_t Calendar::getMinimum UCalendarDateFields  field  )  const [pure virtual]
 

Gets the minimum value for the given time field.

e.g., for Gregorian DAY_OF_MONTH, 1.

Parameters:
field The given time field.
Returns:
The minimum value for the given time field. ICU 2.6.

Implemented in GregorianCalendar.

virtual int32_t Calendar::getMinimum EDateFields  field  )  const [pure virtual]
 

Gets the minimum value for the given time field.

e.g., for Gregorian DAY_OF_MONTH, 1.

Parameters:
field The given time field.
Returns:
The minimum value for the given time field.
Deprecated:
ICU 2.6. Use getMinimum(UCalendarDateFields field) instead.

Implemented in GregorianCalendar.

UDate Calendar::getNow void   )  [static]
 

Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70 (derived from the system time).

Returns:
The current UTC time in milliseconds. ICU 2.0

UDate Calendar::getTime UErrorCode status  )  const [inline]
 

Gets this Calendar's time as milliseconds.

May involve recalculation of time due to previous calls to set time field values. The time specified is non-local UTC (GMT) time. Although this method is const, this object may actually be changed (semantically const).

Parameters:
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status.
Returns:
The current time in UTC (GMT) time, or zero if the operation failed. ICU 2.0

double Calendar::getTimeInMillis UErrorCode status  )  const [protected]
 

Gets this Calendar's current time as a long.

Parameters:
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status.
Returns:
the current time as UTC milliseconds from the epoch. ICU 2.0

const TimeZone& Calendar::getTimeZone void   )  const
 

Returns a reference to the time zone owned by this calendar.

The returned reference is only valid until clients make another call to adoptTimeZone or setTimeZone, or this Calendar is destroyed.

Returns:
The time zone object associated with this calendar. ICU 2.0

virtual const char* Calendar::getType  )  const [pure virtual]
 

Returns the resource key string used for this calendar type.

For example, prepending "Eras_" to this string could return "Eras_japanese" or "Eras_gregorian".

Returns:
static string, for example, "gregorian" or "japanese"

For internal use only.

Implemented in GregorianCalendar.

virtual UBool Calendar::haveDefaultCentury  )  const [pure virtual]
 

For internal use only.

Returns:
TRUE if this calendar has a default century (i.e. 03 -> 2003)

Implemented in GregorianCalendar.

virtual UBool Calendar::inDaylightTime UErrorCode status  )  const [pure virtual]
 

Queries if the current date for this Calendar is in Daylight Savings Time.

Parameters:
status Fill-in parameter which receives the status of this operation.
Returns:
True if the current date for this Calendar is in Daylight Savings Time, false, otherwise. ICU 2.0

Implemented in GregorianCalendar.

int32_t Calendar::internalGet UCalendarDateFields  field  )  const [inline, protected]
 

Gets the value for a given time field.

Subclasses can use this function to get field values without forcing recomputation of time.

Parameters:
field The given time field.
Returns:
The value for the given time field. ICU 2.6.

int32_t Calendar::internalGet EDateFields  field  )  const [inline, protected]
 

Gets the value for a given time field.

Subclasses can use this function to get field values without forcing recomputation of time.

Parameters:
field The given time field.
Returns:
The value for the given time field.
Deprecated:
ICU 2.6. Use internalGet(UCalendarDateFields field) instead.

UDate Calendar::internalGetTime void   )  const [inline, protected]
 

Get the current time without recomputing.

Returns:
the current time without recomputing. ICU 2.0

void Calendar::internalSet UCalendarDateFields  field,
int32_t  value
[inline, protected]
 

Sets the value for a given time field.

This is a fast internal method for subclasses. It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet flags.

Parameters:
field The given time field.
value The value for the given time field. ICU 2.6.

void Calendar::internalSet EDateFields  field,
int32_t  value
[inline, protected]
 

Sets the value for a given time field.

This is a fast internal method for subclasses. It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet flags.

Parameters:
field The given time field.
value The value for the given time field.
Deprecated:
ICU 2.6. Use internalSet(UCalendarDateFields field, int32_t value) instead.

void Calendar::internalSetTime UDate  time  )  [inline, protected]
 

Set the current time without affecting flags or fields.

Parameters:
time The time to be set
Returns:
the current time without recomputing. ICU 2.0

virtual UBool Calendar::isEquivalentTo const Calendar other  )  const [virtual]
 

Returns TRUE if the given Calendar object is equivalent to this one.

An equivalent Calendar will behave exactly as this one does, but it may be set to a different time. By contrast, for the operator==() method to return TRUE, the other Calendar must be set to the same time.

Parameters:
other the Calendar to be compared with this Calendar ICU 2.4

Reimplemented in GregorianCalendar.

UBool Calendar::isLenient void   )  const
 

Tells whether date/time interpretation is to be lenient.

Returns:
True tells that date/time interpretation is to be lenient. ICU 2.0

UBool Calendar::isSet UCalendarDateFields  field  )  const
 

Determines if the given time field has a value set.

This can affect in the resolving of time in Calendar. Unset fields have a value of zero, by definition.

Parameters:
field The given time field.
Returns:
True if the given time field has a value set; false otherwise. ICU 2.6.

UBool Calendar::isSet EDateFields  field  )  const
 

Determines if the given time field has a value set.

This can affect in the resolving of time in Calendar. Unset fields have a value of zero, by definition.

Parameters:
field The given time field.
Returns:
True if the given time field has a value set; false otherwise.
Deprecated:
ICU 2.6. Use isSet(UCalendarDateFields field) instead.

UBool Calendar::operator!= const Calendar that  )  const [inline]
 

Compares the inequality of two Calendar objects.

Parameters:
that The Calendar object to be compared with.
Returns:
True if the given Calendar is not the same as this Calendar; false otherwise. ICU 2.0

Calendar& Calendar::operator= const Calendar right  )  [protected]
 

Default assignment operator.

Parameters:
right Calendar object to be copied ICU 2.0

virtual UBool Calendar::operator== const Calendar that  )  const [virtual]
 

Compares the equality of two Calendar objects.

Objects of different subclasses are considered unequal. This comparison is very exacting; two Calendar objects must be in exactly the same state to be considered equal. To compare based on the represented time, use equals() instead.

Parameters:
that The Calendar object to be compared with.
Returns:
True if the given Calendar is the same as this Calendar; false otherwise. ICU 2.0

TimeZone* Calendar::orphanTimeZone void   ) 
 

Returns the time zone owned by this calendar.

The caller owns the returned object and must delete it when done. After this call, the new time zone associated with this Calendar is the default TimeZone as returned by TimeZone::createDefault().

Returns:
The time zone object which was associated with this calendar. ICU 2.0

URegistryKey Calendar::registerFactory ICUServiceFactory *  toAdopt,
UErrorCode status
[static]
 

Register a new Calendar factory.

The factory will be adopted. INTERNAL in 2.6

Parameters:
toAdopt the factory instance to be adopted
status the in/out status code, no special meanings are assigned
Returns:
a registry key that can be used to unregister this factory

For internal use only.

virtual void Calendar::roll UCalendarDateFields  field,
int32_t  amount,
UErrorCode status
[pure virtual]
 

Time Field Rolling function.

Rolls by the given amount on the given time field. For example, to roll the current date up by one day, call roll(Calendar::DATE, +1, status). When rolling on the month or Calendar::MONTH field, other fields like date might conflict and, need to be changed. For instance, rolling the month up on the date 01/31/96 will result in 02/29/96. Rolling by a positive value always means rolling forward in time; e.g., rolling the year by +1 on "100 BC" will result in "99 BC", for Gregorian calendar. When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the hour value in the range between 0 and 23, which is zero-based.

The only difference between roll() and add() is that roll() does not change the value of more significant fields when it reaches the minimum or maximum of its range, whereas add() does.

Parameters:
field The time field.
amount Indicates amount to roll.
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid, this will be set to an error status. ICU 2.6.

Implemented in GregorianCalendar.

virtual void Calendar::roll EDateFields  field,
int32_t  amount,
UErrorCode status
[pure virtual]
 

Time Field Rolling function.

Rolls by the given amount on the given time field. For example, to roll the current date up by one day, call roll(Calendar::DATE, +1, status). When rolling on the month or Calendar::MONTH field, other fields like date might conflict and, need to be changed. For instance, rolling the month up on the date 01/31/96 will result in 02/29/96. Rolling by a positive value always means rolling forward in time; e.g., rolling the year by +1 on "100 BC" will result in "99 BC", for Gregorian calendar. When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the hour value in the range between 0 and 23, which is zero-based.

The only difference between roll() and add() is that roll() does not change the value of more significant fields when it reaches the minimum or maximum of its range, whereas add() does.

Parameters:
field The time field.
amount Indicates amount to roll.
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid, this will be set to an error status.
Deprecated:
ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.

Implemented in GregorianCalendar.

void Calendar::roll UCalendarDateFields  field,
UBool  up,
UErrorCode status
[inline]
 

Time Field Rolling function.

Rolls (up/down) a single unit of time on the given time field. For example, to roll the current date up by one day, call roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it will roll the year value in the range between getMinimum(Calendar::YEAR) and the value returned by getMaximum(Calendar::YEAR). When rolling on the month or Calendar::MONTH field, other fields like date might conflict and, need to be changed. For instance, rolling the month up on the date 01/31/96 will result in 02/29/96. Rolling up always means rolling forward in time; e.g., rolling the year up on "100 BC" will result in "99 BC", for Gregorian calendar. When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the hour value in the range between 0 and 23, which is zero-based.

NOTE: Do not use this method -- use roll(UCalendarDateFields, int, UErrorCode&) instead.

Parameters:
field The time field.
up Indicates if the value of the specified time field is to be rolled up or rolled down. Use true if rolling up, false otherwise.
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status. ICU 2.6.

void Calendar::roll EDateFields  field,
UBool  up,
UErrorCode status
[inline]
 

Time Field Rolling function.

Rolls (up/down) a single unit of time on the given time field. For example, to roll the current date up by one day, call roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it will roll the year value in the range between getMinimum(Calendar::YEAR) and the value returned by getMaximum(Calendar::YEAR). When rolling on the month or Calendar::MONTH field, other fields like date might conflict and, need to be changed. For instance, rolling the month up on the date 01/31/96 will result in 02/29/96. Rolling up always means rolling forward in time; e.g., rolling the year up on "100 BC" will result in "99 BC", for Gregorian calendar. When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the hour value in the range between 0 and 23, which is zero-based.

NOTE: Do not use this method -- use roll(EDateFields, int, UErrorCode&) instead.

Parameters:
field The time field.
up Indicates if the value of the specified time field is to be rolled up or rolled down. Use true if rolling up, false otherwise.
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status.
Deprecated:
ICU 2.6. Use roll(UCalendarDateFields field, UBool up, UErrorCode& status) instead.

void Calendar::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.

Other field values are retained; call clear() first if this is not desired.

Parameters:
year The value used to set the YEAR time field.
month The value used to set the MONTH time field. Month value is 0-based. E.g., 0 for January.
date The value used to set the DATE time field.
hour The value used to set the HOUR_OF_DAY time field.
minute The value used to set the MINUTE time field.
second The value used to set the SECOND time field. ICU 2.0

void Calendar::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.

Other field values are retained; call clear() first if this is not desired.

Parameters:
year The value used to set the YEAR time field.
month The value used to set the MONTH time field. Month value is 0-based. E.g., 0 for January.
date The value used to set the DATE time field.
hour The value used to set the HOUR_OF_DAY time field.
minute The value used to set the MINUTE time field. ICU 2.0

void Calendar::set int32_t  year,
int32_t  month,
int32_t  date
 

Sets the values for the fields YEAR, MONTH, and DATE.

Other field values are retained; call clear() first if this is not desired.

Parameters:
year The value used to set the YEAR time field.
month The value used to set the MONTH time field. Month value is 0-based. e.g., 0 for January.
date The value used to set the DATE time field. ICU 2.0

void Calendar::set UCalendarDateFields  field,
int32_t  value
 

Sets the given time field with the given value.

Parameters:
field The given time field.
value The value to be set for the given time field. ICU 2.6.

void Calendar::set EDateFields  field,
int32_t  value
 

Sets the given time field with the given value.

Parameters:
field The given time field.
value The value to be set for the given time field.
Deprecated:
ICU 2.6. Use set(UCalendarDateFields field, int32_t value) instead.

void Calendar::setFirstDayOfWeek UCalendarDaysOfWeek  value  ) 
 

Sets what the first day of the week is; e.g., Sunday in US, Monday in France.

Parameters:
value The given first day of the week. ICU 2.6.

void Calendar::setFirstDayOfWeek EDaysOfWeek  value  ) 
 

Sets what the first day of the week is; e.g., Sunday in US, Monday in France.

Parameters:
value The given first day of the week.
Deprecated:
ICU 2.6. Use setFirstDayOfWeek(UCalendarDaysOfWeek value) instead.

void Calendar::setLenient UBool  lenient  ) 
 

Specifies whether or not date/time interpretation is to be lenient.

With lenient interpretation, a date such as "February 942, 1996" will be treated as being equivalent to the 941st day after February 1, 1996. With strict interpretation, such dates will cause an error when computing time from the time field values representing the dates.

Parameters:
lenient True specifies date/time interpretation to be lenient.
See also:
DateFormat::setLenient ICU 2.0

void Calendar::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.

If it must be a full week, use value 7.

Parameters:
value The given minimal days required in the first week of the year. ICU 2.0

void Calendar::setTime UDate  date,
UErrorCode status
[inline]
 

Sets this Calendar's current time with the given UDate.

The time specified should be in non-local UTC (GMT) time.

Parameters:
date The given UDate in UTC (GMT) time.
status Output param set to success/failure code on exit. If any value set in the time field is invalid or restricted by leniency, this will be set to an error status. ICU 2.0

void Calendar::setTimeInMillis double  millis,
UErrorCode status
[protected]
 

Sets this Calendar's current time from the given long value.

Parameters:
millis the new time in UTC milliseconds from the epoch.
status Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status. ICU 2.0

void Calendar::setTimeZone const TimeZone zone  ) 
 

Sets the calendar's time zone to be the same as the one passed in.

The TimeZone passed in is _not_ adopted; the client is still responsible for deleting it.

Parameters:
zone The given time zone. ICU 2.0

UBool Calendar::unregister URegistryKey  key,
UErrorCode status
[static]
 

Unregister a previously-registered CalendarFactory using the key returned from the register call.

Key becomes invalid after a successful call and should not be used again. The CalendarFactory corresponding to the key will be deleted. INTERNAL in 2.6

Parameters:
key the registry key returned by a previous call to registerFactory
status the in/out status code, no special meanings are assigned
Returns:
TRUE if the factory for the key was successfully unregistered

For internal use only.


Friends And Related Function Documentation

friend class CalendarFactory [friend]
 

Multiple Calendar Implementation.

For internal use only.

friend class CalendarService [friend]
 

Multiple Calendar Implementation.

For internal use only.

friend class DefaultCalendarFactory [friend]
 

Multiple Calendar Implementation.

For internal use only.


Field Documentation

UBool Calendar::fAreAllFieldsSet [protected]
 

True if all of the fields have been set.

This is initially false, and set to true by computeFields(). ICU 2.0

UBool Calendar::fAreFieldsSet [protected]
 

True if the fields are in sync with the currently set time of this Calendar.

If false, then the next attempt to get the value of a field will force a recomputation of all fields from the current value of the time field.

This should really be named areFieldsInSync, but the old name is retained for backward compatibility. ICU 2.0

int32_t Calendar::fFields[UCAL_FIELD_COUNT] [protected]
 

The time fields containing values into which the millis is computed.

ICU 2.0

UBool Calendar::fIsSet[UCAL_FIELD_COUNT] [protected]
 

The flags which tell if a specified time field for the calendar is set.

ICU 2.0

UBool Calendar::fIsTimeSet [protected]
 

The flag which indicates if the current time is set in the calendar.

ICU 2.0

int32_t Calendar::fStamp[UCAL_FIELD_COUNT] [protected]
 

Pseudo-time-stamps which specify when each field was set.

There are two special values, UNSET and INTERNALLY_SET. Values from MINIMUM_USER_SET to Integer.MAX_VALUE are legal user set values. ICU 2.0


The documentation for this class was generated from the following file:
Generated on Wed Sep 3 17:47:17 2003 for ICU 2.6 by doxygen 1.3.2