Rogue Wave Views 5.6 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
Abstract base class managing a calendar date. More...
#include <ilog/calendar.h>
Public Types | |
enum | EAmpm { AM, PM } |
Useful constants for the hour in a 12-hour clock. More... | |
enum | EDaysOfWeek { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } |
Useful constants for days of the week. More... | |
enum | EMonths { JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER, UNDECIMBER } |
Useful constants for the month. More... | |
enum | IlDateFields { ERA, YEAR, MONTH, WEEK_OF_YEAR, WEEK_OF_MONTH, DATE, DAY_OF_YEAR, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, AM_PM, HOUR, HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND, ZONE_OFFSET, DST_OFFSET } |
Field IDs for date and time. More... | |
Public Member Functions | |
virtual | ~IlCalendar () |
virtual void | add (IlDateFields field, IlInt amount, IlDateErrorCode &status)=0 |
An arithmetic function for IlDate type. This function adds the specified (signed) amount of time to the given time field, based on the calendar rules. | |
void | adoptTimeZone (IlTimeZone *value) |
Sets the calendar time zone to be the one passed in. | |
IlBoolean | after (const IlCalendar &when, IlDateErrorCode &status) const |
Returns IlTrue if this IlCalendar current time is after when current time. | |
IlBoolean | before (const IlCalendar &when, IlDateErrorCode &status) const |
Returns IlTrue if this IlCalendar current time is before when current time. | |
void | clear (IlDateFields field) |
Clears the value in the given time field, both making it unset and assigning it a value of zero. | |
void | clear () |
Clears the values of all the time fields, making them both unset and assigning them a value of zero. | |
virtual IlCalendar * | clone () const =0 |
Creates and returns a polymorphic copy of this calendar. | |
IlBoolean | equals (const IlCalendar &when, IlDateErrorCode &status) const |
Compares the IlCalendar time, whereas IlCalendar::operator== compares the equality of IlCalendar objects. | |
virtual IlBoolean | equivalentTo (const IlCalendar &other) const |
Returns IlTrue if another IlCalendar object is equivalent to this one. | |
virtual IlInt | fieldDifference (IlDate when, IlDateFields field, IlDateErrorCode &status) |
Returns the difference between the given time and the time this calendar object is set to. | |
IlInt | get (IlDateFields field, IlDateErrorCode &status) const |
Indicates the value for a given time field. | |
IlInt | getActualMaximum (IlDateFields field, IlDateErrorCode &status) const |
Returns the maximum value that this field could have, given the current date. | |
IlInt | getActualMinimum (IlDateFields field, IlDateErrorCode &status) const |
Returns the minimum value that this field could have, given the current date. | |
EDaysOfWeek | getFirstDayOfWeek () const |
Returns the first day of the week; for example, Sunday in US, Monday in France. | |
virtual IlInt | getGreatestMinimum (IlDateFields field) const =0 |
Indicates the highest minimum value for the given field if it varies. | |
virtual IlInt | getLeastMaximum (IlDateFields field) const =0 |
Indicates the lowest maximum value for the given field if it varies. | |
virtual IlInt | getMaximum (IlDateFields field) const =0 |
Indicates the maximum value for the given time field. | |
IlUChar | getMinimalDaysInFirstWeek () const |
Indicates the minimal days required in the first week of the year. | |
virtual IlInt | getMinimum (IlDateFields field) const =0 |
Indicates the minimum value for the given time field. | |
IlDate | getTime (IlDateErrorCode &status) const |
Gets this IlCalendar time as milliseconds. | |
const IlTimeZone & | getTimeZone () const |
Returns a reference to the time zone owned by this calendar. | |
virtual IlBoolean | inDaylightTime (IlDateErrorCode &status) const =0 |
Queries if the current date for this IlCalendar is in Daylight Savings Time. | |
IlBoolean | isLenient () const |
Indicates whether the date/time interpretation is lenient. | |
IlBoolean | isSet (IlDateFields field) const |
Determines if the given time field has a value set. | |
IlBoolean | operator!= (const IlCalendar &that) const |
Compares the inequality of two IlCalendar objects. | |
virtual IlBoolean | operator== (const IlCalendar &that) const |
Compares the equality of two IlCalendar objects. | |
IlTimeZone * | orphanTimeZone () |
Returns the time zone owned by this calendar. | |
virtual void | roll (IlDateFields field, IlInt amount, IlDateErrorCode &status)=0 |
Time Field Rolling function: rolls the given amount on the given time field. | |
void | roll (IlDateFields field, IlBoolean up, IlDateErrorCode &status) |
Time Field Rolling function: rolls (up/down) a single unit of time on the given time field. | |
void | set (IlInt year, IlInt month, IlInt date, IlInt hour, IlInt minute, IlInt second) |
Sets the values for the fields YEAR , MONTH , DATE , HOUR_OF_DAY , MINUTE , and SECOND . | |
void | set (IlInt year, IlInt month, IlInt date, IlInt hour, IlInt minute) |
Sets the values for the fields YEAR , MONTH , DATE , HOUR_OF_DAY , and MINUTE . | |
void | set (IlInt year, IlInt month, IlInt date) |
Sets the values for the fields YEAR , MONTH , and DATE . | |
void | set (IlDateFields field, IlInt value) |
Sets the given time field with the given value. | |
void | setFirstDayOfWeek (EDaysOfWeek value) |
Sets the first day of the week; for example, Sunday in US, Monday in France. | |
void | setLenient (IlBoolean lenient) |
Specifies whether or not the date/time interpretation is to be lenient. | |
void | setMinimalDaysInFirstWeek (IlUChar value) |
Sets the minimal days required in the first week of the year. | |
void | setTime (IlDate date, IlDateErrorCode &status) |
Sets this IlCalendar current time with the given IlDate . | |
void | setTimeZone (const IlTimeZone &zone) |
Sets the calendar time zone to be the same as the one passed in. | |
Static Public Member Functions | |
static IlCalendar * | createInstance (const IlTimeZone &zoneToAdopt, const IlLocale &aLocale, IlDateErrorCode &success) |
Gets an IlCalendar using the given time zone and given locale. | |
static IlCalendar * | createInstance (IlTimeZone *zoneToAdopt, const IlLocale &aLocale, IlDateErrorCode &success) |
Creates an IlCalendar using the given time zone and locale. | |
static IlCalendar * | createInstance (const IlLocale &aLocale, IlDateErrorCode &success) |
Creates an IlCalendar using the default time zone and the given locale. | |
static IlCalendar * | createInstance (const IlTimeZone &zone, IlDateErrorCode &success) |
Creates an IlCalendar using the given time zone and the default locale. | |
static IlCalendar * | createInstance (IlTimeZone *zoneToAdopt, IlDateErrorCode &success) |
Creates an IlCalendar using the given time zone and the default locale. | |
static IlCalendar * | createInstance (IlDateErrorCode &success) |
Creates an IlCalendar that uses the default time zone and locale. | |
static IlDate | getNow () |
Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70 (derived from the system time). | |
Protected Member Functions | |
IlCalendar (const IlTimeZone &zone, const IlLocale &aLocale, IlDateErrorCode &success) | |
Constructs an IlCalendar with the given time zone and locale. | |
IlCalendar (IlTimeZone *zone, const IlLocale &aLocale, IlDateErrorCode &success) | |
Constructs an IlCalendar with the given time zone and locale. | |
IlCalendar (const IlCalendar &source) | |
Copy constructor. | |
IlCalendar (IlDateErrorCode &success) | |
Constructs an IlCalendar with the default time zone and locale. | |
void | complete (IlDateErrorCode &status) |
Recomputes the current time from currently set fields. | |
virtual void | computeFields (IlDateErrorCode &status)=0 |
Converts GMT as milliseconds to time field values. | |
virtual void | computeTime (IlDateErrorCode &status)=0 |
Converts IlCalendar time field values to GMT as milliseconds. | |
double | getTimeInMillis (IlDateErrorCode &status) const |
Gets this IlCalendar current time as a long. | |
IlInt | internalGet (IlDateFields field) const |
Gets the value for a given time field. | |
IlDate | internalGetTime () const |
void | internalSet (IlDateFields field, IlInt value) |
Sets the value for a given time field. | |
void | internalSetTime (IlDate time) |
IlCalendar & | operator= (const IlCalendar &right) |
The default assignment operator. | |
void | setTimeInMillis (double millis, IlDateErrorCode &status) |
Sets this IlCalendar current time from the given long value. | |
Protected Attributes | |
IlBoolean | fAreAllFieldsSet |
IlBoolean | fAreFieldsSet |
IlInt | fFields [FIELD_COUNT] |
IlBoolean | fIsSet [FIELD_COUNT] |
IlBoolean | fIsTimeSet |
IlInt | fStamp [FIELD_COUNT] |
Abstract base class managing a calendar date.
Library: ilog
From IBM ICU classes, adapted for Rogue Wave Views libraries.
Copyright (C) 1997-1999, International Business Machines Corporation and others. All Rights Reserved.
IlCalendar
is an abstract base class for converting between a IlDate
object and a set of integer fields such as YEAR
, MONTH
, DAY
, HOUR
, and so on. (A IlDate
object represents a specific instant in time with millisecond precision.)
Subclasses of IlCalendar
interpret a IlDate
according to the rules of a specific calendar system. The Rogue Wave Views library provides one concrete subclass of IlCalendar
: IlGregorianCalendar
. Future subclasses could represent the various types of lunar calendars in use in many parts of the world.
Like other locale-sensitive classes, IlCalendar
provides a class method, getInstance
, for getting a generally useful object of this type. IlCalendar
getInstance
method returns a IlGregorianCalendar
object whose time fields have been initialized with the current date and time:
IlCalendar rightNow = IlCalendar.getInstance();
An IlCalendar
object can produce all the time field values needed to implement the date-time formatting for a particular language and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
When computing a IlDate
from time fields, two special circumstances may arise: there may be insufficient information to compute the IlDate
(such as only year and month but no day in the month), or there may be inconsistent information (such as "Tuesday, July 15, 1996" -- July 15, 1996 is actually a Monday).
Insufficient information. The calendar will use default information to specify the missing fields. This may vary by calendar; for the Gregorian calendar, the default for a field is the same as that of the start of the epoch: that is, YEAR = 1970, MONTH = JANUARY, DATE = 1,
and so on.
Inconsistent information. If fields conflict, the calendar will give preference to fields set more recently. For example, when determining the day, the calendar will look for one of the following combinations of fields. The most recent combination, as determined by the most recently set single field, will be used.
MONTH + DAY_OF_MONTH MONTH + WEEK_OF_MONTH + DAY_OF_WEEK MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK DAY_OF_YEAR DAY_OF_WEEK + WEEK_OF_YEAR
For the time of day:
Note: for some non-Gregorian calendars, different fields may be necessary for complete disambiguation. For example, a full specification of the historical Arabic astronomical calendar requires year, month, day-of-month and day-of-week in some cases.
24:00:00
belongs to the following day. That is, 23:59
on Dec 31, 1969 < 24:00
on Jan 1, 1970 < 24:01:00
on Jan 1, 1970
am
, and noon belongs to pm
, so on the same day, 12:00 am
(midnight) < 12:01 am
, and 12:00 pm
(noon) < 12:01 pm
The date or time format strings are not part of the definition of a calendar, as those can be modified or overriden by the user at runtime.
IlCalendar
provides an API for field rolling, where fields can be incremented or decremented, but wrap around. For example, rolling the month up in the date December 12, 1996
results in January 12, 1996
.
IlCalendar
also provides a date arithmetic function for adding the specified (signed) amount of time to a particular time field. For example, subtracting 5 days from the date September 12, 1996
results in September 7, 1996
.
enum IlCalendar::EAmpm |
Useful constants for the hour in a 12-hour clock.
Used in IlGregorianCalendar
.
Useful constants for days of the week.
Note: The IlCalendar
day-of-week is 1-based.
Users who create locale resources for the field fFirstDayOfWeek
should be aware of this. For instance, in the US locale, fFirstDayOfWeek
is set to 1
, that is, SUNDAY
.
enum IlCalendar::EMonths |
Useful constants for the month.
Note: The IlCalendar
month is 0-based.
Field IDs for date and time.
Used to specify date/time fields. The ERA
is calendar specific. Example ranges given are for illustration only; see specific IlCalendar
subclasses for actual ranges.
virtual IlCalendar::~IlCalendar | ( | ) | [virtual] |
destructor
IlCalendar::IlCalendar | ( | IlDateErrorCode & | success | ) | [protected] |
Constructs an IlCalendar
with the default time zone and locale.
The time zone is the one returned by IlTimeZone::createInstance()
.
success | Indicates the status of IlCalendar object construction. It returns IL_DATE_ZERO_ERROR if constructed successfully. |
IlCalendar::IlCalendar | ( | const IlCalendar & | source | ) | [protected] |
Copy constructor.
Copy constructor
IlCalendar::IlCalendar | ( | IlTimeZone * | zone, | |
const IlLocale & | aLocale, | |||
IlDateErrorCode & | success | |||
) | [protected] |
Constructs an IlCalendar
with the given time zone and locale.
Clients are no longer responsible for deleting the given time zone object after it has been adopted.
zoneToAdopt | The given time zone. | |
aLocale | The given locale. | |
success | Indicates the status of IlCalendar object construction. It returns IL_DATE_ZERO_ERROR if constructed successfully. |
IlCalendar::IlCalendar | ( | const IlTimeZone & | zone, | |
const IlLocale & | aLocale, | |||
IlDateErrorCode & | success | |||
) | [protected] |
Constructs an IlCalendar
with the given time zone and locale.
zone | The given time zone. | |
aLocale | The given locale. | |
success | Indicates the status of IlCalendar object construction. It returns IL_DATE_ZERO_ERROR if constructed successfully. |
virtual void IlCalendar::add | ( | IlDateFields | field, | |
IlInt | amount, | |||
IlDateErrorCode & | status | |||
) | [pure virtual] |
An arithmetic function for IlDate
type. This function adds the specified (signed) amount of time to the given time field, based on the calendar rules.
For example, to subtract 5 days from the current time of the calendar, call add(IlCalendar::DATE, -5)
. When adding on the month or IlCalendar::MONTH
field, other fields such as 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.
field | Specifies which date field to modify. | |
amount | The amount of time to be added to the field, in the natural unit for that field (for example, days for the day fields, hours for the hour field). | |
status | An output parameter set to a 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. |
Implemented in IlGregorianCalendar.
void IlCalendar::adoptTimeZone | ( | IlTimeZone * | value | ) |
Sets the calendar time zone to be the one passed in.
The IlCalendar
takes ownership of the IlTimeZone
; the caller is no longer responsible for deleting it. If the given time zone is null
, this function has no effect.
value | The given time zone. |
IlBoolean IlCalendar::after | ( | const IlCalendar & | when, | |
IlDateErrorCode & | status | |||
) | const |
Returns IlTrue
if this IlCalendar
current time is after when current time.
when | The IlCalendar to be compared with this IlCalendar . Although this is a const parameter, the object may be modified physically (semantically const ). | |
status | An output parameter set to a 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. |
IlTrue
if the current time of this IlCalendar
is after the time of IlCalendar
when; IlFalse
otherwise. IlBoolean IlCalendar::before | ( | const IlCalendar & | when, | |
IlDateErrorCode & | status | |||
) | const |
Returns IlTrue
if this IlCalendar
current time is before when current time.
when | The IlCalendar to be compared with this IlCalendar . Although this is a const parameter, the object may be modified physically (semantically const ). | |
status | Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status. |
IlTrue
if the current time of this IlCalendar
is before the time of IlCalendar
when; IlFalse
otherwise. void IlCalendar::clear | ( | IlDateFields | 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.
field | The time field to be cleared. |
void IlCalendar::clear | ( | ) |
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.
void IlCalendar::complete | ( | IlDateErrorCode & | status | ) | [protected] |
Recomputes the current time from currently set fields.
After computation, any unset fields in the time field list are set.
status | An output parameter set to a 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. |
virtual void IlCalendar::computeFields | ( | IlDateErrorCode & | status | ) | [protected, pure virtual] |
Converts GMT as milliseconds to time field values.
This allows you to sync up the time field values with a new time that is set for the calendar. This method does NOT recompute the time first; to recompute the time, then the fields, use the method complete()
.
status | An output parameter set to a success/failure code on exit. |
Implemented in IlGregorianCalendar.
virtual void IlCalendar::computeTime | ( | IlDateErrorCode & | status | ) | [protected, pure virtual] |
Converts IlCalendar
time field values to GMT as milliseconds.
status | An output parameter set to a 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. |
Implemented in IlGregorianCalendar.
static IlCalendar* IlCalendar::createInstance | ( | const IlTimeZone & | zoneToAdopt, | |
const IlLocale & | aLocale, | |||
IlDateErrorCode & | success | |||
) | [static] |
Gets an IlCalendar
using the given time zone and given locale.
The IlTimeZone
is not adopted; the client is still responsible for deleting it.
zoneToAdopt | The time zone. | |
aLocale | The given locale. | |
success | Indicates the success/failure of IlCalendar creation. Filled in with IL_DATE_ZERO_ERROR if created successfully, set to a failure result otherwise. |
IlCalendar
if created successfully, null
otherwise. static IlCalendar* IlCalendar::createInstance | ( | IlTimeZone * | zoneToAdopt, | |
const IlLocale & | aLocale, | |||
IlDateErrorCode & | success | |||
) | [static] |
Creates an IlCalendar
using the given time zone and locale.
The IlCalendar
takes ownership of zoneToAdopt; the client must not delete it.
zoneToAdopt | The given time zone to be adopted. | |
aLocale | The given locale. | |
success | Indicates the success/failure of IlCalendar creation. Filled in with IL_DATE_ZERO_ERROR if created successfully, set to a failure result otherwise. |
IlCalendar
if created successfully, null
otherwise. static IlCalendar* IlCalendar::createInstance | ( | const IlLocale & | aLocale, | |
IlDateErrorCode & | success | |||
) | [static] |
Creates an IlCalendar
using the default time zone and the given locale.
aLocale | The given locale. | |
success | Indicates the success/failure of IlCalendar creation. Filled in with IL_DATE_ZERO_ERROR if created successfully, set to a failure result otherwise. |
IlCalendar
if created successfully, null
otherwise. static IlCalendar* IlCalendar::createInstance | ( | const IlTimeZone & | zone, | |
IlDateErrorCode & | success | |||
) | [static] |
Creates an IlCalendar
using the given time zone and the default locale.
The IlTimeZone
is not adopted; it is the responsibility of the users to delete it.
zone | The time zone. | |
success | Indicates the success/failure of IlCalendar creation. Filled in with IL_DATE_ZERO_ERROR if created successfully, set to a failure result otherwise. |
IlCalendar
if created successfully, null
otherwise. static IlCalendar* IlCalendar::createInstance | ( | IlTimeZone * | zoneToAdopt, | |
IlDateErrorCode & | success | |||
) | [static] |
Creates an IlCalendar
using the given time zone and the default locale.
The IlCalendar
takes ownership of zoneToAdopt; users should not delete it.
zoneToAdopt | The given time zone to be adopted. | |
success | Indicates the success/failure of IlCalendar creation. Filled in with IL_DATE_ZERO_ERROR if created successfully, set to a failure result otherwise. |
IlCalendar
if created successfully, null
otherwise. static IlCalendar* IlCalendar::createInstance | ( | IlDateErrorCode & | success | ) | [static] |
Creates an IlCalendar
that uses the default time zone and locale.
Users are responsible for deleting the returned object.
success | Indicates the success/failure of IlCalendar creation. Filled in with IL_DATE_ZERO_ERROR if created successfully, set to a failure result otherwise. |
IlCalendar
if created successfully, null
otherwise. IlBoolean IlCalendar::equals | ( | const IlCalendar & | when, | |
IlDateErrorCode & | status | |||
) | const |
Compares the IlCalendar
time, whereas IlCalendar::operator==
compares the equality of IlCalendar
objects.
when | The IlCalendar to be compared with this IlCalendar . Although this is a const parameter, the object may be modified physically (semantically const ). | |
status | Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status. |
IlTrue
if the current time of this IlCalendar
is equal to the time of IlCalendar
when; IlFalse
otherwise. virtual IlBoolean IlCalendar::equivalentTo | ( | const IlCalendar & | other | ) | const [virtual] |
Returns IlTrue
if another IlCalendar
object is equivalent to this one.
An equivalent IlCalendar
will behave exactly as this one does, but may be set to a different time.
Reimplemented in IlGregorianCalendar.
virtual IlInt IlCalendar::fieldDifference | ( | IlDate | when, | |
IlDateFields | field, | |||
IlDateErrorCode & | status | |||
) | [virtual] |
Returns the difference between the given time and the time this calendar object is set to.
If this calendar is set before the given time, the returned value will be positive. If this calendar is set after the given time, the returned value will be negative. The field
parameter specifies the units of the return value. For example, if fieldDifference(when, IlCalendar.MONTH)
returns 3
, then this calendar is set to 3 months before when, and possibly some additional time less than one month.
As a side effect of this call, this calendar is advanced toward when by the given amount. That is, calling this method has the side effect of calling add(field, n)
, where n
is the return value.
Usage: To use this method, call it first with the largest field of interest, then with progressively smaller fields. For example:
int y = cal.fieldDifference(when, IlCalendar.YEAR); int m = cal.fieldDifference(when, IlCalendar.MONTH); int d = cal.fieldDifference(when, IlCalendar.DATE);
computes the difference between cal
and when
in years, months, and days.
Note: fieldDifference()
is asymmetrical. That is, in the following code:
cal.setTime(date1); int m1 = cal.fieldDifference(date2, IlCalendar.MONTH); int d1 = cal.fieldDifference(date2, IlCalendar.DATE); cal.setTime(date2); int m2 = cal.fieldDifference(date1, IlCalendar.MONTH); int d2 = cal.fieldDifference(date1, IlCalendar.DATE);
you might expect that m1 == -m2 && d1 == -d2
. However, this is not generally the case, because of irregularities in the underlying calendar system (for example, the Gregorian calendar has a variable number of days per month).
when | The date to compare this calendar time to. | |
field | The field in which to compute the result. |
field
. IlInt IlCalendar::get | ( | IlDateFields | field, | |
IlDateErrorCode & | status | |||
) | const |
Indicates the value for a given time field.
It recalculates the current time field values if the time value has been changed by a call to setTime()
. It returns 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.
field | The given time field. | |
status | Fill-in parameter which receives the status of the operation. |
set()
has been called for any other field. IlInt IlCalendar::getActualMaximum | ( | IlDateFields | field, | |
IlDateErrorCode & | status | |||
) | const |
Returns 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 is 29
. Similarly, for a Hebrew calendar, for some years the actual maximum for MONTH
is 12
, and for others it is 13
.
The version of this function on IlCalendar
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()
). IlGregorianCalendar
overrides this function with a more efficient implementation.
field | The given time field. |
IlCalendar
. IlInt IlCalendar::getActualMinimum | ( | IlDateFields | field, | |
IlDateErrorCode & | status | |||
) | const |
Returns 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 IlCalendar
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()
). IlGregorianCalendar
overrides this function with a more efficient implementation.
field | The given time field. |
IlCalendar
. EDaysOfWeek IlCalendar::getFirstDayOfWeek | ( | ) | const |
Returns the first day of the week; for example, Sunday in US, Monday in France.
virtual IlInt IlCalendar::getGreatestMinimum | ( | IlDateFields | field | ) | const [pure virtual] |
Indicates the highest minimum value for the given field if it varies.
Otherwise, the value is the same as getMinimum()
.
For Gregorian, there is no difference.
field | The given time field. |
Implemented in IlGregorianCalendar.
virtual IlInt IlCalendar::getLeastMaximum | ( | IlDateFields | field | ) | const [pure virtual] |
Indicates the lowest maximum value for the given field if it varies.
Otherwise, the value is the same as getMaximum()
.
For example, for Gregorian DAY_OF_MONTH
, 28
.
field | The given time field. |
Implemented in IlGregorianCalendar.
virtual IlInt IlCalendar::getMaximum | ( | IlDateFields | field | ) | const [pure virtual] |
Indicates the maximum value for the given time field.
For example, for Gregorian DAY_OF_MONTH
, 31
.
field | The given time field. |
Implemented in IlGregorianCalendar.
IlUChar IlCalendar::getMinimalDaysInFirstWeek | ( | ) | const |
Indicates the minimal days required in the first week of the year.
For example, 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
.
virtual IlInt IlCalendar::getMinimum | ( | IlDateFields | field | ) | const [pure virtual] |
Indicates the minimum value for the given time field.
For example, for Gregorian DAY_OF_MONTH
, 1
.
field | The given time field. |
Implemented in IlGregorianCalendar.
static IlDate IlCalendar::getNow | ( | ) | [static] |
Returns the current UTC (GMT) time measured in milliseconds since 0:00:00
on 1/1/70
(derived from the system time).
IlDate IlCalendar::getTime | ( | IlDateErrorCode & | status | ) | const |
Gets this IlCalendar
time as milliseconds.
This may involve recalculation of time due to previous calls to set time field values. The time specified is nonlocal UTC (GMT) time. Although this method is const
, this object may actually be changed (semantically const
).
status | Output parameter set to a 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. |
double IlCalendar::getTimeInMillis | ( | IlDateErrorCode & | status | ) | const [protected] |
Gets this IlCalendar
current time as a long.
status | An output parameter set to a success/failure code on exit. |
const IlTimeZone& IlCalendar::getTimeZone | ( | ) | const |
Returns a reference to the time zone owned by this calendar.
The returned reference is valid only until clients make another call to adoptTimeZone
or setTimeZone
, or this IlCalendar
is destroyed.
virtual IlBoolean IlCalendar::inDaylightTime | ( | IlDateErrorCode & | status | ) | const [pure virtual] |
Queries if the current date for this IlCalendar
is in Daylight Savings Time.
status | Fill-in parameter which receives the status of this operation. |
IlTrue
if the current date for this IlCalendar
is in Daylight Savings Time, IlFalse
otherwise. Implemented in IlGregorianCalendar.
IlInt IlCalendar::internalGet | ( | IlDateFields | field | ) | const [protected] |
Gets the value for a given time field.
Subclasses can use this function to fetch field values without forcing recomputation of time.
field | The given time field. |
IlDate IlCalendar::internalGetTime | ( | ) | const [protected] |
Gets the current time without recomputing.
void IlCalendar::internalSet | ( | IlDateFields | field, | |
IlInt | value | |||
) | [protected] |
Sets the value for a given time field.
This is a fast internal method for subclasses. It does not affect the areFieldsInSync
, isTimeSet
, or areAllFieldsSet
flags.
void IlCalendar::internalSetTime | ( | IlDate | time | ) | [protected] |
Sets the current time without affecting flags or fields.
IlBoolean IlCalendar::isLenient | ( | ) | const |
Indicates whether the date/time interpretation is lenient.
IlTrue
if the date/time interpretation is lenient. IlBoolean IlCalendar::isSet | ( | IlDateFields | field | ) | const |
Determines if the given time field has a value set.
This can affect the resolving of time in IlCalendar
. Unset fields have a value of zero, by definition.
IlTrue
if the given time field has a value set; IlFalse
otherwise. IlBoolean IlCalendar::operator!= | ( | const IlCalendar & | that | ) | const |
Compares the inequality of two IlCalendar
objects.
that | The IlCalendar object to be compared with. |
IlTrue
if the given IlCalendar
is not the same as this IlCalendar
; IlFalse
otherwise. virtual IlBoolean IlCalendar::operator== | ( | const IlCalendar & | that | ) | const [virtual] |
Compares the equality of two IlCalendar
objects.
Objects of different subclasses are considered unequal. This comparison is very exacting; two IlCalendar
objects must be in exactly the same state to be considered equal. To compare based on the represented time, use equals()
instead.
that | The IlCalendar object to be compared with. |
IlTrue
if the given IlCalendar
is the same as this IlCalendar
; IlFalse
otherwise. Reimplemented in IlGregorianCalendar.
IlTimeZone* IlCalendar::orphanTimeZone | ( | ) |
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 IlCalendar
is the default IlTimeZone
as returned by IlTimeZone::createDefault()
.
virtual void IlCalendar::roll | ( | IlDateFields | field, | |
IlInt | amount, | |||
IlDateErrorCode & | status | |||
) | [pure virtual] |
Time Field Rolling function: rolls the given amount on the given time field.
For example, to roll the current date up by one day, call roll(IlCalendar::DATE, +1, status)
. When rolling on the month or IlCalendar::MONTH
field, other fields such as 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; for example, rolling the year by +1 on 100 BC
will result in 99 BC
, for the Gregorian calendar. When rolling on the hour-in-day or IlCalendar::HOUR_OF_DAY
field, it will roll the hour value in the range between 0
and 23
, which is zero-based.
The only difference between roll()
and add()
is that roll()
does not change the value of more significant fields when it reaches the minimum or maximum of its range, whereas add()
does.
field | The time field. | |
amount | The amount to roll. | |
status | An output parameter set to a success/failure code on exit. If any value previously set in the time field is invalid, this will be set to an error status. |
Implemented in IlGregorianCalendar.
void IlCalendar::roll | ( | IlDateFields | field, | |
IlBoolean | up, | |||
IlDateErrorCode & | status | |||
) |
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(IlCalendar::DATE, true)
. When rolling on the year or IlCalendar::YEAR
field, it will roll the year value in the range between getMinimum(IlCalendar::YEAR)
and the value returned by getMaximum(IlCalendar::YEAR)
. When rolling on the month or IlCalendar::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; for example, rolling the year up on 100 BC
will result in 99 BC
, for Gregorian calendar. When rolling on the hour-in-day or IlCalendar::HOUR_OF_DAY
field, it will roll the hour value in the range between 0 and 23, which is zero-based.
roll(IlDateFields, int, IlDateErrorCode&)
instead.field | The time field. | |
up | Indicates if the value of the specified time field is to be rolled up or rolled down. Use IlTrue if rolling up, IlFalse otherwise. | |
status | Output param set to success/failure code on exit. If any value previously set in the time field is invalid or restricted by leniency, this will be set to an error status. |
void IlCalendar::set | ( | IlInt | year, | |
IlInt | month, | |||
IlInt | date, | |||
IlInt | hour, | |||
IlInt | minute, | |||
IlInt | second | |||
) |
Sets the values for the fields YEAR
, MONTH
, DATE
, HOUR_OF_DAY
, MINUTE
, and SECOND
.
Other field values are retained; call clear()
first if this is not desired.
year | The value used to set the YEAR time field. | |
month | The value used to set the MONTH time field. The month value is 0-based, for example, 0 for January. | |
date | The value used to set the DATE time field. | |
hour | The value used to set the HOUR_OF_DAY time field. | |
minute | The value used to set the MINUTE time field. | |
second | The value used to set the SECOND time field. |
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.
year | The value used to set the YEAR time field. | |
month | The value used to set the MONTH time field. The month value is 0-based, for example, 0 for January. | |
date | The value used to set the DATE time field. | |
hour | The value used to set the HOUR_OF_DAY time field. | |
minute | The value used to set the MINUTE time field. |
Sets the values for the fields YEAR
, MONTH
, and DATE
.
Other field values are retained; call clear()
first if this is not desired.
year | The value used to set the YEAR time field. | |
month | The value used to set the MONTH time field. The month value is 0-based, for example, 0 for January. | |
date | The value used to set the DATE time field. |
void IlCalendar::set | ( | IlDateFields | field, | |
IlInt | value | |||
) |
Sets the given time field with the given value.
field | The given time field. | |
value | The value to be set for the given time field. |
void IlCalendar::setFirstDayOfWeek | ( | EDaysOfWeek | value | ) |
Sets the first day of the week; for example, Sunday in US, Monday in France.
value | The given first day of the week. |
void IlCalendar::setLenient | ( | IlBoolean | lenient | ) |
Specifies whether or not the date/time interpretation is to be lenient.
With lenient interpretation, a date such as February 942, 1996
will be treated as being equivalent to the 941st day after February 1, 1996
. With strict interpretation, such dates will cause an error when computing time from the time field values representing the dates.
lenient | If IlTrue , specifies the date/time interpretation to be lenient. |
void IlCalendar::setMinimalDaysInFirstWeek | ( | IlUChar | value | ) |
Sets the minimal days required in the first week of the year.
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
.
value | The given minimal days required in the first week of the year. |
void IlCalendar::setTime | ( | IlDate | date, | |
IlDateErrorCode & | status | |||
) |
Sets this IlCalendar
current time with the given IlDate
.
The time specified should be in nonlocal UTC (GMT) time.
date | The given IlDate in UTC (GMT) time. |
void IlCalendar::setTimeInMillis | ( | double | millis, | |
IlDateErrorCode & | status | |||
) | [protected] |
Sets this IlCalendar
current time from the given long value.
millis | The new time in UTC milliseconds from the epoch. | |
status | An output parameter set to a success/failure code on exit. |
void IlCalendar::setTimeZone | ( | const IlTimeZone & | zone | ) |
Sets the calendar time zone to be the same as the one passed in.
The IlTimeZone
passed in is not adopted; the client is still responsible for deleting it.
zone | The given time zone. |
IlBoolean IlCalendar::fAreAllFieldsSet [protected] |
IlTrue
if all of the fields have been set.
This is initially IlFalse
, and set to IlTrue
by computeFields()
.
IlBoolean IlCalendar::fAreFieldsSet [protected] |
If set to IlTrue
, the fields are in sync with the currently set time of this IlCalendar
.
If set to IlFalse
, then the next attempt to get the value of a field will trigger a recomputation of all fields from the current value of the time field.
This should really be named areFieldsInSync
, but the old name is retained for backward compatibility.
IlInt IlCalendar::fFields[FIELD_COUNT] [protected] |
The time fields containing values into which the millis are computed.
IlBoolean IlCalendar::fIsSet[FIELD_COUNT] [protected] |
The flags which tell if a specified time field for the calendar is set.
IlBoolean IlCalendar::fIsTimeSet [protected] |
The flag which indicates if the current time is set in the calendar.
IlInt IlCalendar::fStamp[FIELD_COUNT] [protected] |
Pseudo-time-stamps that specify when each field was set.
There are two special values, kUnset
and kInternallySet
. Values from kMinimumUserStamp
to the maximal value for IlInt
are valid.
© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.