2 * Copyright 2010-2014, Haiku, Inc.
3 * Distributed under the terms of the MIT Licence.
5 #ifndef _B_DATE_FORMAT_H_
6 #define _B_DATE_FORMAT_H_
10 #include <DateTimeFormat.h>
12 #include <FormattingConventions.h>
17 #ifndef U_ICU_NAMESPACE
18 #define U_ICU_NAMESPACE icu
20 namespace U_ICU_NAMESPACE
{
40 class BDateFormat
: public BFormat
{
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
);
55 ssize_t
Format(char* string
, const size_t maxSize
,
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
,
67 const BDateFormatStyle style
) const;
69 status_t
GetFields(BDateElement
*& fields
,
70 int& fieldCount
, BDateFormatStyle style
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;
83 status_t
Parse(BString source
, BDateFormatStyle style
,
87 int _ConvertDayNumberToICU(int day
) const;
89 U_ICU_NAMESPACE::DateFormat
* _CreateDateFormatter(
90 const BDateFormatStyle style
) const;
96 BDateFormat::_ConvertDayNumberToICU(int day
) const
98 return day
== 7 ? 1 : day
+ 1;
102 #endif // _B_DATE_FORMAT_H_