1999-12-28 23:57:50 +00:00
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2004-05-19 20:42:44 +00:00
* Copyright ( C ) 1997 - 2004 , International Business Machines
1999-12-28 23:57:50 +00:00
* Corporation and others . All Rights Reserved .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* File CALENDAR . H
*
* Modification History :
*
* Date Name Description
* 04 / 22 / 97 aliu Expanded and corrected comments and other header
* contents .
* 05 / 01 / 97 aliu Made equals ( ) , before ( ) , after ( ) arguments const .
* 05 / 20 / 97 aliu Replaced fAreFieldsSet with fAreFieldsInSync and
* fAreAllFieldsSet .
* 07 / 27 / 98 stephen Sync up with JDK 1.2
* 11 / 15 / 99 weiv added YEAR_WOY and DOW_LOCAL
* to EDateFields
2002-08-20 15:59:07 +00:00
* 8 / 19 / 2002 srl Removed Javaisms
2003-11-12 09:01:41 +00:00
* 11 / 07 / 2003 srl Update , clean up documentation .
1999-12-28 23:57:50 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
# ifndef CALENDAR_H
# define CALENDAR_H
2002-06-27 01:19:20 +00:00
# include "unicode/utypes.h"
2002-09-20 01:54:48 +00:00
# if !UCONFIG_NO_FORMATTING
2002-06-27 01:19:20 +00:00
# include "unicode/uobject.h"
1999-12-28 23:57:50 +00:00
# include "unicode/locid.h"
# include "unicode/timezone.h"
2003-02-21 08:32:22 +00:00
# include "unicode/ucal.h"
1999-12-28 23:57:50 +00:00
2001-10-08 23:26:58 +00:00
U_NAMESPACE_BEGIN
1999-12-28 23:57:50 +00:00
2003-05-15 22:30:24 +00:00
class ICUServiceFactory ;
/**
2003-05-25 07:12:19 +00:00
* @ internal
2003-05-15 22:30:24 +00:00
*/
typedef const void * URegistryKey ;
2003-10-28 02:30:49 +00:00
/**
* @ internal
*/
typedef int32_t UFieldResolutionTable [ 12 ] [ 8 ] ;
1999-12-28 23:57:50 +00:00
/**
* < code > Calendar < / code > is an abstract base class for converting between
* a < code > UDate < / code > object and a set of integer fields such as
* < code > YEAR < / code > , < code > MONTH < / code > , < code > DAY < / code > , < code > HOUR < / code > ,
* and so on . ( A < code > UDate < / code > object represents a specific instant in
2002-12-19 00:11:32 +00:00
* time with millisecond precision . See UDate
1999-12-28 23:57:50 +00:00
* for information about the < code > UDate < / code > class . )
*
* < p >
* Subclasses of < code > Calendar < / code > interpret a < code > UDate < / code >
2004-08-24 17:38:33 +00:00
* according to the rules of a specific calendar system .
2003-05-21 16:29:56 +00:00
* The most commonly used subclass of < code > Calendar < / code > is
* < code > GregorianCalendar < / code > . Other subclasses could represent
1999-12-28 23:57:50 +00:00
* the various types of lunar calendars in use in many parts of the world .
2004-08-24 17:38:33 +00:00
*
2003-06-09 23:08:08 +00:00
* < p >
* < b > NOTE < / b > : ( ICU 2.6 ) The subclass interface should be considered unstable
2004-08-24 17:38:33 +00:00
* - it WILL change .
1999-12-28 23:57:50 +00:00
*
* < p >
* Like other locale - sensitive classes , < code > Calendar < / code > provides a
2002-08-20 15:59:07 +00:00
* static method , < code > createInstance < / code > , for getting a generally useful
2004-08-24 17:38:33 +00:00
* object of this type . < code > Calendar < / code > ' s < code > createInstance < / code > method
2003-05-21 16:29:56 +00:00
* returns the appropriate < code > Calendar < / code > subclass whose
1999-12-28 23:57:50 +00:00
* time fields have been initialized with the current date and time :
2004-06-15 22:32:41 +00:00
* \ htmlonly < blockquote > \ endhtmlonly
1999-12-28 23:57:50 +00:00
* < pre >
2002-08-20 15:59:07 +00:00
* Calendar * rightNow = Calendar : : createInstance ( errCode ) ;
1999-12-28 23:57:50 +00:00
* < / pre >
2004-06-15 22:32:41 +00:00
* \ htmlonly < / blockquote > \ endhtmlonly
1999-12-28 23:57:50 +00:00
*
* < p >
* A < code > Calendar < / code > 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 ) .
*
* < p >
* When computing a < code > UDate < / code > from time fields , two special circumstances
* may arise : there may be insufficient information to compute the
* < code > UDate < / code > ( 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 ) .
*
* < p >
* < strong > Insufficient information . < / strong > 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 .
*
* < p >
* < strong > Inconsistent information . < / strong > 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 .
*
2004-06-15 22:32:41 +00:00
* \ htmlonly < blockquote > \ endhtmlonly
1999-12-28 23:57:50 +00:00
* < pre >
* 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
* < / pre >
2004-06-15 22:32:41 +00:00
* \ htmlonly < / blockquote > \ endhtmlonly
1999-12-28 23:57:50 +00:00
*
* For the time of day :
*
2004-06-15 22:32:41 +00:00
* \ htmlonly < blockquote > \ endhtmlonly
1999-12-28 23:57:50 +00:00
* < pre >
* HOUR_OF_DAY
* AM_PM + HOUR
* < / pre >
2004-06-15 22:32:41 +00:00
* \ htmlonly < / blockquote > \ endhtmlonly
1999-12-28 23:57:50 +00:00
*
* < p >
* < strong > Note : < / strong > 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 < em > and < / em > day - of - week in some cases .
*
* < p >
* < strong > Note : < / strong > There are certain possible ambiguities in
* interpretation of certain singular times , which are resolved in the
* following ways :
* < ol >
* < li > 24 : 00 : 00 " belongs " to the following day . That is ,
* 23 : 59 on Dec 31 , 1969 & lt ; 24 : 00 on Jan 1 , 1970 & lt ; 24 : 01 : 00 on Jan 1 , 1970
*
* < li > Although historically not precise , midnight also belongs to " am " ,
* and noon belongs to " pm " , so on the same day ,
* 12 : 00 am ( midnight ) & lt ; 12 : 01 am , and 12 : 00 pm ( noon ) & lt ; 12 : 01 pm
* < / ol >
*
* < p >
* 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 { @ link DateFormat }
* to format dates .
*
* < p >
* < code > Calendar < / code > 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 < code > December 12 , < b > 1996 < / b > < / code > results in
* < code > January 12 , < b > 1996 < / b > < / code > .
*
* < p >
* < code > Calendar < / code > 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 < code > September 12 , 1996 < / code >
* results in < code > September 7 , 1996 < / code > .
*
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2002-06-27 01:19:20 +00:00
class U_I18N_API Calendar : public UObject {
1999-12-28 23:57:50 +00:00
public :
/**
* 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 .
2003-02-21 08:32:22 +00:00
* @ deprecated ICU 2.6 . Use C enum UCalendarDateFields defined in ucal . h
1999-12-28 23:57:50 +00:00
*/
enum EDateFields {
ERA , // Example: 0..1
YEAR , // Example: 1..big number
MONTH , // Example: 0..11
WEEK_OF_YEAR , // Example: 1..53
WEEK_OF_MONTH , // Example: 1..4
DATE , // Example: 1..31
DAY_OF_YEAR , // Example: 1..365
DAY_OF_WEEK , // Example: 1..7
DAY_OF_WEEK_IN_MONTH , // Example: 1..4, may be specified as -1
AM_PM , // Example: 0..1
HOUR , // Example: 0..11
HOUR_OF_DAY , // Example: 0..23
MINUTE , // Example: 0..59
SECOND , // Example: 0..59
MILLISECOND , // Example: 0..999
ZONE_OFFSET , // Example: -12*U_MILLIS_PER_HOUR..12*U_MILLIS_PER_HOUR
DST_OFFSET , // Example: 0 or U_MILLIS_PER_HOUR
2004-08-24 17:38:33 +00:00
YEAR_WOY , // 'Y' Example: 1..big number - Year of Week of Year
2003-11-12 09:01:41 +00:00
DOW_LOCAL , // 'e' Example: 1..7 - Day of Week / Localized
2003-11-19 05:38:55 +00:00
FIELD_COUNT = UCAL_FIELD_COUNT // See ucal.h for other fields.
1999-12-28 23:57:50 +00:00
} ;
/**
* 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 .
2003-02-21 08:32:22 +00:00
* @ deprecated ICU 2.6 . Use C enum UCalendarDaysOfWeek defined in ucal . h
1999-12-28 23:57:50 +00:00
*/
enum EDaysOfWeek {
SUNDAY = 1 ,
MONDAY ,
TUESDAY ,
WEDNESDAY ,
THURSDAY ,
FRIDAY ,
SATURDAY
} ;
/**
* Useful constants for month . Note : Calendar month is 0 - based .
2003-02-21 08:32:22 +00:00
* @ deprecated ICU 2.6 . Use C enum UCalendarMonths defined in ucal . h
1999-12-28 23:57:50 +00:00
*/
enum EMonths {
JANUARY ,
FEBRUARY ,
MARCH ,
APRIL ,
MAY ,
JUNE ,
JULY ,
AUGUST ,
SEPTEMBER ,
OCTOBER ,
NOVEMBER ,
DECEMBER ,
UNDECIMBER
} ;
/**
* Useful constants for hour in 12 - hour clock . Used in GregorianCalendar .
2003-02-21 08:32:22 +00:00
* @ deprecated ICU 2.6 . Use C enum UCalendarAMPMs defined in ucal . h
1999-12-28 23:57:50 +00:00
*/
enum EAmpm {
AM ,
PM
} ;
/**
* destructor
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
virtual ~ Calendar ( ) ;
/**
* Create and return a polymorphic copy of this calendar .
2002-07-01 11:04:45 +00:00
*
* @ return a polymorphic copy of this calendar .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
virtual Calendar * clone ( void ) const = 0 ;
/**
* Creates a Calendar using the default timezone and locale . Clients are responsible
* for deleting the object returned .
*
* @ param success Indicates the success / failure of Calendar creation . Filled in
* with U_ZERO_ERROR if created successfully , set to a failure result
2003-05-15 22:30:24 +00:00
* otherwise . U_MISSING_RESOURCE_ERROR will be returned if the resource data
* requests a calendar type which has not been installed .
1999-12-28 23:57:50 +00:00
* @ return A Calendar if created successfully . NULL otherwise .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2004-08-24 17:38:33 +00:00
static Calendar * U_EXPORT2 createInstance ( UErrorCode & success ) ;
1999-12-28 23:57:50 +00:00
/**
* Creates a Calendar using the given timezone and the default locale .
* The Calendar takes ownership of zoneToAdopt ; the
* client must not delete it .
*
* @ param zoneToAdopt The given timezone to be adopted .
* @ param success Indicates the success / failure of Calendar creation . Filled in
* with U_ZERO_ERROR if created successfully , set to a failure result
* otherwise .
* @ return A Calendar if created successfully . NULL otherwise .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2004-08-24 17:38:33 +00:00
static Calendar * U_EXPORT2 createInstance ( TimeZone * zoneToAdopt , UErrorCode & success ) ;
1999-12-28 23:57:50 +00:00
/**
* Creates a Calendar using the given timezone and the default locale . The TimeZone
* is _not_ adopted ; the client is still responsible for deleting it .
*
* @ param zone The timezone .
* @ param success Indicates the success / failure of Calendar creation . Filled in
* with U_ZERO_ERROR if created successfully , set to a failure result
* otherwise .
* @ return A Calendar if created successfully . NULL otherwise .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2004-08-24 17:38:33 +00:00
static Calendar * U_EXPORT2 createInstance ( const TimeZone & zone , UErrorCode & success ) ;
1999-12-28 23:57:50 +00:00
/**
* Creates a Calendar using the default timezone and the given locale .
*
* @ param aLocale The given locale .
* @ param success Indicates the success / failure of Calendar creation . Filled in
* with U_ZERO_ERROR if created successfully , set to a failure result
* otherwise .
* @ return A Calendar if created successfully . NULL otherwise .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2004-08-24 17:38:33 +00:00
static Calendar * U_EXPORT2 createInstance ( const Locale & aLocale , UErrorCode & success ) ;
1999-12-28 23:57:50 +00:00
/**
* Creates a Calendar using the given timezone and given locale .
* The Calendar takes ownership of zoneToAdopt ; the
* client must not delete it .
*
* @ param zoneToAdopt The given timezone to be adopted .
* @ param aLocale The given locale .
* @ param success Indicates the success / failure of Calendar creation . Filled in
* with U_ZERO_ERROR if created successfully , set to a failure result
* otherwise .
* @ return A Calendar if created successfully . NULL otherwise .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2004-08-24 17:38:33 +00:00
static Calendar * U_EXPORT2 createInstance ( TimeZone * zoneToAdopt , const Locale & aLocale , UErrorCode & success ) ;
1999-12-28 23:57:50 +00:00
/**
* Gets a Calendar using the given timezone and given locale . The TimeZone
* is _not_ adopted ; the client is still responsible for deleting it .
*
2002-07-01 11:04:45 +00:00
* @ param zoneToAdopt The given timezone to be adopted .
1999-12-28 23:57:50 +00:00
* @ param aLocale The given locale .
* @ param success Indicates the success / failure of Calendar creation . Filled in
* with U_ZERO_ERROR if created successfully , set to a failure result
* otherwise .
* @ return A Calendar if created successfully . NULL otherwise .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2004-08-24 17:38:33 +00:00
static Calendar * U_EXPORT2 createInstance ( const TimeZone & zoneToAdopt , const Locale & aLocale , UErrorCode & success ) ;
1999-12-28 23:57:50 +00:00
/**
* Returns a list of the locales for which Calendars are installed .
*
* @ param count Number of locales returned .
* @ return An array of Locale objects representing the set of locales for which
* Calendars are installed . The system retains ownership of this list ;
2003-05-15 22:30:24 +00:00
* the caller must NOT delete it . Does not include user - registered Calendars .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2004-08-24 17:38:33 +00:00
static const Locale * U_EXPORT2 getAvailableLocales ( int32_t & count ) ;
1999-12-28 23:57:50 +00:00
/**
2004-08-24 17:38:33 +00:00
* Returns the current UTC ( GMT ) time measured in milliseconds since 0 : 00 : 00 on 1 / 1 / 70
1999-12-28 23:57:50 +00:00
* ( derived from the system time ) .
*
* @ return The current UTC time in milliseconds .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2004-08-24 17:38:33 +00:00
static UDate U_EXPORT2 getNow ( void ) ;
1999-12-28 23:57:50 +00:00
/**
* 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 ) .
*
* @ param 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 .
* @ return The current time in UTC ( GMT ) time , or zero if the operation
* failed .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
inline UDate getTime ( UErrorCode & status ) const { return getTimeInMillis ( status ) ; }
/**
* Sets this Calendar ' s current time with the given UDate . The time specified should
* be in non - local UTC ( GMT ) time .
*
* @ param date The given UDate in UTC ( GMT ) time .
2002-07-01 11:04:45 +00:00
* @ param 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 .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
inline void setTime ( UDate date , UErrorCode & status ) { setTimeInMillis ( date , status ) ; }
/**
* 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 .
*
* @ param that The Calendar object to be compared with .
* @ return True if the given Calendar is the same as this Calendar ; false
* otherwise .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2000-05-18 22:08:39 +00:00
virtual UBool operator = = ( const Calendar & that ) const ;
1999-12-28 23:57:50 +00:00
/**
* Compares the inequality of two Calendar objects .
*
* @ param that The Calendar object to be compared with .
* @ return True if the given Calendar is not the same as this Calendar ; false
* otherwise .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2000-05-18 22:08:39 +00:00
UBool operator ! = ( const Calendar & that ) const { return ! operator = = ( that ) ; }
1999-12-28 23:57:50 +00:00
2002-08-21 18:33:08 +00:00
/**
* 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 .
*
2004-08-24 17:38:33 +00:00
* @ param other the Calendar to be compared with this Calendar
2004-03-26 19:42:04 +00:00
* @ stable ICU 2.4
2002-08-21 18:33:08 +00:00
*/
virtual UBool isEquivalentTo ( const Calendar & other ) const ;
1999-12-28 23:57:50 +00:00
/**
* Compares the Calendar time , whereas Calendar : : operator = = compares the equality of
* Calendar objects .
*
* @ param when The Calendar to be compared with this Calendar . Although this is a
* const parameter , the object may be modified physically
* ( semantically const ) .
* @ param 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 .
* @ return True if the current time of this Calendar is equal to the time of
* Calendar when ; false otherwise .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2000-05-18 22:08:39 +00:00
UBool equals ( const Calendar & when , UErrorCode & status ) const ;
1999-12-28 23:57:50 +00:00
/**
* Returns true if this Calendar ' s current time is before " when " ' s current time .
*
* @ param when The Calendar to be compared with this Calendar . Although this is a
* const parameter , the object may be modified physically
* ( semantically const ) .
* @ param 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 .
* @ return True if the current time of this Calendar is before the time of
* Calendar when ; false otherwise .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2000-05-18 22:08:39 +00:00
UBool before ( const Calendar & when , UErrorCode & status ) const ;
1999-12-28 23:57:50 +00:00
/**
* Returns true if this Calendar ' s current time is after " when " ' s current time .
*
* @ param when The Calendar to be compared with this Calendar . Although this is a
* const parameter , the object may be modified physically
* ( semantically const ) .
* @ param 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 .
* @ return True if the current time of this Calendar is after the time of
* Calendar when ; false otherwise .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2000-05-18 22:08:39 +00:00
UBool after ( const Calendar & when , UErrorCode & status ) const ;
1999-12-28 23:57:50 +00:00
/**
* 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.
*
* @ param field Specifies which date field to modify .
* @ param 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 . )
* @ param 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 .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . use add ( UCalendarDateFields field , int32_t amount , UErrorCode & status ) instead .
*/
2003-10-26 10:24:58 +00:00
virtual void add ( EDateFields field , int32_t amount , UErrorCode & status ) ;
2003-02-28 13:21:23 +00:00
/**
* 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.
*
* @ param field Specifies which date field to modify .
* @ param 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 . )
* @ param 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 .
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-10-26 10:24:58 +00:00
virtual void add ( UCalendarDateFields field , int32_t amount , UErrorCode & status ) ;
1999-12-28 23:57:50 +00:00
2003-02-28 13:21:23 +00:00
/**
* 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 .
* < P >
* NOTE : Do not use this method - - use roll ( EDateFields , int , UErrorCode & ) instead .
*
* @ param field The time field .
* @ param 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 .
* @ param 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 .
*/
2003-05-16 20:33:01 +00:00
inline void roll ( EDateFields field , UBool up , UErrorCode & status ) ;
2003-02-28 13:21:23 +00:00
1999-12-28 23:57:50 +00:00
/**
* 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 .
* < P >
2003-02-21 08:32:22 +00:00
* NOTE : Do not use this method - - use roll ( UCalendarDateFields , int , UErrorCode & ) instead .
1999-12-28 23:57:50 +00:00
*
* @ param field The time field .
* @ param 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 .
* @ param 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 .
2003-02-28 13:21:23 +00:00
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-05-16 20:33:01 +00:00
inline void roll ( UCalendarDateFields field , UBool up , UErrorCode & status ) ;
1999-12-28 23:57:50 +00:00
/**
* 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 .
* < P >
* 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 .
*
* @ param field The time field .
* @ param amount Indicates amount to roll .
* @ param 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 .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use roll ( UCalendarDateFields field , int32_t amount , UErrorCode & status ) instead .
*/
2003-11-24 22:43:31 +00:00
virtual void roll ( EDateFields field , int32_t amount , UErrorCode & status ) ;
2003-02-28 13:21:23 +00:00
/**
* 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 .
* < P >
* 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 .
*
* @ param field The time field .
* @ param amount Indicates amount to roll .
* @ param 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 .
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-10-26 10:24:58 +00:00
virtual void roll ( UCalendarDateFields field , int32_t amount , UErrorCode & status ) ;
1999-12-28 23:57:50 +00:00
2000-06-15 23:36:25 +00:00
/**
* Return the difference between the given time and the time this
* calendar object is set to . If this calendar is set
* < em > before < / em > the given time , the returned value will be
* positive . If this calendar is set < em > after < / em > the given
* time , the returned value will be negative . The
* < code > field < / code > parameter specifies the units of the return
* value . For example , if < code > fieldDifference ( when ,
2002-08-20 15:59:07 +00:00
* Calendar : : MONTH ) < / code > returns 3 , then this calendar is set to
2000-06-15 23:36:25 +00:00
* 3 months before < code > when < / code > , and possibly some addition
* time less than one month .
*
* < p > As a side effect of this call , this calendar is advanced
* toward < code > when < / code > by the given amount . That is , calling
* this method has the side effect of calling < code > add ( field ,
* n ) < / code > , where < code > n < / code > is the return value .
*
* < p > Usage : To use this method , call it first with the largest
* field of interest , then with progressively smaller fields . For
* example :
*
* < pre >
2002-08-20 15:59:07 +00:00
* int y = cal - > fieldDifference ( when , Calendar : : YEAR , err ) ;
* int m = cal - > fieldDifference ( when , Calendar : : MONTH , err ) ;
* int d = cal - > fieldDifference ( when , Calendar : : DATE , err ) ; < / pre >
2000-06-15 23:36:25 +00:00
*
* computes the difference between < code > cal < / code > and
* < code > when < / code > in years , months , and days .
*
* < p > Note : < code > fieldDifference ( ) < / code > is
* < em > asymmetrical < / em > . That is , in the following code :
*
* < pre >
2002-08-20 15:59:07 +00:00
* 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 ) ; < / pre >
2000-06-15 23:36:25 +00:00
*
* one might expect that < code > m1 = = - m2 & & d1 = = - d2 < / code > .
* 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 ) .
*
* @ param when the date to compare this calendar ' s time to
* @ param field the field in which to compute the result
2002-07-01 11:04:45 +00:00
* @ param 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 .
2000-06-15 23:36:25 +00:00
* @ return the difference , either positive or negative , between
* this calendar ' s time and < code > when < / code > , in terms of
* < code > field < / code > .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use fieldDifference ( UDate when , UCalendarDateFields field , UErrorCode & status ) .
*/
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 . If this calendar is set
* < em > before < / em > the given time , the returned value will be
* positive . If this calendar is set < em > after < / em > the given
* time , the returned value will be negative . The
* < code > field < / code > parameter specifies the units of the return
* value . For example , if < code > fieldDifference ( when ,
* Calendar : : MONTH ) < / code > returns 3 , then this calendar is set to
* 3 months before < code > when < / code > , and possibly some addition
* time less than one month .
*
* < p > As a side effect of this call , this calendar is advanced
* toward < code > when < / code > by the given amount . That is , calling
* this method has the side effect of calling < code > add ( field ,
* n ) < / code > , where < code > n < / code > is the return value .
*
* < p > Usage : To use this method , call it first with the largest
* field of interest , then with progressively smaller fields . For
* example :
*
* < pre >
* int y = cal - > fieldDifference ( when , Calendar : : YEAR , err ) ;
* int m = cal - > fieldDifference ( when , Calendar : : MONTH , err ) ;
* int d = cal - > fieldDifference ( when , Calendar : : DATE , err ) ; < / pre >
*
* computes the difference between < code > cal < / code > and
* < code > when < / code > in years , months , and days .
*
* < p > Note : < code > fieldDifference ( ) < / code > is
* < em > asymmetrical < / em > . That is , in the following code :
*
* < pre >
* 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 ) ; < / pre >
*
* one might expect that < code > m1 = = - m2 & & d1 = = - d2 < / code > .
* 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 ) .
*
* @ param when the date to compare this calendar ' s time to
* @ param field the field in which to compute the result
* @ param 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 .
* @ return the difference , either positive or negative , between
* this calendar ' s time and < code > when < / code > , in terms of
* < code > field < / code > .
* @ draft ICU 2.6 .
2000-06-15 23:36:25 +00:00
*/
2003-02-21 08:32:22 +00:00
virtual int32_t fieldDifference ( UDate when , UCalendarDateFields field , UErrorCode & status ) ;
2000-06-15 23:36:25 +00:00
1999-12-28 23:57:50 +00:00
/**
* 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 .
*
* @ param value The given time zone .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
void adoptTimeZone ( TimeZone * value ) ;
/**
* 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 .
*
2003-05-10 00:17:35 +00:00
* @ param zone The given time zone .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
void setTimeZone ( const TimeZone & zone ) ;
/**
* 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 .
*
* @ return The time zone object associated with this calendar .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
const TimeZone & getTimeZone ( void ) const ;
/**
* 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 ( ) .
*
* @ return The time zone object which was associated with this calendar .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
TimeZone * orphanTimeZone ( void ) ;
/**
* Queries if the current date for this Calendar is in Daylight Savings Time .
*
* @ param status Fill - in parameter which receives the status of this operation .
* @ return True if the current date for this Calendar is in Daylight Savings Time ,
* false , otherwise .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2000-05-18 22:08:39 +00:00
virtual UBool inDaylightTime ( UErrorCode & status ) const = 0 ;
1999-12-28 23:57:50 +00:00
/**
* 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 941 st 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 .
*
* @ param lenient True specifies date / time interpretation to be lenient .
*
* @ see DateFormat # setLenient
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2000-05-18 22:08:39 +00:00
void setLenient ( UBool lenient ) ;
1999-12-28 23:57:50 +00:00
/**
* Tells whether date / time interpretation is to be lenient .
*
* @ return True tells that date / time interpretation is to be lenient .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2000-05-18 22:08:39 +00:00
UBool isLenient ( void ) const ;
1999-12-28 23:57:50 +00:00
/**
* Sets what the first day of the week is ; e . g . , Sunday in US , Monday in France .
*
* @ param value The given first day of the week .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use setFirstDayOfWeek ( UCalendarDaysOfWeek value ) instead .
*/
void setFirstDayOfWeek ( EDaysOfWeek value ) ;
/**
* Sets what the first day of the week is ; e . g . , Sunday in US , Monday in France .
*
* @ param value The given first day of the week .
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-02-21 08:32:22 +00:00
void setFirstDayOfWeek ( UCalendarDaysOfWeek value ) ;
1999-12-28 23:57:50 +00:00
/**
* Gets what the first day of the week is ; e . g . , Sunday in US , Monday in France .
*
* @ return The first day of the week .
2003-05-01 17:43:01 +00:00
* @ deprecated ICU 2.6 use the overload with error code
1999-12-28 23:57:50 +00:00
*/
2003-03-19 13:21:51 +00:00
EDaysOfWeek getFirstDayOfWeek ( void ) const ;
1999-12-28 23:57:50 +00:00
2003-05-01 17:43:01 +00:00
/**
* Gets what the first day of the week is ; e . g . , Sunday in US , Monday in France .
*
* @ param status error code
* @ return The first day of the week .
* @ draft ICU 2.6
*/
UCalendarDaysOfWeek getFirstDayOfWeek ( UErrorCode & status ) const ;
1999-12-28 23:57:50 +00:00
/**
* 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.
*
* @ param value The given minimal days required in the first week of the year .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
void setMinimalDaysInFirstWeek ( uint8_t value ) ;
/**
* 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.
*
* @ return The minimal days required in the first week of the year .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
uint8_t getMinimalDaysInFirstWeek ( void ) const ;
/**
* Gets the minimum value for the given time field . e . g . , for Gregorian
* DAY_OF_MONTH , 1.
*
* @ param field The given time field .
* @ return The minimum value for the given time field .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use getMinimum ( UCalendarDateFields field ) instead .
*/
2003-10-26 10:24:58 +00:00
virtual int32_t getMinimum ( EDateFields field ) const ;
2003-02-28 13:21:23 +00:00
/**
* Gets the minimum value for the given time field . e . g . , for Gregorian
* DAY_OF_MONTH , 1.
*
* @ param field The given time field .
* @ return The minimum value for the given time field .
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-10-26 10:24:58 +00:00
virtual int32_t getMinimum ( UCalendarDateFields field ) const ;
1999-12-28 23:57:50 +00:00
/**
* Gets the maximum value for the given time field . e . g . for Gregorian DAY_OF_MONTH ,
* 31.
*
* @ param field The given time field .
* @ return The maximum value for the given time field .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use getMaximum ( UCalendarDateFields field ) instead .
*/
2003-10-26 10:24:58 +00:00
virtual int32_t getMaximum ( EDateFields field ) const ;
2003-02-28 13:21:23 +00:00
/**
* Gets the maximum value for the given time field . e . g . for Gregorian DAY_OF_MONTH ,
* 31.
*
* @ param field The given time field .
* @ return The maximum value for the given time field .
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-10-26 10:24:58 +00:00
virtual int32_t getMaximum ( UCalendarDateFields field ) const ;
1999-12-28 23:57:50 +00:00
/**
* Gets the highest minimum value for the given field if varies . Otherwise same as
* getMinimum ( ) . For Gregorian , no difference .
*
* @ param field The given time field .
* @ return The highest minimum value for the given time field .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use getGreatestMinimum ( UCalendarDateFields field ) instead .
*/
2003-10-26 10:24:58 +00:00
virtual int32_t getGreatestMinimum ( EDateFields field ) const ;
2003-02-28 13:21:23 +00:00
/**
* Gets the highest minimum value for the given field if varies . Otherwise same as
* getMinimum ( ) . For Gregorian , no difference .
*
* @ param field The given time field .
* @ return The highest minimum value for the given time field .
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-10-26 10:24:58 +00:00
virtual int32_t getGreatestMinimum ( UCalendarDateFields field ) const ;
1999-12-28 23:57:50 +00:00
/**
* Gets the lowest maximum value for the given field if varies . Otherwise same as
* getMaximum ( ) . e . g . , for Gregorian DAY_OF_MONTH , 28.
*
* @ param field The given time field .
* @ return The lowest maximum value for the given time field .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use getLeastMaximum ( UCalendarDateFields field ) instead .
*/
2003-10-26 10:24:58 +00:00
virtual int32_t getLeastMaximum ( EDateFields field ) const ;
2003-02-28 13:21:23 +00:00
/**
* Gets the lowest maximum value for the given field if varies . Otherwise same as
* getMaximum ( ) . e . g . , for Gregorian DAY_OF_MONTH , 28.
*
* @ param field The given time field .
* @ return The lowest maximum value for the given time field .
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-10-26 10:24:58 +00:00
virtual int32_t getLeastMaximum ( UCalendarDateFields field ) const ;
1999-12-28 23:57:50 +00:00
/**
* 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 .
*
2002-07-01 11:04:45 +00:00
* @ param field the field to determine the minimum of
* @ param status Fill - in parameter which receives the status of this operation .
* @ return the minimum of the given field for the current date of this Calendar
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use getActualMinimum ( UCalendarDateFields field , UErrorCode & status ) instead .
*/
int32_t 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 .
*
* @ param field the field to determine the minimum of
* @ param status Fill - in parameter which receives the status of this operation .
* @ return the minimum of the given field for the current date of this Calendar
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-02-21 08:32:22 +00:00
int32_t getActualMinimum ( UCalendarDateFields field , UErrorCode & status ) const ;
1999-12-28 23:57:50 +00:00
/**
* 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 .
*
2002-07-01 11:04:45 +00:00
* @ param field the field to determine the maximum of
* @ param status Fill - in parameter which receives the status of this operation .
* @ return the maximum of the given field for the current date of this Calendar
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use getActualMaximum ( UCalendarDateFields field , UErrorCode & status ) instead .
*/
int32_t 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 .
*
* @ param field the field to determine the maximum of
* @ param status Fill - in parameter which receives the status of this operation .
* @ return the maximum of the given field for the current date of this Calendar
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-02-21 08:32:22 +00:00
int32_t getActualMaximum ( UCalendarDateFields field , UErrorCode & status ) const ;
1999-12-28 23:57:50 +00:00
/**
* 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 .
*
* @ param field The given time field .
* @ param status Fill - in parameter which receives the status of the operation .
* @ return The value for the given time field , or zero if the field is unset ,
* and set ( ) has been called for any other field .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use get ( UCalendarDateFields field , UErrorCode & status ) instead .
*/
int32_t 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 .
*
* @ param field The given time field .
* @ param status Fill - in parameter which receives the status of the operation .
* @ return The value for the given time field , or zero if the field is unset ,
* and set ( ) has been called for any other field .
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-02-21 08:32:22 +00:00
int32_t get ( UCalendarDateFields field , UErrorCode & status ) const ;
1999-12-28 23:57:50 +00:00
/**
* 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 .
*
2002-07-01 11:04:45 +00:00
* @ param field The given time field .
1999-12-28 23:57:50 +00:00
* @ return True if the given time field has a value set ; false otherwise .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use isSet ( UCalendarDateFields field ) instead .
*/
UBool 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 .
*
* @ param field The given time field .
* @ return True if the given time field has a value set ; false otherwise .
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-02-21 08:32:22 +00:00
UBool isSet ( UCalendarDateFields field ) const ;
1999-12-28 23:57:50 +00:00
/**
* Sets the given time field with the given value .
*
* @ param field The given time field .
* @ param value The value to be set for the given time field .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use set ( UCalendarDateFields field , int32_t value ) instead .
*/
void set ( EDateFields field , int32_t value ) ;
/**
* Sets the given time field with the given value .
*
* @ param field The given time field .
* @ param value The value to be set for the given time field .
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-02-21 08:32:22 +00:00
void set ( UCalendarDateFields field , int32_t value ) ;
1999-12-28 23:57:50 +00:00
/**
* Sets the values for the fields YEAR , MONTH , and DATE . Other field values are
* retained ; call clear ( ) first if this is not desired .
*
* @ param year The value used to set the YEAR time field .
* @ param month The value used to set the MONTH time field . Month value is 0 - based .
* e . g . , 0 for January .
* @ param date The value used to set the DATE time field .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
void set ( int32_t year , int32_t month , int32_t date ) ;
/**
* 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 .
*
* @ param year The value used to set the YEAR time field .
* @ param month The value used to set the MONTH time field . Month value is
* 0 - based . E . g . , 0 for January .
* @ param date The value used to set the DATE time field .
* @ param hour The value used to set the HOUR_OF_DAY time field .
* @ param minute The value used to set the MINUTE time field .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
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 , MINUTE , and SECOND .
* Other field values are retained ; call clear ( ) first if this is not desired .
*
* @ param year The value used to set the YEAR time field .
* @ param month The value used to set the MONTH time field . Month value is
* 0 - based . E . g . , 0 for January .
* @ param date The value used to set the DATE time field .
* @ param hour The value used to set the HOUR_OF_DAY time field .
* @ param minute The value used to set the MINUTE time field .
* @ param second The value used to set the SECOND time field .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
void set ( int32_t year , int32_t month , int32_t date , int32_t hour , int32_t minute , int32_t second ) ;
/**
* 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 .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
void clear ( void ) ;
/**
* 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 .
*
* @ param field The time field to be cleared .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use clear ( UCalendarDateFields field ) instead .
*/
void 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 .
*
* @ param field The time field to be cleared .
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-02-21 08:32:22 +00:00
void clear ( UCalendarDateFields field ) ;
1999-12-28 23:57:50 +00:00
/**
* 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 .
* < P >
* Concrete subclasses of Calendar must implement getDynamicClassID ( ) and also a
* static method and data member :
*
2004-06-15 20:52:22 +00:00
* static UClassID getStaticClassID ( ) { return ( UClassID ) & amp ; fgClassID ; }
1999-12-28 23:57:50 +00:00
* static char fgClassID ;
*
* @ return 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 .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
virtual UClassID getDynamicClassID ( void ) const = 0 ;
2003-05-21 16:29:56 +00:00
/**
* Returns the resource key string used for this calendar type .
* For example , prepending " Eras_ " to this string could return " Eras_japanese "
2004-08-24 17:38:33 +00:00
* or " Eras_gregorian " .
2003-05-21 16:29:56 +00:00
*
* @ returns static string , for example , " gregorian " or " japanese "
2003-05-25 07:12:19 +00:00
* @ internal
2003-05-21 16:29:56 +00:00
*/
virtual const char * getType ( ) const = 0 ;
1999-12-28 23:57:50 +00:00
protected :
/**
* Constructs a Calendar with the default time zone as returned by
* TimeZone : : createInstance ( ) , and the default locale .
*
* @ param success Indicates the status of Calendar object construction . Returns
* U_ZERO_ERROR if constructed successfully .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
Calendar ( UErrorCode & success ) ;
/**
* Copy constructor
2002-07-01 11:04:45 +00:00
*
* @ param source Calendar object to be copied from
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
Calendar ( const Calendar & source ) ;
/**
* Default assignment operator
2002-07-01 11:04:45 +00:00
*
* @ param right Calendar object to be copied
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
Calendar & operator = ( const Calendar & right ) ;
/**
* 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 .
*
2002-07-01 11:04:45 +00:00
* @ param zone The given time zone .
1999-12-28 23:57:50 +00:00
* @ param aLocale The given locale .
* @ param success Indicates the status of Calendar object construction . Returns
* U_ZERO_ERROR if constructed successfully .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
Calendar ( TimeZone * zone , const Locale & aLocale , UErrorCode & success ) ;
/**
* Constructs a Calendar with the given time zone and locale .
*
* @ param zone The given time zone .
* @ param aLocale The given locale .
* @ param success Indicates the status of Calendar object construction . Returns
* U_ZERO_ERROR if constructed successfully .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
Calendar ( const TimeZone & zone , const Locale & aLocale , UErrorCode & success ) ;
/**
* Converts Calendar ' s time field values to GMT as milliseconds .
*
* @ param 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 .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2003-10-26 10:24:58 +00:00
virtual void computeTime ( UErrorCode & status ) ;
1999-12-28 23:57:50 +00:00
/**
* 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 ( ) .
2002-07-01 11:04:45 +00:00
*
* @ param 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 .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2003-10-26 10:24:58 +00:00
virtual void computeFields ( UErrorCode & status ) ;
1999-12-28 23:57:50 +00:00
/**
* Gets this Calendar ' s current time as a long .
2002-07-01 11:04:45 +00:00
*
* @ param 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 .
1999-12-28 23:57:50 +00:00
* @ return the current time as UTC milliseconds from the epoch .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
double getTimeInMillis ( UErrorCode & status ) const ;
/**
* Sets this Calendar ' s current time from the given long value .
2002-07-01 11:04:45 +00:00
* @ param millis the new time in UTC milliseconds from the epoch .
* @ param 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 .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
void setTimeInMillis ( double millis , UErrorCode & status ) ;
/**
* Recomputes the current time from currently set fields , and then fills in any
* unset fields in the time field list .
*
* @ param 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 .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
void complete ( UErrorCode & status ) ;
/**
* Gets the value for a given time field . Subclasses can use this function to get
* field values without forcing recomputation of time .
*
* @ param field The given time field .
* @ return The value for the given time field .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use internalGet ( UCalendarDateFields field ) instead .
*/
2003-05-16 20:33:01 +00:00
inline int32_t internalGet ( EDateFields field ) const { return fFields [ field ] ; }
2003-02-28 13:21:23 +00:00
2003-10-26 10:24:58 +00:00
/**
* Gets the value for a given time field . Subclasses can use this function to get
* field values without forcing recomputation of time . If the field ' s stamp is UNSET ,
* the defaultValue is used .
*
* @ param field The given time field .
* @ param defaultValue a default value used if the field is unset .
* @ return The value for the given time field .
* @ internal
*/
inline int32_t internalGet ( UCalendarDateFields field , int32_t defaultValue ) const { return fStamp [ field ] > kUnset ? fFields [ field ] : defaultValue ; }
2003-02-28 13:21:23 +00:00
/**
* Gets the value for a given time field . Subclasses can use this function to get
* field values without forcing recomputation of time .
*
* @ param field The given time field .
* @ return The value for the given time field .
2003-10-26 10:24:58 +00:00
* @ internal
1999-12-28 23:57:50 +00:00
*/
2003-05-16 20:33:01 +00:00
inline int32_t internalGet ( UCalendarDateFields field ) const { return fFields [ field ] ; }
1999-12-28 23:57:50 +00:00
/**
* 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 .
2002-07-01 11:04:45 +00:00
*
* @ param field The given time field .
* @ param value The value for the given time field .
2003-02-28 13:21:23 +00:00
* @ deprecated ICU 2.6 . Use internalSet ( UCalendarDateFields field , int32_t value ) instead .
*/
void internalSet ( EDateFields field , int32_t value ) ;
/**
* 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 .
*
* @ param field The given time field .
* @ param value The value for the given time field .
* @ draft ICU 2.6 .
1999-12-28 23:57:50 +00:00
*/
2003-05-16 20:33:01 +00:00
inline void internalSet ( UCalendarDateFields field , int32_t value ) ;
1999-12-28 23:57:50 +00:00
2003-10-26 10:24:58 +00:00
/**
* Prepare this calendar for computing the actual minimum or maximum .
* This method modifies this calendar ' s fields ; it is called on a
* temporary calendar .
* @ internal
*/
virtual void prepareGetActual ( UCalendarDateFields field , UBool isMinimum , UErrorCode & status ) ;
2004-08-24 17:38:33 +00:00
2003-11-12 09:01:41 +00:00
/**
2004-05-27 20:40:17 +00:00
* Limit enums . Not in sync with UCalendarLimitType ( refers to internal fields ) .
2004-08-24 17:38:33 +00:00
* @ internal
2003-11-12 09:01:41 +00:00
*/
2004-08-24 17:38:33 +00:00
enum ELimitType {
UCAL_LIMIT_MINIMUM = 0 ,
UCAL_LIMIT_GREATEST_MINIMUM ,
UCAL_LIMIT_LEAST_MAXIMUM ,
UCAL_LIMIT_MAXIMUM ,
2003-11-19 05:38:55 +00:00
UCAL_LIMIT_COUNT
2003-11-12 09:01:41 +00:00
} ;
2004-08-24 17:38:33 +00:00
2003-10-26 10:24:58 +00:00
/**
* Subclass API for defining limits of different types .
* Subclasses must implement this method to return limits for the
* following fields :
*
* < pre > UCAL_ERA
* UCAL_YEAR
* UCAL_MONTH
* UCAL_WEEK_OF_YEAR
* UCAL_WEEK_OF_MONTH
* UCAL_DATE ( DAY_OF_MONTH on Java )
* UCAL_DAY_OF_YEAR
* UCAL_DAY_OF_WEEK_IN_MONTH
* UCAL_YEAR_WOY
* UCAL_EXTENDED_YEAR < / pre >
*
* @ param field one of the above field numbers
* @ param limitType one of < code > MINIMUM < / code > , < code > GREATEST_MINIMUM < / code > ,
* < code > LEAST_MAXIMUM < / code > , or < code > MAXIMUM < / code >
* @ internal
*/
virtual int32_t handleGetLimit ( UCalendarDateFields field , ELimitType limitType ) const = 0 ;
/**
* Return a limit for a field .
2004-06-08 21:47:15 +00:00
* @ param field the field , from < code > 0. . UCAL_MAX_FIELD < / code >
2003-10-26 10:24:58 +00:00
* @ param limitType the type specifier for the limit
* @ see # ELimitType
* @ internal
*/
2003-11-19 05:38:55 +00:00
virtual int32_t getLimit ( UCalendarDateFields field , ELimitType limitType ) const ;
2003-10-26 10:24:58 +00:00
/**
* Return the Julian day number of day before the first day of the
* given month in the given extended year . Subclasses should override
* this method to implement their calendar system .
* @ param eyear the extended year
* @ param month the zero - based month , or 0 if useMonth is false
* @ param useMonth if false , compute the day before the first day of
* the given year , otherwise , compute the day before the first day of
* the given month
2004-05-25 03:23:31 +00:00
* @ return the Julian day number of the day before the first
2003-10-26 10:24:58 +00:00
* day of the given month and year
* @ internal
*/
virtual int32_t handleComputeMonthStart ( int32_t eyear , int32_t month ,
UBool useMonth ) const = 0 ;
/**
* Return the number of days in the given month of the given extended
* year of this calendar system . Subclasses should override this
* method if they can provide a more correct or more efficient
* implementation than the default implementation in Calendar .
* @ internal
*/
virtual int32_t handleGetMonthLength ( int32_t extendedYear , int32_t month ) const ;
/**
* Return the number of days in the given extended year of this
* calendar system . Subclasses should override this method if they can
* provide a more correct or more efficient implementation than the
* default implementation in Calendar .
* @ stable ICU 2.0
*/
2003-10-28 01:52:29 +00:00
virtual int32_t handleGetYearLength ( int32_t eyear ) const ;
2003-10-26 10:24:58 +00:00
/**
* Return the extended year defined by the current fields . This will
* use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra - year fields ( such
* as UCAL_ERA ) specific to the calendar system , depending on which set of
* fields is newer .
* @ return the extended year
* @ internal
*/
virtual int32_t handleGetExtendedYear ( ) = 0 ;
/**
* Subclasses may override this . This method calls
* handleGetMonthLength ( ) to obtain the calendar - specific month
* length .
2004-08-24 17:38:33 +00:00
* @ param bestField which field to use to calculate the date
2003-11-12 09:01:41 +00:00
* @ return julian day specified by calendar fields .
2003-10-26 10:24:58 +00:00
* @ internal
*/
virtual int32_t handleComputeJulianDay ( UCalendarDateFields bestField ) ;
2004-08-24 17:38:33 +00:00
/**
* Subclasses must override this to convert from week fields
2003-10-26 10:24:58 +00:00
* ( YEAR_WOY and WEEK_OF_YEAR ) to an extended year in the case
* where YEAR , EXTENDED_YEAR are not set .
* The Calendar implementation assumes yearWoy is in extended gregorian form
* @ internal
* @ return the extended year , UCAL_EXTENDED_YEAR
*/
virtual int32_t handleGetExtendedYearFromWeekFields ( int32_t yearWoy , int32_t woy ) ;
2003-11-12 09:01:41 +00:00
/**
* Compute the Julian day from fields . Will determine whether to use
* the JULIAN_DAY field directly , or other fields .
* @ return the julian day
* @ internal
*/
2003-10-26 10:24:58 +00:00
int32_t computeJulianDay ( ) ;
2004-08-24 17:38:33 +00:00
2003-10-26 10:24:58 +00:00
/**
* Compute the milliseconds in the day from the fields . This is a
* value from 0 to 23 : 59 : 59.999 inclusive , unless fields are out of
* range , in which case it can be an arbitrary value . This value
* reflects local zone wall time .
* @ internal
*/
int32_t computeMillisInDay ( ) ;
/**
* This method can assume EXTENDED_YEAR has been set .
* @ param millis milliseconds of the date fields
* @ param millisInDay milliseconds of the time fields ; may be out
* or range .
2004-05-25 03:23:31 +00:00
* @ param ec Output param set to failure code on function return
* when this function fails .
2003-10-26 10:24:58 +00:00
* @ internal
*/
int32_t computeZoneOffset ( double millis , int32_t millisInDay , UErrorCode & ec ) ;
/**
2003-11-12 09:01:41 +00:00
* Determine the best stamp in a range .
2003-10-26 10:24:58 +00:00
* @ param start first enum to look at
* @ param end last enum to look at
2004-05-25 03:23:31 +00:00
* @ param bestSoFar stamp prior to function call
2003-11-12 09:01:41 +00:00
* @ return the stamp value of the best stamp
* @ internal
2003-10-26 10:24:58 +00:00
*/
int32_t newestStamp ( UCalendarDateFields start , UCalendarDateFields end , int32_t bestSoFar ) const ;
/**
2003-11-19 05:38:55 +00:00
* Values for field resolution tables
2003-10-26 10:24:58 +00:00
* @ see # resolveFields
* @ internal
*/
2003-11-19 05:38:55 +00:00
enum {
/** Marker for end of resolve set (row or group). */
kResolveSTOP = - 1 ,
/** Value to be bitwised "ORed" against resolve table field values for remapping. Example: (UCAL_DATE | kResolveRemap) in 1st column will cause 'UCAL_DATE' to be returned, but will not examine the value of UCAL_DATE. */
kResolveRemap = 32
} ;
2003-10-26 10:24:58 +00:00
/**
2003-11-12 09:01:41 +00:00
* Precedence table for Dates
* @ see # resolveFields
* @ internal
2003-10-26 10:24:58 +00:00
*/
static const UFieldResolutionTable kDatePrecedence [ ] ;
2003-11-12 09:01:41 +00:00
/**
* Precedence table for Year
* @ see # resolveFields
* @ internal
*/
2003-10-26 10:24:58 +00:00
static const UFieldResolutionTable kYearPrecedence [ ] ;
2003-11-12 09:01:41 +00:00
/**
* Precedence table for Day of Week
* @ see # resolveFields
* @ internal
*/
2003-10-26 10:24:58 +00:00
static const UFieldResolutionTable kDOWPrecedence [ ] ;
/**
* Given a precedence table , return the newest field combination in
2003-12-03 00:11:17 +00:00
* the table , or UCAL_FIELD_COUNT if none is found .
2003-10-26 10:24:58 +00:00
*
* < p > The precedence table is a 3 - dimensional array of integers . It
* may be thought of as an array of groups . Each group is an array of
* lines . Each line is an array of field numbers . Within a line , if
* all fields are set , then the time stamp of the line is taken to be
* the stamp of the most recently set field . If any field of a line is
* unset , then the line fails to match . Within a group , the line with
* the newest time stamp is selected . The first field of the line is
* returned to indicate which line matched .
*
* < p > In some cases , it may be desirable to map a line to field that
* whose stamp is NOT examined . For example , if the best field is
* DAY_OF_WEEK then the DAY_OF_WEEK_IN_MONTH algorithm may be used . In
2003-11-19 05:38:55 +00:00
* order to do this , insert the value < code > kResolveRemap | F < / code > at
2003-10-26 10:24:58 +00:00
* the start of the line , where < code > F < / code > is the desired return
* field value . This field will NOT be examined ; it only determines
* the return value if the other fields in the line are the newest .
*
* < p > If all lines of a group contain at least one unset field , then no
* line will match , and the group as a whole will fail to match . In
* that case , the next group will be processed . If all groups fail to
2003-12-03 00:11:17 +00:00
* match , then UCAL_FIELD_COUNT is returned .
2003-10-26 10:24:58 +00:00
* @ internal
*/
UCalendarDateFields resolveFields ( const UFieldResolutionTable * precedenceTable ) ;
2004-06-17 18:57:52 +00:00
/**
* @ internal
*/
2003-10-26 10:24:58 +00:00
virtual const UFieldResolutionTable * getFieldResolutionTable ( ) const ;
/**
* Return the field that is newer , either defaultField , or
* alternateField . If neither is newer or neither is set , return defaultField .
* @ internal
*/
UCalendarDateFields newerField ( UCalendarDateFields defaultField , UCalendarDateFields alternateField ) const ;
2004-08-24 17:38:33 +00:00
private :
2003-11-12 09:01:41 +00:00
/**
* Helper function for calculating limits by trial and error
* @ param field The field being investigated
* @ param startValue starting ( least max ) value of field
* @ param endValue ending ( greatest max ) value of field
* @ param status return type
* @ internal
*/
2003-10-26 10:24:58 +00:00
int32_t getActualHelper ( UCalendarDateFields field , int32_t startValue , int32_t endValue , UErrorCode & status ) const ;
1999-12-28 23:57:50 +00:00
protected :
/**
* The flag which indicates if the current time is set in the calendar .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2000-05-18 22:08:39 +00:00
UBool fIsTimeSet ;
1999-12-28 23:57:50 +00:00
/**
* 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 .
* < P >
* This should really be named areFieldsInSync , but the old name is retained
* for backward compatibility .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2000-05-18 22:08:39 +00:00
UBool fAreFieldsSet ;
1999-12-28 23:57:50 +00:00
/**
* True if all of the fields have been set . This is initially false , and set to
* true by computeFields ( ) .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2000-05-18 22:08:39 +00:00
UBool fAreAllFieldsSet ;
1999-12-28 23:57:50 +00:00
2004-03-04 23:24:43 +00:00
/**
* True if all fields have been virtually set , but have not yet been
* computed . This occurs only in setTimeInMillis ( ) . A calendar set
* to this state will compute all fields from the time if it becomes
* necessary , but otherwise will delay such computation .
2004-06-15 20:52:22 +00:00
* @ draft ICU 3.0
2004-03-04 23:24:43 +00:00
*/
UBool fAreFieldsVirtuallySet ;
1999-12-28 23:57:50 +00:00
/**
* Get the current time without recomputing .
2002-07-01 11:04:45 +00:00
*
* @ return the current time without recomputing .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
UDate internalGetTime ( void ) const { return fTime ; }
/**
* Set the current time without affecting flags or fields .
2002-07-01 11:04:45 +00:00
*
* @ param time The time to be set
* @ return the current time without recomputing .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
void internalSetTime ( UDate time ) { fTime = time ; }
/**
* The time fields containing values into which the millis is computed .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2003-02-21 08:32:22 +00:00
int32_t fFields [ UCAL_FIELD_COUNT ] ;
1999-12-28 23:57:50 +00:00
/**
* The flags which tell if a specified time field for the calendar is set .
2003-10-26 10:24:58 +00:00
* @ deprecated ICU 2.8 use ( fStamp [ n ] ! = kUnset )
1999-12-28 23:57:50 +00:00
*/
2003-02-21 08:32:22 +00:00
UBool fIsSet [ UCAL_FIELD_COUNT ] ;
1999-12-28 23:57:50 +00:00
2001-11-14 21:22:13 +00:00
/** Special values of stamp[]
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
2001-11-14 21:22:13 +00:00
*/
2000-01-25 02:15:41 +00:00
enum {
1999-12-28 23:57:50 +00:00
kUnset = 0 ,
kInternallySet ,
kMinimumUserStamp
} ;
/**
* 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 .
2002-12-04 23:46:16 +00:00
* @ stable ICU 2.0
1999-12-28 23:57:50 +00:00
*/
2003-02-21 08:32:22 +00:00
int32_t fStamp [ UCAL_FIELD_COUNT ] ;
1999-12-28 23:57:50 +00:00
2003-10-26 10:24:58 +00:00
/**
* Subclasses may override this method to compute several fields
* specific to each calendar system . These are :
*
* < ul > < li > ERA
* < li > YEAR
* < li > MONTH
* < li > DAY_OF_MONTH
* < li > DAY_OF_YEAR
* < li > EXTENDED_YEAR < / ul >
*
* Subclasses can refer to the DAY_OF_WEEK and DOW_LOCAL fields , which
* will be set when this method is called . Subclasses can also call
* the getGregorianXxx ( ) methods to obtain Gregorian calendar
* equivalents for the given Julian day .
*
* < p > In addition , subclasses should compute any subclass - specific
* fields , that is , fields from BASE_FIELD_COUNT to
* getFieldCount ( ) - 1.
*
* < p > The default implementation in < code > Calendar < / code > implements
* a pure proleptic Gregorian calendar .
* @ internal
*/
virtual void handleComputeFields ( int32_t julianDay , UErrorCode & status ) ;
/**
* Return the extended year on the Gregorian calendar as computed by
* < code > computeGregorianFields ( ) < / code > .
* @ see # computeGregorianFields
2003-11-12 09:01:41 +00:00
* @ internal
2003-10-26 10:24:58 +00:00
*/
int32_t getGregorianYear ( ) const {
return fGregorianYear ;
}
/**
* Return the month ( 0 - based ) on the Gregorian calendar as computed by
* < code > computeGregorianFields ( ) < / code > .
* @ see # computeGregorianFields
2003-11-12 09:01:41 +00:00
* @ internal
2003-10-26 10:24:58 +00:00
*/
int32_t getGregorianMonth ( ) const {
return fGregorianMonth ;
}
/**
* Return the day of year ( 1 - based ) on the Gregorian calendar as
* computed by < code > computeGregorianFields ( ) < / code > .
* @ see # computeGregorianFields
2003-11-12 09:01:41 +00:00
* @ internal
2003-10-26 10:24:58 +00:00
*/
int32_t getGregorianDayOfYear ( ) const {
return fGregorianDayOfYear ;
}
/**
* Return the day of month ( 1 - based ) on the Gregorian calendar as
* computed by < code > computeGregorianFields ( ) < / code > .
* @ see # computeGregorianFields
2003-11-12 09:01:41 +00:00
* @ internal
2003-10-26 10:24:58 +00:00
*/
int32_t getGregorianDayOfMonth ( ) const {
return fGregorianDayOfMonth ;
}
/**
* Called by computeJulianDay . Returns the default month ( 0 - based ) for the year ,
* taking year and era into account . Defaults to 0 for Gregorian , which doesn ' t care .
* @ internal
2003-11-12 09:01:41 +00:00
* @ internal
2003-10-26 10:24:58 +00:00
*/
virtual int32_t getDefaultMonthInYear ( ) ;
/**
* Called by computeJulianDay . Returns the default day ( 1 - based ) for the month ,
2003-11-12 09:01:41 +00:00
* taking currently - set year and era into account . Defaults to 1 for Gregorian .
2003-10-26 10:24:58 +00:00
* @ internal
*/
virtual int32_t getDefaultDayInMonth ( int32_t /*month*/ ) ;
//-------------------------------------------------------------------------
// Protected utility methods for use by subclasses. These are very handy
// for implementing add, roll, and computeFields.
//-------------------------------------------------------------------------
/**
* Adjust the specified field so that it is within
* the allowable range for the date to which this calendar is set .
2004-05-27 06:06:03 +00:00
* For example , in a Gregorian calendar pinning the { @ link # UCalendarDateFields DAY_OF_MONTH }
2003-10-26 10:24:58 +00:00
* field for a calendar set to April 31 would cause it to be set
* to April 30.
* < p >
* < b > Subclassing : < / b >
* < br >
* This utility method is intended for use by subclasses that need to implement
* their own overrides of { @ link # roll roll } and { @ link # add add } .
* < p >
* < b > Note : < / b >
* < code > pinField < / code > is implemented in terms of
* { @ link # getActualMinimum getActualMinimum }
* and { @ link # getActualMaximum getActualMaximum } . If either of those methods uses
* a slow , iterative algorithm for a particular field , it would be
* unwise to attempt to call < code > pinField < / code > for that field . If you
* really do need to do so , you should override this method to do
* something more efficient for that field .
* < p >
* @ param field The calendar field whose value should be pinned .
2004-05-25 03:23:31 +00:00
* @ param status Output param set to failure code on function return
* when this function fails .
2003-10-26 10:24:58 +00:00
*
* @ see # getActualMinimum
* @ see # getActualMaximum
* @ stable ICU 2.0
*/
virtual void pinField ( UCalendarDateFields field , UErrorCode & status ) ;
/**
* Return the week number of a day , within a period . This may be the week number in
* a year or the week number in a month . Usually this will be a value > = 1 , but if
* some initial days of the period are excluded from week 1 , because
* { @ link # getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek } is > 1 , then
* the week number will be zero for those
* initial days . This method requires the day number and day of week for some
* known date in the period in order to determine the day of week
* on the desired day .
* < p >
* < b > Subclassing : < / b >
* < br >
* This method is intended for use by subclasses in implementing their
* { @ link # computeTime computeTime } and / or { @ link # computeFields computeFields } methods .
* It is often useful in { @ link # getActualMinimum getActualMinimum } and
* { @ link # getActualMaximum getActualMaximum } as well .
* < p >
* This variant is handy for computing the week number of some other
* day of a period ( often the first or last day of the period ) when its day
* of the week is not known but the day number and day of week for some other
* day in the period ( e . g . the current date ) < em > is < / em > known .
* < p >
2004-05-27 06:06:03 +00:00
* @ param desiredDay The { @ link # UCalendarDateFields DAY_OF_YEAR } or
* { @ link # UCalendarDateFields DAY_OF_MONTH } whose week number is desired .
2003-10-26 10:24:58 +00:00
* Should be 1 for the first day of the period .
*
2004-05-27 06:06:03 +00:00
* @ param dayOfPeriod The { @ link # UCalendarDateFields DAY_OF_YEAR }
* or { @ link # UCalendarDateFields DAY_OF_MONTH } for a day in the period whose
* { @ link # UCalendarDateFields DAY_OF_WEEK } is specified by the
2003-10-26 10:24:58 +00:00
* < code > knownDayOfWeek < / code > parameter .
* Should be 1 for first day of period .
*
2004-05-27 06:06:03 +00:00
* @ param dayOfWeek The { @ link # UCalendarDateFields DAY_OF_WEEK } for the day
2003-10-26 10:24:58 +00:00
* corresponding to the < code > knownDayOfPeriod < / code > parameter .
* 1 - based with 1 = Sunday .
*
* @ return The week number ( one - based ) , or zero if the day falls before
* the first week because
* { @ link # getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek }
* is more than one .
2004-06-15 20:52:22 +00:00
*
* @ draft ICU 2.8
2003-10-26 10:24:58 +00:00
*/
int32_t weekNumber ( int32_t desiredDay , int32_t dayOfPeriod , int32_t dayOfWeek ) ;
/**
* Return the week number of a day , within a period . This may be the week number in
* a year , or the week number in a month . Usually this will be a value > = 1 , but if
* some initial days of the period are excluded from week 1 , because
* { @ link # getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek } is > 1 ,
* then the week number will be zero for those
* initial days . This method requires the day of week for the given date in order to
* determine the result .
* < p >
* < b > Subclassing : < / b >
* < br >
* This method is intended for use by subclasses in implementing their
* { @ link # computeTime computeTime } and / or { @ link # computeFields computeFields } methods .
* It is often useful in { @ link # getActualMinimum getActualMinimum } and
* { @ link # getActualMaximum getActualMaximum } as well .
* < p >
2004-05-27 06:06:03 +00:00
* @ param dayOfPeriod The { @ link # UCalendarDateFields DAY_OF_YEAR } or
* { @ link # UCalendarDateFields DAY_OF_MONTH } whose week number is desired .
2003-10-26 10:24:58 +00:00
* Should be 1 for the first day of the period .
*
2004-05-27 06:06:03 +00:00
* @ param dayOfWeek The { @ link # UCalendarDateFields DAY_OF_WEEK } for the day
2003-10-26 10:24:58 +00:00
* corresponding to the < code > dayOfPeriod < / code > parameter .
* 1 - based with 1 = Sunday .
*
* @ return The week number ( one - based ) , or zero if the day falls before
* the first week because
* { @ link # getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek }
* is more than one .
2003-11-12 09:01:41 +00:00
* @ internal
2003-10-26 10:24:58 +00:00
*/
inline int32_t weekNumber ( int32_t dayOfPeriod , int32_t dayOfWeek ) ;
/**
* returns the local DOW , valid range 0. .6
2003-11-12 09:01:41 +00:00
* @ internal
2003-10-26 10:24:58 +00:00
*/
int32_t getLocalDOW ( ) ;
1999-12-28 23:57:50 +00:00
private :
2003-11-12 09:01:41 +00:00
/**
* The next available value for fStamp [ ]
*/
1999-12-28 23:57:50 +00:00
int32_t fNextStamp ; // = MINIMUM_USER_STAMP;
/**
* The current time set for the calendar .
*/
UDate fTime ;
/**
* @ see # setLenient
*/
2000-05-18 22:08:39 +00:00
UBool fLenient ;
1999-12-28 23:57:50 +00:00
/**
* Time zone affects the time calculation done by Calendar . Calendar subclasses use
* the time zone data to produce the local time .
*/
TimeZone * fZone ;
/**
* Both firstDayOfWeek and minimalDaysInFirstWeek are locale - dependent . They are
* used to figure out the week count for a specific date for a given locale . These
* must be set when a Calendar is constructed . For example , in US locale ,
* firstDayOfWeek is SUNDAY ; minimalDaysInFirstWeek is 1. They are used to figure
* out the week count for a specific date for a given locale . These must be set when
* a Calendar is constructed .
*/
2003-02-21 08:32:22 +00:00
UCalendarDaysOfWeek fFirstDayOfWeek ;
1999-12-28 23:57:50 +00:00
uint8_t fMinimalDaysInFirstWeek ;
/**
* Sets firstDayOfWeek and minimalDaysInFirstWeek . Called at Calendar construction
* time .
*
* @ param desiredLocale The given locale .
2004-05-18 23:08:35 +00:00
* @ param type The calendar type identifier , e . g : gregorian , buddhist , etc .
1999-12-28 23:57:50 +00:00
* @ param success Indicates the status of setting the week count data from
* the resource for the given locale . Returns U_ZERO_ERROR if
* constructed successfully .
*/
2004-05-18 23:08:35 +00:00
void setWeekCountData ( const Locale & desiredLocale , const char * type , UErrorCode & success ) ;
1999-12-28 23:57:50 +00:00
/**
* Recompute the time and update the status fields isTimeSet
* and areFieldsSet . Callers should check isTimeSet and only
* call this method if isTimeSet is false .
2002-07-01 11:04:45 +00:00
*
* @ param 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 .
1999-12-28 23:57:50 +00:00
*/
void updateTime ( UErrorCode & status ) ;
/**
* The resource tag for the resource where the week - count data is stored .
*/
2001-09-28 19:13:03 +00:00
static const char kDateTimeElements [ ] ;
2003-05-15 22:30:24 +00:00
/**
* The resource tag where the default calendar is stored .
*/
static const char kDefaultCalendar [ ] ;
2004-08-24 17:38:33 +00:00
2003-10-26 10:24:58 +00:00
/**
* The Gregorian year , as computed by computeGregorianFields ( ) and
* returned by getGregorianYear ( ) .
*/
int32_t fGregorianYear ;
/**
* The Gregorian month , as computed by computeGregorianFields ( ) and
* returned by getGregorianMonth ( ) .
*/
int32_t fGregorianMonth ;
/**
* The Gregorian day of the year , as computed by
* computeGregorianFields ( ) and returned by getGregorianDayOfYear ( ) .
*/
int32_t fGregorianDayOfYear ;
/**
* The Gregorian day of the month , as computed by
* computeGregorianFields ( ) and returned by getGregorianDayOfMonth ( ) .
*/
int32_t fGregorianDayOfMonth ;
/* calculations */
/**
* Compute the Gregorian calendar year , month , and day of month from
* the given Julian day . These values are not stored in fields , but in
* member variables gregorianXxx . Also compute the DAY_OF_WEEK and
* DOW_LOCAL fields .
*/
void computeGregorianAndDOWFields ( int32_t julianDay , UErrorCode & ec ) ;
/**
* Compute the Gregorian calendar year , month , and day of month from the
* Julian day . These values are not stored in fields , but in member
* variables gregorianXxx . They are used for time zone computations and by
* subclasses that are Gregorian derivatives . Subclasses may call this
* method to perform a Gregorian calendar millis - > fields computation .
* To perform a Gregorian calendar fields - > millis computation , call
* computeGregorianMonthStart ( ) .
* @ see # computeGregorianMonthStart
*/
void computeGregorianFields ( int32_t julianDay , UErrorCode & ec ) ;
/**
* Compute the fields WEEK_OF_YEAR , YEAR_WOY , WEEK_OF_MONTH ,
* DAY_OF_WEEK_IN_MONTH , and DOW_LOCAL from EXTENDED_YEAR , YEAR ,
* DAY_OF_WEEK , and DAY_OF_YEAR . The latter fields are computed by the
* subclass based on the calendar system .
*
* < p > The YEAR_WOY field is computed simplistically . It is equal to YEAR
* most of the time , but at the year boundary it may be adjusted to YEAR - 1
* or YEAR + 1 to reflect the overlap of a week into an adjacent year . In
* this case , a simple increment or decrement is performed on YEAR , even
* though this may yield an invalid YEAR value . For instance , if the YEAR
* is part of a calendar system with an N - year cycle field CYCLE , then
* incrementing the YEAR may involve incrementing CYCLE and setting YEAR
* back to 0 or 1. This is not handled by this code , and in fact cannot be
* simply handled without having subclasses define an entire parallel set of
* fields for fields larger than or equal to a year . This additional
* complexity is not warranted , since the intention of the YEAR_WOY field is
* to support ISO 8601 notation , so it will typically be used with a
* proleptic Gregorian calendar , which has no field larger than a year .
*/
void computeWeekFields ( UErrorCode & ec ) ;
/**
* Ensure that each field is within its valid range by calling { @ link
2004-06-17 18:57:52 +00:00
* # validateField ( int , int & ) } on each field that has been set . This method
2003-10-26 10:24:58 +00:00
* should only be called if this calendar is not lenient .
* @ see # isLenient
2004-06-15 20:52:22 +00:00
* @ see # validateField ( int , int & )
2003-10-26 10:24:58 +00:00
* @ internal
*/
void validateFields ( UErrorCode & status ) ;
/**
* Validate a single field of this calendar . Subclasses should
* override this method to validate any calendar - specific fields .
* Generic fields can be handled by
* < code > Calendar . validateField ( ) < / code > .
2004-06-15 20:52:22 +00:00
* @ see # validateField ( int , int , int , int & )
2003-10-26 10:24:58 +00:00
* @ internal
*/
virtual void validateField ( UCalendarDateFields field , UErrorCode & status ) ;
/**
* Validate a single field of this calendar given its minimum and
2004-08-24 17:38:33 +00:00
* maximum allowed value . If the field is out of range ,
2003-10-26 10:24:58 +00:00
* < code > U_ILLEGAL_ARGUMENT_ERROR < / code > will be set . Subclasses may
* use this method in their implementation of { @ link
2004-06-15 20:52:22 +00:00
* # validateField ( int , int & ) } .
2003-10-26 10:24:58 +00:00
* @ internal
*/
void validateField ( UCalendarDateFields field , int32_t min , int32_t max , UErrorCode & status ) ;
protected :
/**
* Convert a quasi Julian date to the day of the week . The Julian date used here is
* not a true Julian date , since it is measured from midnight , not noon . Return
* value is one - based .
*
* @ param julian The given Julian date number .
* @ return Day number from 1. .7 ( SUN . . SAT ) .
2003-11-12 09:01:41 +00:00
* @ internal
2003-10-26 10:24:58 +00:00
*/
static uint8_t julianDayToDayOfWeek ( double julian ) ;
2003-05-15 22:30:24 +00:00
2004-01-20 23:06:38 +00:00
private :
2004-01-12 22:39:41 +00:00
char validLocale [ ULOC_FULLNAME_CAPACITY ] ;
char actualLocale [ ULOC_FULLNAME_CAPACITY ] ;
2003-11-14 21:08:16 +00:00
2003-05-21 16:29:56 +00:00
public :
2004-09-10 04:51:24 +00:00
# if !UCONFIG_NO_SERVICE
2004-08-24 17:38:33 +00:00
/**
2003-05-15 22:30:24 +00:00
* INTERNAL FOR 2.6 - - Registration .
*/
/**
2004-08-24 17:38:33 +00:00
* Return a StringEnumeration over the locales available at the time of the call ,
2003-05-15 22:30:24 +00:00
* including registered locales .
* @ return a StringEnumeration over the locales available at the time of the call
* @ internal
*/
static StringEnumeration * getAvailableLocales ( void ) ;
/**
* Register a new Calendar factory . The factory will be adopted .
* INTERNAL in 2.6
* @ param toAdopt the factory instance to be adopted
* @ param status the in / out status code , no special meanings are assigned
* @ return a registry key that can be used to unregister this factory
* @ internal
*/
static URegistryKey registerFactory ( ICUServiceFactory * toAdopt , UErrorCode & status ) ;
/**
* 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
* @ param key the registry key returned by a previous call to registerFactory
* @ param status the in / out status code , no special meanings are assigned
* @ return TRUE if the factory for the key was successfully unregistered
* @ internal
*/
static UBool unregister ( URegistryKey key , UErrorCode & status ) ;
2004-08-24 17:38:33 +00:00
2003-06-03 01:58:15 +00:00
/**
* Multiple Calendar Implementation
2004-08-24 17:38:33 +00:00
* @ internal
2003-06-03 01:58:15 +00:00
*/
2003-05-15 22:30:24 +00:00
friend class CalendarFactory ;
2003-06-03 01:58:15 +00:00
/**
* Multiple Calendar Implementation
2004-08-24 17:38:33 +00:00
* @ internal
2003-06-03 01:58:15 +00:00
*/
2003-05-15 22:30:24 +00:00
friend class CalendarService ;
2003-06-03 01:58:15 +00:00
/**
* Multiple Calendar Implementation
2004-08-24 17:38:33 +00:00
* @ internal
2003-06-03 01:58:15 +00:00
*/
2003-05-15 22:30:24 +00:00
friend class DefaultCalendarFactory ;
2004-09-10 04:51:24 +00:00
# endif /* !UCONFIG_NO_SERVICE */
2003-05-25 07:12:19 +00:00
/**
2004-08-24 17:38:33 +00:00
* @ internal
2003-06-03 01:58:15 +00:00
* @ return TRUE if this calendar has a default century ( i . e . 03 - > 2003 )
2003-05-25 07:12:19 +00:00
*/
virtual UBool haveDefaultCentury ( ) const = 0 ;
2003-06-03 01:58:15 +00:00
2003-05-25 07:12:19 +00:00
/**
* @ internal
2003-06-03 01:58:15 +00:00
* @ return the start of the default century , as a UDate
2003-05-25 07:12:19 +00:00
*/
virtual UDate defaultCenturyStart ( ) const = 0 ;
/**
2004-08-24 17:38:33 +00:00
* @ internal
2003-06-03 01:58:15 +00:00
* @ return the beginning year of the default century , as a year
2003-05-25 07:12:19 +00:00
*/
virtual int32_t defaultCenturyStartYear ( ) const = 0 ;
2004-08-24 17:38:33 +00:00
2003-11-14 21:08:16 +00:00
/** Get the locale for this calendar object. You can choose between valid and actual locale.
2004-08-24 17:38:33 +00:00
* @ param type type of the locale we ' re looking for ( valid or actual )
2003-11-14 21:08:16 +00:00
* @ param status error code for the operation
* @ return the locale
2004-01-23 19:28:19 +00:00
* @ draft ICU 2.8 likely to change in ICU 3.0 , based on feedback
2003-11-14 21:08:16 +00:00
*/
2004-01-22 00:14:17 +00:00
Locale getLocale ( ULocDataLocaleType type , UErrorCode & status ) const ;
2003-11-14 21:08:16 +00:00
/** Get the locale for this calendar object. You can choose between valid and actual locale.
2004-08-24 17:38:33 +00:00
* @ param type type of the locale we ' re looking for ( valid or actual )
2003-11-14 21:08:16 +00:00
* @ param status error code for the operation
* @ return the locale
* @ internal
*/
2004-01-22 00:14:17 +00:00
const char * getLocaleID ( ULocDataLocaleType type , UErrorCode & status ) const ;
2003-11-14 21:08:16 +00:00
1999-12-28 23:57:50 +00:00
} ;
// -------------------------------------
inline Calendar *
Calendar : : createInstance ( TimeZone * zone , UErrorCode & errorCode )
{
// since the Locale isn't specified, use the default locale
return createInstance ( zone , Locale : : getDefault ( ) , errorCode ) ;
}
// -------------------------------------
2004-08-24 17:38:33 +00:00
inline void
2003-02-21 08:32:22 +00:00
Calendar : : roll ( UCalendarDateFields field , UBool up , UErrorCode & status )
1999-12-28 23:57:50 +00:00
{
roll ( field , ( int32_t ) ( up ? + 1 : - 1 ) , status ) ;
}
2003-05-16 20:33:01 +00:00
inline void
Calendar : : roll ( EDateFields field , UBool up , UErrorCode & status )
{
roll ( ( UCalendarDateFields ) field , up , status ) ;
}
2003-11-24 22:43:31 +00:00
1999-12-28 23:57:50 +00:00
// -------------------------------------
/**
* Fast method for subclasses . The caller must maintain fUserSetDSTOffset and
* fUserSetZoneOffset , as well as the isSet [ ] array .
*/
2003-02-28 13:21:23 +00:00
inline void
2003-05-16 20:33:01 +00:00
Calendar : : internalSet ( UCalendarDateFields field , int32_t value )
2003-02-28 13:21:23 +00:00
{
2003-05-16 20:33:01 +00:00
fFields [ field ] = value ;
2003-10-26 10:24:58 +00:00
fStamp [ field ] = kInternallySet ;
fIsSet [ field ] = TRUE ; // Remove later
2003-02-28 13:21:23 +00:00
}
1999-12-28 23:57:50 +00:00
inline void
2003-05-16 20:33:01 +00:00
Calendar : : internalSet ( EDateFields field , int32_t value )
1999-12-28 23:57:50 +00:00
{
2003-05-16 20:33:01 +00:00
internalSet ( ( UCalendarDateFields ) field , value ) ;
1999-12-28 23:57:50 +00:00
}
2003-10-26 10:24:58 +00:00
inline uint8_t Calendar : : julianDayToDayOfWeek ( double julian )
{
// If julian is negative, then julian%7 will be negative, so we adjust
// accordingly. We add 1 because Julian day 0 is Monday.
int8_t dayOfWeek = ( int8_t ) uprv_fmod ( julian + 1 , 7 ) ;
uint8_t result = ( uint8_t ) ( dayOfWeek + ( ( dayOfWeek < 0 ) ? ( 7 + UCAL_SUNDAY ) : UCAL_SUNDAY ) ) ;
return result ;
}
inline int32_t Calendar : : weekNumber ( int32_t dayOfPeriod , int32_t dayOfWeek )
{
return weekNumber ( dayOfPeriod , dayOfPeriod , dayOfWeek ) ;
}
2001-10-08 23:26:58 +00:00
U_NAMESPACE_END
2002-09-20 01:54:48 +00:00
# endif /* #if !UCONFIG_NO_FORMATTING */
1999-12-28 23:57:50 +00:00
# endif // _CALENDAR