ICU 54.1 54.1

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

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
38 U_NAMESPACE_BEGIN
39
149 class U_I18N_API GregorianCalendar: public Calendar {
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
295 GregorianCalendar& operator=(const GregorianCalendar& right);
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
377 #ifndef U_HIDE_DEPRECATED_API
378
385 int32_t getActualMinimum(EDateFields field) const;
386
395 int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;
396 #endif /* U_HIDE_DEPRECATED_API */
397
406 int32_t getActualMinimum(UCalendarDateFields field, UErrorCode &status) const;
407
408 #ifndef U_HIDE_DEPRECATED_API
409
418 int32_t getActualMaximum(EDateFields field) const;
419 #endif /* U_HIDE_DEPRECATED_API */
420
431 virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
432
442 virtual UBool inDaylightTime(UErrorCode& status) const;
443
444 public:
445
456 virtual UClassID getDynamicClassID(void) const;
457
469 static UClassID U_EXPORT2 getStaticClassID(void);
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
519 virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField) ;
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
557
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
589 virtual UDate getEpochDay(UErrorCode& status);
590
612 virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
613
622 virtual int32_t handleGetExtendedYear();
623
632 virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
633
634
650 virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
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
771 U_NAMESPACE_END
772
773 #endif /* #if !UCONFIG_NO_FORMATTING */
774
775 #endif // _GREGOCAL
776 //eof
777