ICU 76.1 76.1
Loading...
Searching...
No Matches
gregocal.h
Go to the documentation of this file.
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4* Copyright (C) 1997-2013, International Business Machines Corporation and others.
5* All Rights Reserved.
6********************************************************************************
7*
8* File GREGOCAL.H
9*
10* Modification History:
11*
12* Date Name Description
13* 04/22/97 aliu Overhauled header.
14* 07/28/98 stephen Sync with JDK 1.2
15* 09/04/98 stephen Re-sync with JDK 8/31 putback
16* 09/14/98 stephen Changed type of kOneDay, kOneWeek to double.
17* Fixed bug in roll()
18* 10/15/99 aliu Fixed j31, incorrect WEEK_OF_YEAR computation.
19* Added documentation of WEEK_OF_YEAR computation.
20* 10/15/99 aliu Fixed j32, cannot set date to Feb 29 2000 AD.
21* {JDK bug 4210209 4209272}
22* 11/07/2003 srl Update, clean up documentation.
23********************************************************************************
24*/
25
26#ifndef GREGOCAL_H
27#define GREGOCAL_H
28
29#include "unicode/utypes.h"
30
31#if U_SHOW_CPLUSPLUS_API
32
33#if !UCONFIG_NO_FORMATTING
34
35#include "unicode/calendar.h"
36
42U_NAMESPACE_BEGIN
43
154public:
155
160 enum EEras {
161 BC,
162 AD
163 };
164
174
186
197
208
221
233
247
263
280
286
293
300
306 virtual GregorianCalendar* clone() const override;
307
318
328
345
353 virtual UBool isEquivalentTo(const Calendar& other) const override;
354
355#ifndef U_FORCE_HIDE_DEPRECATED_API
367 virtual void roll(EDateFields field, int32_t amount, UErrorCode& status) override;
368#endif // U_FORCE_HIDE_DEPRECATED_API
369
381 virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) override;
382
383#ifndef U_HIDE_DEPRECATED_API
392
402#endif /* U_HIDE_DEPRECATED_API */
403
413
425
426public:
427
438 virtual UClassID getDynamicClassID() const override;
439
452
463 virtual const char * getType() const override;
464
465 private:
466 GregorianCalendar() = delete; // default constructor not implemented
467
468 protected:
475 virtual int32_t internalGetEra() const;
476
492 UBool useMonth, UErrorCode& status) const override;
493
504
513
521 virtual int32_t handleGetYearLength(int32_t eyear) const override;
522
531
540
541#ifndef U_HIDE_INTERNAL_API
548
549#endif /* U_HIDE_INTERNAL_API */
550
559
582
593
603
604
621
622#ifndef U_HIDE_INTERNAL_API
628 virtual bool isEra0CountingBackward() const override { return true; }
629#endif // U_HIDE_INTERNAL_API
630
631 private:
639 static double computeJulianDayOfYear(UBool isGregorian, int32_t year,
640 UBool& isLeap);
641
646 UBool validateFields() const;
647
651 UBool boundsCheck(int32_t value, UCalendarDateFields field) const;
652
662 int32_t aggregateStamp(int32_t stamp_a, int32_t stamp_b);
663
671 UDate fGregorianCutover;
672
676 int32_t fCutoverJulianDay;
677
683 UDate fNormalizedGregorianCutover;// = gregorianCutover;
684
689 int32_t fGregorianCutoverYear;// = 1582;
690
698 static double millisToJulianDay(UDate millis);
699
707 static UDate julianDayToMillis(double julian);
708
713 UBool fIsGregorian;
714
720 UBool fInvertGregorian;
721
722
723 public: // internal implementation
724
726
727};
728
729U_NAMESPACE_END
730
731#endif /* #if !UCONFIG_NO_FORMATTING */
732
733#endif /* U_SHOW_CPLUSPLUS_API */
734
735#endif // _GREGOCAL
736//eof
737
C++ API: Calendar object.
#define DECLARE_OVERRIDE_SYSTEM_DEFAULT_CENTURY
Macro for the class to declare it override haveDefaultCentury, defaultCenturyStart,...
Definition calendar.h:2575
Calendar is an abstract base class for converting between a UDate object and a set of integer fields ...
Definition calendar.h:189
EDateFields
Field IDs for date and time.
Definition calendar.h:198
ELimitType
Limit enums.
Definition calendar.h:1621
Concrete class which provides the standard calendar used by most of the world.
Definition gregocal.h:153
virtual UClassID getDynamicClassID() const override
Override Calendar Returns a unique class ID POLYMORPHICALLY.
int32_t getActualMinimum(EDateFields field, UErrorCode &status) const
Return the minimum value that this field could have, given the current date.
virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField, UErrorCode &status) override
Subclasses may override this.
GregorianCalendar(UErrorCode &success)
Constructs a default GregorianCalendar using the current time in the default time zone with the defau...
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override
Subclass API for defining limits of different types.
virtual void handleComputeFields(int32_t julianDay, UErrorCode &status) override
Subclasses may override this method to compute several fields specific to each calendar system.
EEras
Useful constants for GregorianCalendar and TimeZone.
Definition gregocal.h:160
virtual int32_t monthLength(int32_t month, UErrorCode &status) const
return the length of the given month.
GregorianCalendar & operator=(const GregorianCalendar &right)
Default assignment operator.
GregorianCalendar(TimeZone *zoneToAdopt, UErrorCode &success)
Constructs a GregorianCalendar based on the current time in the given time zone with the default loca...
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 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 int32_t monthLength(int32_t month, int32_t year) const
return the length of the month according to the given year.
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...
UDate getGregorianChange() const
Gets the Gregorian Calendar change 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(const TimeZone &zone, UErrorCode &success)
Constructs a GregorianCalendar based on the current time in the given time zone with the default loca...
virtual bool isEra0CountingBackward() const override
The year in this calendar is counting from 1 backward if the era is 0.
Definition gregocal.h:628
GregorianCalendar(const GregorianCalendar &source)
Copy constructor.
virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy, UErrorCode &status) override
Subclasses may override this to convert from week fields (YEAR_WOY and WEEK_OF_YEAR) to an extended y...
virtual int32_t internalGetEra() const
Return the ERA.
int32_t yearLength() const
return the length of the year field.
virtual int32_t handleGetYearLength(int32_t eyear) const override
Return the number of days in the given extended year of this calendar system.
int32_t getActualMinimum(EDateFields field) const
Return the minimum value that this field could have, given the current date.
static UClassID getStaticClassID()
Return the class ID for this class.
UBool isLeapYear(int32_t year) const
Return true if the given year is a leap year.
virtual ~GregorianCalendar()
Destructor.
virtual int32_t handleGetExtendedYear(UErrorCode &status) override
Return the extended year defined by the current fields.
virtual int64_t handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth, UErrorCode &status) const override
Return the Julian day number of day before the first day of the given month in the given extended yea...
int32_t getActualMinimum(UCalendarDateFields field, UErrorCode &status) const override
Return the minimum value that this field could have, given the current date.
virtual const char * getType() const override
Returns the calendar type name string for this Calendar object.
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...
virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode &status) const override
Return the maximum value that this field could have, given the current date.
virtual UDate getEpochDay(UErrorCode &status)
Return the day number with respect to the epoch.
virtual UBool isEquivalentTo(const Calendar &other) const override
Returns true if the given Calendar object is equivalent to this one.
virtual void roll(EDateFields field, int32_t amount, UErrorCode &status) override
(Overrides Calendar) Rolls up or down by the given amount in the specified field.
virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode &status) override
(Overrides Calendar) Rolls up or down by the given amount in the specified field.
virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month, UErrorCode &status) const override
Return the number of days in the given month of the given extended year of this calendar system.
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...
virtual GregorianCalendar * clone() const override
Create and return a polymorphic copy of this calendar.
void setGregorianChange(UDate date, UErrorCode &success)
Sets the GregorianCalendar change date.
"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:195
TimeZone represents a time zone offset, and also figures out daylight savings.
Definition timezone.h:133
UCalendarDateFields
Possible fields in a UCalendar.
Definition ucal.h:202
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:247
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:430
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:316
double UDate
Date and Time data type.
Definition utypes.h:218