mirror of
https://review.haiku-os.org/haiku
synced 2025-02-04 12:46:58 +01:00
2a5e33a980
* 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.
69 lines
1.5 KiB
C++
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_
|