xref: /haiku/headers/os/locale/TimeFormat.h (revision 83b1a68c52ba3e0e8796282759f694b7fdddf06d)
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 								BTimeFormat(const BLanguage& language,
23 									const BFormattingConventions& conventions);
24 								BTimeFormat(const BTimeFormat &other);
25 	virtual						~BTimeFormat();
26 
27 			void				SetTimeFormat(BTimeFormatStyle style,
28 									const BString& format);
29 
30 								// formatting
31 
32 			ssize_t				Format(char* string, size_t maxSize,
33 									time_t time, BTimeFormatStyle style) const;
34 			status_t			Format(BString& string, const time_t time,
35 									const BTimeFormatStyle style,
36 									const BTimeZone* timeZone = NULL) const;
37 			status_t			Format(BString& string,
38 									int*& fieldPositions, int& fieldCount,
39 									time_t time, BTimeFormatStyle style) const;
40 
41 			status_t			GetTimeFields(BDateElement*& fields,
42 									int& fieldCount, BTimeFormatStyle style
43 									) const;
44 
45 								// parsing
46 
47 			status_t			Parse(BString source, BTimeFormatStyle style,
48 									BPrivate::BTime& output);
49 
50 private:
51 			icu::DateFormat*	_CreateTimeFormatter(
52 									const BTimeFormatStyle style) const;
53 };
54 
55 
56 #endif	// _B_TIME_FORMAT_H_
57