haiku/headers/os/locale/DateFormat.h
Adrien Destugues 2a5e33a980 Move date formatting from BLocale to BDateFormat
* There is a little code duplication. This will be moved to BFormat once
the time and datetime formatting is also moved out of BLocale
* The way to create a BDateFormat from a BLocale is still open for
discussion. I'm undecided between making BDateFormat a member of
BLocale, or adding a BDateFormat(const BLocale&) constructor.
* Adjust all users of the API.
2014-09-26 18:31:11 +02:00

69 lines
1.5 KiB
C++

/*
* Copyright 2010-2014, Haiku, Inc.
* Distributed under the terms of the MIT Licence.
*/
#ifndef _B_DATE_FORMAT_H_
#define _B_DATE_FORMAT_H_
#include <DateTimeFormat.h>
#include <FormattingConventions.h>
#include <Language.h>
#include <Locker.h>
class BString;
class BTimeZone;
enum BWeekday {
B_WEEKDAY_MONDAY = 1,
B_WEEKDAY_TUESDAY,
B_WEEKDAY_WEDNESDAY,
B_WEEKDAY_THURSDAY,
B_WEEKDAY_FRIDAY,
B_WEEKDAY_SATURDAY,
B_WEEKDAY_SUNDAY,
};
class BDateFormat {
public:
BDateFormat(const BLanguage* const,
const BFormattingConventions* const);
BDateFormat(const BDateFormat &other);
virtual ~BDateFormat();
static const BDateFormat* Default();
// formatting
ssize_t Format(char* string, size_t maxSize,
time_t time, BDateFormatStyle style) const;
status_t Format(BString* string, time_t time,
BDateFormatStyle style,
const BTimeZone* timeZone = NULL) const;
status_t Format(BString* string,
int*& fieldPositions, int& fieldCount,
time_t time, BDateFormatStyle style) const;
status_t GetFields(BDateElement*& fields,
int& fieldCount, BDateFormatStyle style
) const;
status_t GetStartOfWeek(BWeekday* weekday) const;
// TODO parsing
private:
icu::DateFormat* _CreateDateFormatter(
const BString& format) const;
mutable BLocker fLock;
BFormattingConventions fConventions;
BLanguage fLanguage;
};
#endif // _B_DATE_FORMAT_H_