| 1 |
. |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#ifndef DAYPERIODRULES_H |
| 15 |
#define DAYPERIODRULES_H |
| 16 |
|
| 17 |
#include "unicode/locid.h" |
| 18 |
#include "unicode/unistr.h" |
| 19 |
#include "unicode/uobject.h" |
| 20 |
#include "unicode/utypes.h" |
| 21 |
#include "resource.h" |
| 22 |
#include "uhash.h" |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
U_NAMESPACE_BEGIN |
| 27 |
|
| 28 |
struct DayPeriodRulesDataSink; |
| 29 |
|
| 30 |
class DayPeriodRules : public UMemory { |
| 31 |
friend struct DayPeriodRulesDataSink; |
| 32 |
public: |
| 33 |
enum DayPeriod { |
| 34 |
DAYPERIOD_UNKNOWN = -1, |
| 35 |
DAYPERIOD_MIDNIGHT, |
| 36 |
DAYPERIOD_NOON, |
| 37 |
DAYPERIOD_MORNING1, |
| 38 |
DAYPERIOD_AFTERNOON1, |
| 39 |
DAYPERIOD_EVENING1, |
| 40 |
DAYPERIOD_NIGHT1, |
| 41 |
DAYPERIOD_MORNING2, |
| 42 |
DAYPERIOD_AFTERNOON2, |
| 43 |
DAYPERIOD_EVENING2, |
| 44 |
DAYPERIOD_NIGHT2, |
| 45 |
DAYPERIOD_AM, |
| 46 |
DAYPERIOD_PM |
| 47 |
}; |
| 48 |
|
| 49 |
static const DayPeriodRules *getInstance(const Locale &locale, UErrorCode &errorCode); |
| 50 |
|
| 51 |
UBool hasMidnight() const { return fHasMidnight; } |
| 52 |
UBool hasNoon() const { return fHasNoon; } |
| 53 |
DayPeriod getDayPeriodForHour(int32_t hour) const { return fDayPeriodForHour[hour]; } |
| 54 |
|
| 55 |
|
| 56 |
double getMidPointForDayPeriod(DayPeriod dayPeriod, UErrorCode &errorCode) const; |
| 57 |
|
| 58 |
private: |
| 59 |
DayPeriodRules(); |
| 60 |
|
| 61 |
|
| 62 |
static DayPeriod getDayPeriodFromString(const char *type_str); |
| 63 |
|
| 64 |
static void U_CALLCONV load(UErrorCode &errorCode); |
| 65 |
|
| 66 |
|
| 67 |
void add(int32_t startHour, int32_t limitHour, DayPeriod period); |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
UBool allHoursAreSet(); |
| 72 |
|
| 73 |
|
| 74 |
int32_t getStartHourForDayPeriod(DayPeriod dayPeriod, UErrorCode &errorCode) const; |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
int32_t getEndHourForDayPeriod(DayPeriod dayPeriod, UErrorCode &errorCode) const; |
| 81 |
|
| 82 |
UBool fHasMidnight; |
| 83 |
UBool fHasNoon; |
| 84 |
DayPeriod fDayPeriodForHour[24]; |
| 85 |
}; |
| 86 |
|
| 87 |
U_NAMESPACE_END |
| 88 |
|
| 89 |
#endif |