#ifndef DAYPERIODRULES_H
#define DAYPERIODRULES_H
#include "unicode/locid.h"
#include "unicode/unistr.h"
#include "unicode/uobject.h"
#include "unicode/utypes.h"
#include "resource.h"
#include "uhash.h"
U_NAMESPACE_BEGIN
struct DayPeriodRulesDataSink;
class DayPeriodRules : public UMemory {
friend struct DayPeriodRulesDataSink;
public:
enum DayPeriod {
DAYPERIOD_UNKNOWN = -1,
DAYPERIOD_MIDNIGHT,
DAYPERIOD_NOON,
DAYPERIOD_MORNING1,
DAYPERIOD_AFTERNOON1,
DAYPERIOD_EVENING1,
DAYPERIOD_NIGHT1,
DAYPERIOD_MORNING2,
DAYPERIOD_AFTERNOON2,
DAYPERIOD_EVENING2,
DAYPERIOD_NIGHT2,
DAYPERIOD_AM,
DAYPERIOD_PM
};
static const DayPeriodRules *getInstance(const Locale &locale, UErrorCode &errorCode);
UBool hasMidnight() const { return fHasMidnight; }
UBool hasNoon() const { return fHasNoon; }
DayPeriod getDayPeriodForHour(int32_t hour) const { return fDayPeriodForHour[hour]; }
double getMidPointForDayPeriod(DayPeriod dayPeriod, UErrorCode &errorCode) const;
private:
DayPeriodRules();
static DayPeriod getDayPeriodFromString(const char *type_str);
static void U_CALLCONV load(UErrorCode &errorCode);
void add(int32_t startHour, int32_t limitHour, DayPeriod period);
UBool allHoursAreSet();
int32_t getStartHourForDayPeriod(DayPeriod dayPeriod, UErrorCode &errorCode) const;
int32_t getEndHourForDayPeriod(DayPeriod dayPeriod, UErrorCode &errorCode) const;
UBool fHasMidnight;
UBool fHasNoon;
DayPeriod fDayPeriodForHour[24];
};
U_NAMESPACE_END
#endif