DateFormat.h revision 2a5e33a9
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 <DateTimeFormat.h>
10#include <FormattingConventions.h>
11#include <Language.h>
12#include <Locker.h>
13
14
15class BString;
16class BTimeZone;
17
18
19enum BWeekday {
20	B_WEEKDAY_MONDAY = 1,
21	B_WEEKDAY_TUESDAY,
22	B_WEEKDAY_WEDNESDAY,
23	B_WEEKDAY_THURSDAY,
24	B_WEEKDAY_FRIDAY,
25	B_WEEKDAY_SATURDAY,
26	B_WEEKDAY_SUNDAY,
27};
28
29
30class BDateFormat {
31public:
32								BDateFormat(const BLanguage* const,
33									const BFormattingConventions* const);
34								BDateFormat(const BDateFormat &other);
35	virtual						~BDateFormat();
36
37	static	const BDateFormat*	Default();
38
39								// formatting
40
41			ssize_t				Format(char* string, size_t maxSize,
42									time_t time, BDateFormatStyle style) const;
43			status_t			Format(BString* string, time_t time,
44									BDateFormatStyle style,
45									const BTimeZone* timeZone = NULL) const;
46			status_t			Format(BString* string,
47									int*& fieldPositions, int& fieldCount,
48									time_t time, BDateFormatStyle style) const;
49
50			status_t			GetFields(BDateElement*& fields,
51									int& fieldCount, BDateFormatStyle style
52									) const;
53
54			status_t			GetStartOfWeek(BWeekday* weekday) const;
55
56								// TODO parsing
57
58private:
59			icu::DateFormat*	_CreateDateFormatter(
60									const BString& format) const;
61
62	mutable	BLocker				fLock;
63			BFormattingConventions	fConventions;
64			BLanguage			fLanguage;
65};
66
67
68#endif	// _B_DATE_FORMAT_H_
69