Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/unicode/dtrule.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // © 2016 and later: Unicode, Inc. and others.
0002 // License & terms of use: http://www.unicode.org/copyright.html
0003 /*
0004 *******************************************************************************
0005 * Copyright (C) 2007-2008, International Business Machines Corporation and         *
0006 * others. All Rights Reserved.                                                *
0007 *******************************************************************************
0008 */
0009 #ifndef DTRULE_H
0010 #define DTRULE_H
0011 
0012 #include "unicode/utypes.h"
0013 
0014 #if U_SHOW_CPLUSPLUS_API
0015 
0016 /**
0017  * \file 
0018  * \brief C++ API: Rule for specifying date and time in an year
0019  */
0020 
0021 #if !UCONFIG_NO_FORMATTING
0022 
0023 #include "unicode/uobject.h"
0024 
0025 U_NAMESPACE_BEGIN
0026 /**
0027  * <code>DateTimeRule</code> is a class representing a time in a year by
0028  * a rule specified by month, day of month, day of week and
0029  * time in the day.
0030  * 
0031  * @stable ICU 3.8
0032  */
0033 class U_I18N_API DateTimeRule : public UObject {
0034 public:
0035 
0036     /**
0037      * Date rule type constants.
0038      * @stable ICU 3.8
0039      */
0040     enum DateRuleType {
0041         DOM = 0,        /**< The exact day of month,
0042                              for example, March 11. */
0043         DOW,            /**< The Nth occurrence of the day of week,
0044                              for example, 2nd Sunday in March. */
0045         DOW_GEQ_DOM,    /**< The first occurrence of the day of week on or after the day of monnth,
0046                              for example, first Sunday on or after March 8. */
0047         DOW_LEQ_DOM     /**< The last occurrence of the day of week on or before the day of month,
0048                              for example, first Sunday on or before March 14. */
0049     };
0050 
0051     /**
0052      * Time rule type constants.
0053      * @stable ICU 3.8
0054      */
0055     enum TimeRuleType {
0056         WALL_TIME = 0,  /**< The local wall clock time */
0057         STANDARD_TIME,  /**< The local standard time */
0058         UTC_TIME        /**< The UTC time */
0059     };
0060 
0061     /**
0062      * Constructs a <code>DateTimeRule</code> by the day of month and
0063      * the time rule.  The date rule type for an instance created by
0064      * this constructor is <code>DOM</code>.
0065      * 
0066      * @param month         The rule month, for example, <code>Calendar::JANUARY</code>
0067      * @param dayOfMonth    The day of month, 1-based.
0068      * @param millisInDay   The milliseconds in the rule date.
0069      * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
0070      *                      or <code>UTC_TIME</code>.
0071      * @stable ICU 3.8
0072      */
0073     DateTimeRule(int32_t month, int32_t dayOfMonth,
0074         int32_t millisInDay, TimeRuleType timeType);
0075 
0076     /**
0077      * Constructs a <code>DateTimeRule</code> by the day of week and its ordinal
0078      * number and the time rule.  The date rule type for an instance created
0079      * by this constructor is <code>DOW</code>.
0080      * 
0081      * @param month         The rule month, for example, <code>Calendar::JANUARY</code>.
0082      * @param weekInMonth   The ordinal number of the day of week.  Negative number
0083      *                      may be used for specifying a rule date counted from the
0084      *                      end of the rule month.
0085      * @param dayOfWeek     The day of week, for example, <code>Calendar::SUNDAY</code>.
0086      * @param millisInDay   The milliseconds in the rule date.
0087      * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
0088      *                      or <code>UTC_TIME</code>.
0089      * @stable ICU 3.8
0090      */
0091     DateTimeRule(int32_t month, int32_t weekInMonth, int32_t dayOfWeek,
0092         int32_t millisInDay, TimeRuleType timeType);
0093 
0094     /**
0095      * Constructs a <code>DateTimeRule</code> by the first/last day of week
0096      * on or after/before the day of month and the time rule.  The date rule
0097      * type for an instance created by this constructor is either
0098      * <code>DOM_GEQ_DOM</code> or <code>DOM_LEQ_DOM</code>.
0099      * 
0100      * @param month         The rule month, for example, <code>Calendar::JANUARY</code>
0101      * @param dayOfMonth    The day of month, 1-based.
0102      * @param dayOfWeek     The day of week, for example, <code>Calendar::SUNDAY</code>.
0103      * @param after         true if the rule date is on or after the day of month.
0104      * @param millisInDay   The milliseconds in the rule date.
0105      * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
0106      *                      or <code>UTC_TIME</code>.
0107      * @stable ICU 3.8
0108      */
0109     DateTimeRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, UBool after,
0110         int32_t millisInDay, TimeRuleType timeType);
0111 
0112     /**
0113      * Copy constructor.
0114      * @param source    The DateTimeRule object to be copied.
0115      * @stable ICU 3.8
0116      */
0117     DateTimeRule(const DateTimeRule& source);
0118 
0119     /**
0120      * Destructor.
0121      * @stable ICU 3.8
0122      */
0123     ~DateTimeRule();
0124 
0125     /**
0126      * Clone this DateTimeRule object polymorphically. The caller owns the result and
0127      * should delete it when done.
0128      * @return    A copy of the object.
0129      * @stable ICU 3.8
0130      */
0131     DateTimeRule* clone() const;
0132 
0133     /**
0134      * Assignment operator.
0135      * @param right The object to be copied.
0136      * @stable ICU 3.8
0137      */
0138     DateTimeRule& operator=(const DateTimeRule& right);
0139 
0140     /**
0141      * Return true if the given DateTimeRule objects are semantically equal. Objects
0142      * of different subclasses are considered unequal.
0143      * @param that  The object to be compared with.
0144      * @return  true if the given DateTimeRule objects are semantically equal.
0145      * @stable ICU 3.8
0146      */
0147     bool operator==(const DateTimeRule& that) const;
0148 
0149     /**
0150      * Return true if the given DateTimeRule objects are semantically unequal. Objects
0151      * of different subclasses are considered unequal.
0152      * @param that  The object to be compared with.
0153      * @return  true if the given DateTimeRule objects are semantically unequal.
0154      * @stable ICU 3.8
0155      */
0156     bool operator!=(const DateTimeRule& that) const;
0157 
0158     /**
0159      * Gets the date rule type, such as <code>DOM</code>
0160      * @return The date rule type.
0161      * @stable ICU 3.8
0162      */
0163     DateRuleType getDateRuleType(void) const;
0164 
0165     /**
0166      * Gets the time rule type
0167      * @return The time rule type, either <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
0168      *         or <code>UTC_TIME</code>.
0169      * @stable ICU 3.8
0170      */
0171     TimeRuleType getTimeRuleType(void) const;
0172 
0173     /**
0174      * Gets the rule month.
0175      * @return The rule month.
0176      * @stable ICU 3.8
0177      */
0178     int32_t getRuleMonth(void) const;
0179 
0180     /**
0181      * Gets the rule day of month.  When the date rule type
0182      * is <code>DOW</code>, the value is always 0.
0183      * @return The rule day of month
0184      * @stable ICU 3.8
0185      */
0186     int32_t getRuleDayOfMonth(void) const;
0187 
0188     /**
0189      * Gets the rule day of week.  When the date rule type
0190      * is <code>DOM</code>, the value is always 0.
0191      * @return The rule day of week.
0192      * @stable ICU 3.8
0193      */
0194     int32_t getRuleDayOfWeek(void) const;
0195 
0196     /**
0197      * Gets the ordinal number of the occurrence of the day of week
0198      * in the month.  When the date rule type is not <code>DOW</code>,
0199      * the value is always 0.
0200      * @return The rule day of week ordinal number in the month.
0201      * @stable ICU 3.8
0202      */
0203     int32_t getRuleWeekInMonth(void) const;
0204 
0205     /**
0206      * Gets the rule time in the rule day.
0207      * @return The time in the rule day in milliseconds.
0208      * @stable ICU 3.8
0209      */
0210     int32_t getRuleMillisInDay(void) const;
0211 
0212 private:
0213     int32_t fMonth;
0214     int32_t fDayOfMonth;
0215     int32_t fDayOfWeek;
0216     int32_t fWeekInMonth;
0217     int32_t fMillisInDay;
0218     DateRuleType fDateRuleType;
0219     TimeRuleType fTimeRuleType;
0220 
0221 public:
0222     /**
0223      * Return the class ID for this class. This is useful only for comparing to
0224      * a return value from getDynamicClassID(). For example:
0225      * <pre>
0226      * .   Base* polymorphic_pointer = createPolymorphicObject();
0227      * .   if (polymorphic_pointer->getDynamicClassID() ==
0228      * .       erived::getStaticClassID()) ...
0229      * </pre>
0230      * @return          The class ID for all objects of this class.
0231      * @stable ICU 3.8
0232      */
0233     static UClassID U_EXPORT2 getStaticClassID(void);
0234 
0235     /**
0236      * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
0237      * method is to implement a simple version of RTTI, since not all C++
0238      * compilers support genuine RTTI. Polymorphic operator==() and clone()
0239      * methods call this method.
0240      *
0241      * @return          The class ID for this object. All objects of a
0242      *                  given class have the same class ID.  Objects of
0243      *                  other classes have different class IDs.
0244      * @stable ICU 3.8
0245      */
0246     virtual UClassID getDynamicClassID(void) const override;
0247 };
0248 
0249 U_NAMESPACE_END
0250 
0251 #endif /* #if !UCONFIG_NO_FORMATTING */
0252 
0253 #endif /* U_SHOW_CPLUSPLUS_API */
0254 
0255 #endif // DTRULE_H
0256 //eof