1/* 2 * Copyright 2010-2011, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef _B_TIME_UNIT_FORMAT_H_ 6#define _B_TIME_UNIT_FORMAT_H_ 7 8 9#include <Format.h> 10#include <SupportDefs.h> 11 12 13class BString; 14 15namespace icu { 16 class TimeUnitFormat; 17} 18 19 20enum time_unit_style { 21 B_TIME_UNIT_ABBREVIATED, // e.g. '5 hrs.' 22 B_TIME_UNIT_FULL, // e.g. '5 hours' 23}; 24 25 26enum time_unit_element { 27 B_TIME_UNIT_YEAR, 28 B_TIME_UNIT_MONTH, 29 B_TIME_UNIT_WEEK, 30 B_TIME_UNIT_DAY, 31 B_TIME_UNIT_HOUR, 32 B_TIME_UNIT_MINUTE, 33 B_TIME_UNIT_SECOND, 34 35 B_TIME_UNIT_LAST = B_TIME_UNIT_SECOND 36}; 37 38 39class BTimeUnitFormat : public BFormat { 40 typedef BFormat Inherited; 41 42public: 43 BTimeUnitFormat(); 44 BTimeUnitFormat(const BTimeUnitFormat& other); 45 virtual ~BTimeUnitFormat(); 46 47 BTimeUnitFormat& operator=(const BTimeUnitFormat& other); 48 49 virtual status_t SetLocale(const BLocale* locale); 50 status_t Format(int32 value, time_unit_element unit, 51 BString* buffer, 52 time_unit_style style = B_TIME_UNIT_FULL 53 ) const; 54 55private: 56 icu::TimeUnitFormat* fFormatter; 57}; 58 59 60#endif 61