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