Fix FreeBSD build.
[haiku.git] / headers / os / locale / DateFormat.h
blobcee04e5543a89e2c629eb04b7b9ac476fcf163b9
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_
9 #include <DateTime.h>
10 #include <DateTimeFormat.h>
11 #include <Format.h>
12 #include <FormattingConventions.h>
13 #include <Language.h>
14 #include <Locker.h>
17 #ifndef U_ICU_NAMESPACE
18 #define U_ICU_NAMESPACE icu
19 #endif
20 namespace U_ICU_NAMESPACE {
21 class DateFormat;
25 class BString;
26 class BTimeZone;
29 enum BWeekday {
30 B_WEEKDAY_MONDAY = 1,
31 B_WEEKDAY_TUESDAY,
32 B_WEEKDAY_WEDNESDAY,
33 B_WEEKDAY_THURSDAY,
34 B_WEEKDAY_FRIDAY,
35 B_WEEKDAY_SATURDAY,
36 B_WEEKDAY_SUNDAY,
40 class BDateFormat: public BFormat {
41 public:
42 BDateFormat(const BLocale* locale = NULL);
43 BDateFormat(const BLanguage& language,
44 const BFormattingConventions& format);
45 BDateFormat(const BDateFormat &other);
46 virtual ~BDateFormat();
48 status_t GetDateFormat(BDateFormatStyle style,
49 BString& outFormat) const;
50 void SetDateFormat(BDateFormatStyle style,
51 const BString& format);
53 // formatting
55 ssize_t Format(char* string, const size_t maxSize,
56 const time_t time,
57 const BDateFormatStyle style) const;
58 status_t Format(BString& string, const time_t time,
59 const BDateFormatStyle style,
60 const BTimeZone* timeZone = NULL) const;
61 status_t Format(BString& string, const BDate& time,
62 const BDateFormatStyle style,
63 const BTimeZone* timeZone = NULL) const;
64 status_t Format(BString& string,
65 int*& fieldPositions, int& fieldCount,
66 const time_t time,
67 const BDateFormatStyle style) const;
69 status_t GetFields(BDateElement*& fields,
70 int& fieldCount, BDateFormatStyle style
71 ) const;
73 status_t GetStartOfWeek(BWeekday* weekday) const;
74 status_t GetMonthName(int month, BString& outName,
75 const BDateFormatStyle style
76 = B_FULL_DATE_FORMAT) const;
77 status_t GetDayName(int day, BString& outName,
78 const BDateFormatStyle style
79 = B_FULL_DATE_FORMAT) const;
81 // parsing
83 status_t Parse(BString source, BDateFormatStyle style,
84 BDate& output);
86 private:
87 int _ConvertDayNumberToICU(int day) const;
89 U_ICU_NAMESPACE::DateFormat* _CreateDateFormatter(
90 const BDateFormatStyle style) const;
95 inline int
96 BDateFormat::_ConvertDayNumberToICU(int day) const
98 return day == 7 ? 1 : day + 1;
102 #endif // _B_DATE_FORMAT_H_