1 /* 2 * Copyright 2010-2014, Haiku, Inc. 3 * Distributed under the terms of the MIT Licence. 4 */ 5 #ifndef _B_TIME_FORMAT_H_ 6 #define _B_TIME_FORMAT_H_ 7 8 9 #include <DateTimeFormat.h> 10 11 12 class BString; 13 14 namespace BPrivate { 15 class BTime; 16 } 17 18 19 class BTimeFormat : public BFormat { 20 public: 21 BTimeFormat( 22 const BLanguage* const language = NULL, 23 const BFormattingConventions* const 24 format = NULL); 25 BTimeFormat(const BTimeFormat &other); 26 virtual ~BTimeFormat(); 27 28 void SetTimeFormat(BTimeFormatStyle style, 29 const BString& format); 30 31 // formatting 32 33 ssize_t Format(char* string, size_t maxSize, 34 time_t time, BTimeFormatStyle style) const; 35 status_t Format(BString& string, const time_t time, 36 const BTimeFormatStyle style, 37 const BTimeZone* timeZone = NULL) const; 38 status_t Format(BString& string, 39 int*& fieldPositions, int& fieldCount, 40 time_t time, BTimeFormatStyle style) const; 41 42 status_t GetTimeFields(BDateElement*& fields, 43 int& fieldCount, BTimeFormatStyle style 44 ) const; 45 46 // parsing 47 48 status_t Parse(BString source, BTimeFormatStyle style, 49 BPrivate::BTime& output); 50 51 private: 52 icu::DateFormat* _CreateTimeFormatter( 53 const BTimeFormatStyle style) const; 54 }; 55 56 57 #endif // _B_TIME_FORMAT_H_ 58