DateFormat.h revision 090a0d76
1/*
2 * Copyright 2010-2014, Haiku, Inc.
3 * Distributed under the terms of the MIT Licence.
4 */
5#ifndef _B_DATE_FORMAT_H_
6#define _B_DATE_FORMAT_H_
7
8
9#include <DateTime.h>
10#include <DateTimeFormat.h>
11#include <Format.h>
12#include <FormattingConventions.h>
13#include <Language.h>
14#include <Locker.h>
15
16
17namespace icu {
18	class DateFormat;
19}
20
21
22class BString;
23class BTimeZone;
24
25
26enum BWeekday {
27	B_WEEKDAY_MONDAY = 1,
28	B_WEEKDAY_TUESDAY,
29	B_WEEKDAY_WEDNESDAY,
30	B_WEEKDAY_THURSDAY,
31	B_WEEKDAY_FRIDAY,
32	B_WEEKDAY_SATURDAY,
33	B_WEEKDAY_SUNDAY,
34};
35
36
37class BDateFormat: public BFormat {
38public:
39								BDateFormat(
40									const BLanguage* const language = NULL,
41									const BFormattingConventions* const
42										format = NULL);
43								BDateFormat(const BDateFormat &other);
44	virtual						~BDateFormat();
45
46			status_t			GetDateFormat(BDateFormatStyle style,
47									BString& outFormat) const;
48			void				SetDateFormat(BDateFormatStyle style,
49									const BString& format);
50
51								// formatting
52
53			ssize_t				Format(char* string, const size_t maxSize,
54									const time_t time,
55									const BDateFormatStyle style) const;
56			status_t			Format(BString& string, const time_t time,
57									const BDateFormatStyle style,
58									const BTimeZone* timeZone = NULL) const;
59			status_t			Format(BString& string, const BDate& time,
60									const BDateFormatStyle style,
61									const BTimeZone* timeZone = NULL) const;
62			status_t			Format(BString& string,
63									int*& fieldPositions, int& fieldCount,
64									const time_t time,
65									const BDateFormatStyle style) const;
66
67			status_t			GetFields(BDateElement*& fields,
68									int& fieldCount, BDateFormatStyle style
69									) const;
70
71			status_t			GetStartOfWeek(BWeekday* weekday) const;
72			status_t			GetMonthName(int month, BString& outName);
73
74								// TODO parsing
75
76private:
77			icu::DateFormat*	_CreateDateFormatter(
78									const BString& format) const;
79
80};
81
82
83#endif	// _B_DATE_FORMAT_H_
84