ICU 57.1 57.1
gregocal.h
Go to the documentation of this file.
1/*
2* Copyright (C) 1997-2013, International Business Machines Corporation and others.
3* All Rights Reserved.
4********************************************************************************
5*
6* File GREGOCAL.H
7*
8* Modification History:
9*
10* Date Name Description
11* 04/22/97 aliu Overhauled header.
12* 07/28/98 stephen Sync with JDK 1.2
13* 09/04/98 stephen Re-sync with JDK 8/31 putback
14* 09/14/98 stephen Changed type of kOneDay, kOneWeek to double.
15* Fixed bug in roll()
16* 10/15/99 aliu Fixed j31, incorrect WEEK_OF_YEAR computation.
17* Added documentation of WEEK_OF_YEAR computation.
18* 10/15/99 aliu Fixed j32, cannot set date to Feb 29 2000 AD.
19* {JDK bug 4210209 4209272}
20* 11/07/2003 srl Update, clean up documentation.
21********************************************************************************
22*/
23
24#ifndef GREGOCAL_H
25#define GREGOCAL_H
26
27#include "unicode/utypes.h"
28
29#if !UCONFIG_NO_FORMATTING
30
31#include "unicode/calendar.h"
32
39
150public:
151
156 enum EEras {
157 BC,
158 AD
159 };
160
170
182
193
204
217
229
242 GregorianCalendar(int32_t year, int32_t month, int32_t date, UErrorCode& success);
243
258 GregorianCalendar(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, UErrorCode& success);
259
275 GregorianCalendar(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second, UErrorCode& success);
276
282
289
296
302 virtual Calendar* clone(void) const;
303
314
324
340 UBool isLeapYear(int32_t year) const;
341
349 virtual UBool isEquivalentTo(const Calendar& other) const;
350
362 virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
363
375 virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
376
377#ifndef U_HIDE_DEPRECATED_API
385 int32_t getActualMinimum(EDateFields field) const;
386
396#endif /* U_HIDE_DEPRECATED_API */
397
407
408#ifndef U_HIDE_DEPRECATED_API
418 int32_t getActualMaximum(EDateFields field) const;
419#endif /* U_HIDE_DEPRECATED_API */
420
432
443
444public:
445
456 virtual UClassID getDynamicClassID(void) const;
457
470
481 virtual const char * getType() const;
482
483 private:
484 GregorianCalendar(); // default constructor not implemented
485
486 protected:
493 virtual int32_t internalGetEra() const;
494
508 virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
509 UBool useMonth) const;
510
520
528 virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const;
529
537 virtual int32_t handleGetYearLength(int32_t eyear) const;
538
545 virtual int32_t monthLength(int32_t month) const;
546
554 virtual int32_t monthLength(int32_t month, int32_t year) const;
555
556#ifndef U_HIDE_INTERNAL_API
563 int32_t yearLength(int32_t year) const;
564
570 int32_t yearLength(void) const;
571
579 void pinDayOfMonth(void);
580#endif /* U_HIDE_INTERNAL_API */
581
590
613
622 virtual int32_t handleGetExtendedYear();
623
632 virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
633
634
651
652 private:
660 static double computeJulianDayOfYear(UBool isGregorian, int32_t year,
661 UBool& isLeap);
662
667 UBool validateFields(void) const;
668
672 UBool boundsCheck(int32_t value, UCalendarDateFields field) const;
673
683 int32_t aggregateStamp(int32_t stamp_a, int32_t stamp_b);
684
692 UDate fGregorianCutover;
693
697 int32_t fCutoverJulianDay;
698
704 UDate fNormalizedGregorianCutover;// = gregorianCutover;
705
710 int32_t fGregorianCutoverYear;// = 1582;
711
716 int32_t fGregorianCutoverJulianDay;// = 2299161;
717
725 static double millisToJulianDay(UDate millis);
726
734 static UDate julianDayToMillis(double julian);
735
740 UBool fIsGregorian;
741
747 UBool fInvertGregorian;
748
749
750 public: // internal implementation
751
756 virtual UBool haveDefaultCentury() const;
757
762 virtual UDate defaultCenturyStart() const;
763
768 virtual int32_t defaultCenturyStartYear() const;
769};
770
772
773#endif /* #if !UCONFIG_NO_FORMATTING */
774
775#endif // _GREGOCAL
776//eof
777
C++ API: Calendar object.
Calendar is an abstract base class for converting between a UDate object and a set of integer fields ...
Definition calendar.h:200
EDateFields
Field IDs for date and time.
Definition calendar.h:209
ELimitType
Limit enums.
Definition calendar.h:1608
Concrete class which provides the standard calendar used by most of the world.
Definition gregocal.h:149
GregorianCalendar(TimeZone *zoneToAdopt, UErrorCode &success)
Constructs a GregorianCalendar based on the current time in the given time zone with the default loca...
GregorianCalendar(const TimeZone &zone, UErrorCode &success)
Constructs a GregorianCalendar based on the current time in the given time zone with the default loca...
virtual const char * getType() const
Returns the calendar type name string for this Calendar object.
GregorianCalendar & operator=(const GregorianCalendar &right)
Default assignment operator.
virtual UBool inDaylightTime(UErrorCode &status) const
(Overrides Calendar) Return true if the current date for this Calendar is in Daylight Savings Time.
static UClassID getStaticClassID(void)
Return the class ID for this class.
virtual UBool isEquivalentTo(const Calendar &other) const
Returns TRUE if the given Calendar object is equivalent to this one.
virtual Calendar * clone(void) const
Create and return a polymorphic copy of this calendar.
int32_t getActualMinimum(EDateFields field, UErrorCode &status) const
Return the minimum value that this field could have, given the current date.
int32_t getActualMinimum(UCalendarDateFields field, UErrorCode &status) const
Return the minimum value that this field could have, given the current date.
int32_t getActualMaximum(EDateFields field) const
Return the maximum value that this field could have, given the current date.
virtual void handleComputeFields(int32_t julianDay, UErrorCode &status)
Subclasses may override this method to compute several fields specific to each calendar system.
GregorianCalendar(const TimeZone &zone, const Locale &aLocale, UErrorCode &success)
Constructs a GregorianCalendar based on the current time in the given time zone with the given locale...
virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode &status)
(Overrides Calendar) Rolls up or down by the given amount in the specified field.
int32_t yearLength(void) const
return the length of the year field.
UDate getGregorianChange(void) const
Gets the Gregorian Calendar change date.
UBool isLeapYear(int32_t year) const
Return true if the given year is a leap year.
virtual int32_t defaultCenturyStartYear() const
virtual int32_t handleGetYearLength(int32_t eyear) const
Return the number of days in the given extended year of this calendar system.
virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField)
Subclasses may override this.
virtual ~GregorianCalendar()
Destructor.
void setGregorianChange(UDate date, UErrorCode &success)
Sets the GregorianCalendar change date.
virtual UClassID getDynamicClassID(void) const
Override Calendar Returns a unique class ID POLYMORPHICALLY.
GregorianCalendar(const Locale &aLocale, UErrorCode &success)
Constructs a GregorianCalendar based on the current time in the default time zone with the given loca...
GregorianCalendar(const GregorianCalendar &source)
Copy constructor.
virtual UDate defaultCenturyStart() const
virtual int32_t internalGetEra() const
Return the ERA.
virtual UDate getEpochDay(UErrorCode &status)
Return the day number with respect to the epoch.
virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const
Return the number of days in the given month of the given extended year of this calendar system.
int32_t yearLength(int32_t year) const
return the length of the given year.
virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy)
Subclasses may override this to convert from week fields (YEAR_WOY and WEEK_OF_YEAR) to an extended y...
virtual void roll(EDateFields field, int32_t amount, UErrorCode &status)
(Overrides Calendar) Rolls up or down by the given amount in the specified field.
virtual int32_t handleGetExtendedYear()
Return the extended year defined by the current fields.
GregorianCalendar(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, UErrorCode &success)
Constructs a GregorianCalendar with the given AD date and time set for the default time zone with the...
GregorianCalendar(TimeZone *zoneToAdopt, const Locale &aLocale, UErrorCode &success)
Constructs a GregorianCalendar based on the current time in the given time zone with the given locale...
virtual int32_t monthLength(int32_t month) const
return the length of the given month.
virtual int32_t monthLength(int32_t month, int32_t year) const
return the length of the month according to the given year.
virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth) const
Return the Julian day number of day before the first day of the given month in the given extended yea...
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const
Subclass API for defining limits of different types.
virtual UBool haveDefaultCentury() const
int32_t getActualMinimum(EDateFields field) const
Return the minimum value that this field could have, given the current date.
GregorianCalendar(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second, UErrorCode &success)
Constructs a GregorianCalendar with the given AD date and time set for the default time zone with the...
GregorianCalendar(int32_t year, int32_t month, int32_t date, UErrorCode &success)
Constructs a GregorianCalendar with the given AD date set in the default time zone with the default l...
GregorianCalendar(UErrorCode &success)
Constructs a default GregorianCalendar using the current time in the default time zone with the defau...
void pinDayOfMonth(void)
After adjustments such as add(MONTH), add(YEAR), we don't want the month to jump around.
virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode &status) const
Return the maximum value that this field could have, given the current date.
EEras
Useful constants for GregorianCalendar and TimeZone.
Definition gregocal.h:156
"Smart pointer" base class; do not use directly: use LocalPointer etc.
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:185
TimeZone represents a time zone offset, and also figures out daylight savings.
Definition timezone.h:129
UCalendarDateFields
Possible fields in a UCalendar.
Definition ucal.h:183
int8_t UBool
The ICU boolean type.
Definition umachine.h:234
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:476
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:358
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129