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 13 class BString; 14 15 namespace icu { 16 class TimeUnitFormat; 17 } 18 19 20 enum time_unit_style { 21 B_TIME_UNIT_ABBREVIATED, // e.g. '5 hrs.' 22 B_TIME_UNIT_FULL, // e.g. '5 hours' 23 }; 24 25 26 enum 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 39 class BTimeUnitFormat : public BFormat { 40 typedef BFormat Inherited; 41 42 public: 43 BTimeUnitFormat(); 44 BTimeUnitFormat(const BLanguage& language, 45 const BFormattingConventions& conventions); 46 BTimeUnitFormat(const BTimeUnitFormat& other); 47 virtual ~BTimeUnitFormat(); 48 49 status_t Format(BString& buffer, 50 const int32 value, 51 const time_unit_element unit, 52 time_unit_style style = B_TIME_UNIT_FULL 53 ) const; 54 55 private: 56 icu::TimeUnitFormat* fFormatter; 57 }; 58 59 60 #endif 61