ICU 4.8.1.1  4.8.1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gregocal.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 1997-2011, 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 
150 public:
151 
156  enum EEras {
157  BC,
158  AD
159  };
160 
169  GregorianCalendar(UErrorCode& success);
170 
181  GregorianCalendar(TimeZone* zoneToAdopt, UErrorCode& success);
182 
192  GregorianCalendar(const TimeZone& zone, UErrorCode& success);
193 
203  GregorianCalendar(const Locale& aLocale, UErrorCode& success);
204 
216  GregorianCalendar(TimeZone* zoneToAdopt, const Locale& aLocale, UErrorCode& success);
217 
228  GregorianCalendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
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 
281  virtual ~GregorianCalendar();
282 
288  GregorianCalendar(const GregorianCalendar& source);
289 
296 
302  virtual Calendar* clone(void) const;
303 
313  void setGregorianChange(UDate date, UErrorCode& success);
314 
323  UDate getGregorianChange(void) const;
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 
384  int32_t getActualMinimum(EDateFields field) const;
385 
394  int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;
395 
404  int32_t getActualMinimum(UCalendarDateFields field, UErrorCode &status) const;
405 
415  int32_t getActualMaximum(EDateFields field) const;
416 
427  virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
428 
438  virtual UBool inDaylightTime(UErrorCode& status) const;
439 
440 public:
441 
452  virtual UClassID getDynamicClassID(void) const;
453 
465  static UClassID U_EXPORT2 getStaticClassID(void);
466 
473  virtual const char * getType() const;
474 
475  private:
476  GregorianCalendar(); // default constructor not implemented
477 
478  protected:
485  virtual int32_t internalGetEra() const;
486 
500  virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
501  UBool useMonth) const;
502 
511  virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField) ;
512 
520  virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const;
521 
529  virtual int32_t handleGetYearLength(int32_t eyear) const;
530 
537  virtual int32_t monthLength(int32_t month) const;
538 
546  virtual int32_t monthLength(int32_t month, int32_t year) const;
547 
554  int32_t yearLength(int32_t year) const;
555 
561  int32_t yearLength(void) const;
562 
570  void pinDayOfMonth(void);
571 
579  virtual UDate getEpochDay(UErrorCode& status);
580 
602  virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
603 
612  virtual int32_t handleGetExtendedYear();
613 
622  virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
623 
624 
640  virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
641 
642  private:
650  static double computeJulianDayOfYear(UBool isGregorian, int32_t year,
651  UBool& isLeap);
652 
657  UBool validateFields(void) const;
658 
662  UBool boundsCheck(int32_t value, UCalendarDateFields field) const;
663 
673  int32_t aggregateStamp(int32_t stamp_a, int32_t stamp_b);
674 
683  UDate fGregorianCutover;
684 
688  int32_t fCutoverJulianDay;
689 
695  UDate fNormalizedGregorianCutover;// = gregorianCutover;
696 
701  int32_t fGregorianCutoverYear;// = 1582;
702 
707  int32_t fGregorianCutoverJulianDay;// = 2299161;
708 
716  static double millisToJulianDay(UDate millis);
717 
725  static UDate julianDayToMillis(double julian);
726 
731  UBool fIsGregorian;
732 
738  UBool fInvertGregorian;
739 
740 
741  public: // internal implementation
742 
747  virtual UBool haveDefaultCentury() const;
748 
753  virtual UDate defaultCenturyStart() const;
754 
759  virtual int32_t defaultCenturyStartYear() const;
760 
761  private:
768  static UDate fgSystemDefaultCenturyStart;
769 
773  static int32_t fgSystemDefaultCenturyStartYear;
774 
778  static const int32_t fgSystemDefaultCenturyYear;
779 
783  static const UDate fgSystemDefaultCentury;
784 
791  UDate internalGetDefaultCenturyStart(void) const;
792 
799  int32_t internalGetDefaultCenturyStartYear(void) const;
800 
805  static void initializeSystemDefaultCentury(void);
806 
807 };
808 
810 
811 #endif /* #if !UCONFIG_NO_FORMATTING */
812 
813 #endif // _GREGOCAL
814 //eof
815 
void roll(EDateFields field, UBool up, UErrorCode &status)
Time Field Rolling function.
Definition: calendar.h:2227
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:183
virtual UBool isEquivalentTo(const Calendar &other) const
Returns TRUE if the given Calendar object is equivalent to this one.
Calendar is an abstract base class for converting between a UDate object and a set of integer fields ...
Definition: calendar.h:165
virtual int32_t defaultCenturyStartYear() const =0
EEras
Useful constants for GregorianCalendar and TimeZone.
Definition: gregocal.h:156
double UDate
Date and Time data type.
Definition: utypes.h:314
virtual UDate defaultCenturyStart() const =0
virtual const char * getType() const =0
Returns the resource key string used for this calendar type.
virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField)
Subclasses may override this.
int32_t getActualMinimum(EDateFields field, UErrorCode &status) const
Return the minimum value that this field could have, given the current date.
Calendar & operator=(const Calendar &right)
Default assignment operator.
virtual void handleComputeFields(int32_t julianDay, UErrorCode &status)
Subclasses may override this method to compute several fields specific to each calendar system...
virtual int32_t handleGetExtendedYear()=0
Return the extended year defined by the current fields.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:521
virtual int32_t handleGetYearLength(int32_t eyear) const
Return the number of days in the given extended year of this calendar system.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
int32_t getActualMaximum(EDateFields field, UErrorCode &status) const
Return the maximum value that this field could have, given the current date.
virtual UBool inDaylightTime(UErrorCode &status) const =0
Queries if the current date for this Calendar is in Daylight Savings Time.
C++ API: Calendar object.
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...
virtual UClassID getDynamicClassID(void) const =0
Returns a unique class ID POLYMORPHICALLY.
virtual Calendar * clone(void) const =0
Create and return a polymorphic copy of this calendar.
#define U_EXPORT2
Definition: platform.h:314
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
Concrete class which provides the standard calendar used by most of the world.
Definition: gregocal.h:149
virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth) const =0
Return the Julian day number of day before the first day of the given month in the given extended yea...
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
Definition: utypes.h:385
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:639
TimeZone represents a time zone offset, and also figures out daylight savings.
Definition: timezone.h:123
Basic definitions for ICU, for both C and C++ APIs.
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const =0
Subclass API for defining limits of different types.
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:181
virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy)
Subclasses must override this to convert from week fields (YEAR_WOY and WEEK_OF_YEAR) to an extended ...
virtual UBool haveDefaultCentury() const =0
int8_t UBool
The ICU boolean type.
Definition: umachine.h:228