- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# gregocal.h

Go to the documentation of this file.

    00001 /*
    00002 * Copyright (C) 1997-2009, International Business Machines Corporation and others.
    00003 * All Rights Reserved.
    00004 ********************************************************************************
    00005 *
    00006 * File GREGOCAL.H
    00007 *
    00008 * Modification History:
    00009 *
    00010 *   Date        Name        Description
    00011 *   04/22/97    aliu        Overhauled header.
    00012 *    07/28/98    stephen        Sync with JDK 1.2
    00013 *    09/04/98    stephen        Re-sync with JDK 8/31 putback
    00014 *    09/14/98    stephen        Changed type of kOneDay, kOneWeek to double.
    00015 *                            Fixed bug in roll()
    00016 *   10/15/99    aliu        Fixed j31, incorrect WEEK_OF_YEAR computation.
    00017 *                           Added documentation of WEEK_OF_YEAR computation.
    00018 *   10/15/99    aliu        Fixed j32, cannot set date to Feb 29 2000 AD.
    00019 *                           {JDK bug 4210209 4209272}
    00020 *   11/07/2003  srl         Update, clean up documentation.
    00021 ********************************************************************************
    00022 */
    00023
    00024 #ifndef GREGOCAL_H
    00025 #define GREGOCAL_H
    00026
    00027 #include "unicode/utypes.h"
    00028
    00029 #if !UCONFIG_NO_FORMATTING
    00030
    00031 #include "unicode/calendar.h"
    00032
    00038 U_NAMESPACE_BEGIN
    00039
    00149 class U_I18N_API GregorianCalendar: public Calendar {
    00150 public:
    00151
    00156     enum EEras {
    00157         BC,
    00158         AD
    00159     };
    00160
    00169     GregorianCalendar(UErrorCode& success);
    00170
    00181     GregorianCalendar(TimeZone* zoneToAdopt, UErrorCode& success);
    00182
    00192     GregorianCalendar(const TimeZone& zone, UErrorCode& success);
    00193
    00203     GregorianCalendar(const Locale& aLocale, UErrorCode& success);
    00204
    00216     GregorianCalendar(TimeZone* zoneToAdopt, const Locale& aLocale, UErrorCode& success);
    00217
    00228     GregorianCalendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
    00229
    00242     GregorianCalendar(int32_t year, int32_t month, int32_t date, UErrorCode& success);
    00243
    00258     GregorianCalendar(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, UErrorCode& success);
    00259
    00275     GregorianCalendar(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second, UErrorCode& success);
    00276
    00281     virtual ~GregorianCalendar();
    00282
    00288     GregorianCalendar(const GregorianCalendar& source);
    00289
    00295     GregorianCalendar& operator=(const GregorianCalendar& right);
    00296
    00302     virtual Calendar* clone(void) const;
    00303
    00313     void setGregorianChange(UDate date, UErrorCode& success);
    00314
    00323     UDate getGregorianChange(void) const;
    00324
    00340     UBool isLeapYear(int32_t year) const;
    00341
    00349     virtual UBool isEquivalentTo(const Calendar& other) const;
    00350
    00362     virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
    00363
    00375     virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
    00376
    00384     int32_t getActualMinimum(EDateFields field) const;
    00385
    00394     int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;
    00395
    00404     int32_t getActualMinimum(UCalendarDateFields field, UErrorCode &status) const;
    00405
    00415     int32_t getActualMaximum(EDateFields field) const;
    00416
    00427     virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
    00428
    00438     virtual UBool inDaylightTime(UErrorCode& status) const;
    00439
    00440 public:
    00441
    00452     virtual UClassID getDynamicClassID(void) const;
    00453
    00465     static UClassID U_EXPORT2 getStaticClassID(void);
    00466
    00473     virtual const char * getType() const;
    00474
    00475 protected:
    00476
    00483  private:
    00484     GregorianCalendar(); // default constructor not implemented
    00485
    00486  protected:
    00493     virtual int32_t internalGetEra() const;
    00494
    00508     virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
    00509                                                    UBool useMonth) const;
    00510
    00519     virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField)  ;
    00520
    00528     virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const;
    00529
    00537     virtual int32_t handleGetYearLength(int32_t eyear) const;
    00538
    00545     virtual int32_t monthLength(int32_t month) const;
    00546
    00554     virtual int32_t monthLength(int32_t month, int32_t year) const;
    00555
    00562     int32_t yearLength(int32_t year) const;
    00563
    00569     int32_t yearLength(void) const;
    00570
    00578     void pinDayOfMonth(void);
    00579
    00587     virtual UDate getEpochDay(UErrorCode& status);
    00588
    00610     virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
    00611
    00620     virtual int32_t handleGetExtendedYear();
    00621
    00630     virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
    00631
    00632
    00648     virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
    00649
    00650  private:
    00658     static double computeJulianDayOfYear(UBool isGregorian, int32_t year,
    00659                                          UBool& isLeap);
    00660
    00665     UBool validateFields(void) const;
    00666
    00670     UBool boundsCheck(int32_t value, UCalendarDateFields field) const;
    00671
    00681     int32_t aggregateStamp(int32_t stamp_a, int32_t stamp_b);
    00682
    00691     UDate                fGregorianCutover;
    00692
    00696     int32_t             fCutoverJulianDay;
    00697
    00703     UDate                 fNormalizedGregorianCutover;// = gregorianCutover;
    00704
    00709     int32_t fGregorianCutoverYear;// = 1582;
    00710
    00715     int32_t fGregorianCutoverJulianDay;// = 2299161;
    00716
    00724     static double millisToJulianDay(UDate millis);
    00725
    00733     static UDate julianDayToMillis(double julian);
    00734
    00739     UBool fIsGregorian;
    00740
    00746     UBool fInvertGregorian;
    00747
    00748
    00749  public: // internal implementation
    00750
    00755     virtual UBool haveDefaultCentury() const;
    00756
    00761     virtual UDate defaultCenturyStart() const;
    00762
    00767     virtual int32_t defaultCenturyStartYear() const;
    00768
    00769  private:
    00776     static UDate         fgSystemDefaultCenturyStart;
    00777
    00781     static int32_t          fgSystemDefaultCenturyStartYear;
    00782
    00786     static const int32_t    fgSystemDefaultCenturyYear;
    00787
    00791     static const UDate        fgSystemDefaultCentury;
    00792
    00799     UDate         internalGetDefaultCenturyStart(void) const;
    00800
    00807     int32_t          internalGetDefaultCenturyStartYear(void) const;
    00808
    00813     static void  initializeSystemDefaultCentury(void);
    00814
    00815 };
    00816
    00817 U_NAMESPACE_END
    00818
    00819 #endif /* #if !UCONFIG_NO_FORMATTING */
    00820
    00821 #endif // _GREGOCAL
    00822 //eof
    00823

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines