1 /* 2 * Copyright 2010-2014, Haiku, Inc. 3 * Distributed under the terms of the MIT Licence. 4 */ 5 #ifndef _B_DATE_TIME_FORMAT_H_ 6 #define _B_DATE_TIME_FORMAT_H_ 7 8 9 #include <Format.h> 10 11 12 class BString; 13 class BTimeZone; 14 15 16 enum BDateElement { 17 B_DATE_ELEMENT_INVALID = 0, 18 B_DATE_ELEMENT_YEAR = 1 << 0, 19 B_DATE_ELEMENT_MONTH = 1 << 1, 20 B_DATE_ELEMENT_WEEKDAY = 1 << 2, 21 B_DATE_ELEMENT_DAY = 1 << 3, 22 B_DATE_ELEMENT_AM_PM = 1 << 4, 23 B_DATE_ELEMENT_HOUR = 1 << 5, 24 B_DATE_ELEMENT_MINUTE = 1 << 6, 25 B_DATE_ELEMENT_SECOND = 1 << 7, 26 B_DATE_ELEMENT_TIMEZONE = 1 << 8 27 }; 28 29 30 31 class BDateTimeFormat : public BFormat { 32 public: 33 BDateTimeFormat(const BLocale* locale = NULL); 34 BDateTimeFormat(const BLanguage& language, 35 const BFormattingConventions& conventions); 36 BDateTimeFormat(const BDateTimeFormat &other); 37 virtual ~BDateTimeFormat(); 38 39 void SetDateTimeFormat(BDateFormatStyle dateStyle, 40 BTimeFormatStyle timeStyle, 41 int32 elements); 42 43 // formatting 44 45 ssize_t Format(char* target, const size_t maxSize, 46 const time_t time, 47 BDateFormatStyle dateStyle, 48 BTimeFormatStyle timeStyle) const; 49 status_t Format(BString& buffer, const time_t time, 50 BDateFormatStyle dateStyle, 51 BTimeFormatStyle timeStyle, 52 const BTimeZone* timeZone = NULL) const; 53 54 private: 55 U_ICU_NAMESPACE::DateFormat* _CreateDateTimeFormatter( 56 const BString& format) const; 57 }; 58 59 60 #endif // _B_DATE_TIME_FORMAT_H_ 61