Move time formatting to BTimeformat.
* Harmonize API for all B*Format to take an output BString by reference as the first parameter, * Move the FormatTime methods from BLocale to BTimeFormat * Adjust all callers for BTimeFormat, BTimeUnitFormat and BDurationFormat.
This commit is contained in:
@@ -35,8 +35,9 @@ public:
|
||||
virtual status_t SetLanguage(const BLanguage& language);
|
||||
status_t SetTimeZone(const BTimeZone* timeZone);
|
||||
|
||||
status_t Format(bigtime_t startValue,
|
||||
bigtime_t stopValue, BString* buffer,
|
||||
status_t Format(BString& buffer,
|
||||
const bigtime_t startValue,
|
||||
const bigtime_t stopValue,
|
||||
time_unit_style style = B_TIME_UNIT_FULL
|
||||
) const;
|
||||
|
||||
|
||||
@@ -69,27 +69,6 @@ public:
|
||||
BTimeFormatStyle timeStyle,
|
||||
const BTimeZone* timeZone = NULL) const;
|
||||
|
||||
// Time
|
||||
|
||||
// TODO: drop some of these once BTimeFormat
|
||||
// has been implemented!
|
||||
ssize_t FormatTime(char* string, size_t maxSize,
|
||||
time_t time, BTimeFormatStyle style) const;
|
||||
ssize_t FormatTime(char* string, size_t maxSize,
|
||||
time_t time, BString format) const;
|
||||
status_t FormatTime(BString* string, time_t time,
|
||||
BTimeFormatStyle style,
|
||||
const BTimeZone* timeZone = NULL) const;
|
||||
status_t FormatTime(BString* string, time_t time,
|
||||
BString format,
|
||||
const BTimeZone* timeZone) const;
|
||||
status_t FormatTime(BString* string,
|
||||
int*& fieldPositions, int& fieldCount,
|
||||
time_t time, BTimeFormatStyle style) const;
|
||||
status_t GetTimeFields(BDateElement*& fields,
|
||||
int& fieldCount, BTimeFormatStyle style
|
||||
) const;
|
||||
|
||||
// numbers
|
||||
|
||||
ssize_t FormatNumber(char* string, size_t maxSize,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010, Haiku, Inc.
|
||||
* Copyright 2010-2014, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT Licence.
|
||||
*/
|
||||
#ifndef _B_TIME_FORMAT_H_
|
||||
@@ -9,20 +9,41 @@
|
||||
|
||||
|
||||
class BString;
|
||||
class BTimeZone;
|
||||
|
||||
class BTimeFormat : public BDateTimeFormat {
|
||||
class BTimeFormat : public BFormat {
|
||||
public:
|
||||
BTimeFormat(
|
||||
const BLanguage* const language = NULL,
|
||||
const BFormattingConventions* const
|
||||
format = NULL);
|
||||
BTimeFormat(const BTimeFormat &other);
|
||||
virtual ~BTimeFormat();
|
||||
|
||||
// formatting
|
||||
|
||||
// no-frills version: Simply appends the
|
||||
// formatted date to the string buffer.
|
||||
// Can fail only with B_NO_MEMORY or B_BAD_VALUE.
|
||||
virtual status_t Format(bigtime_t value, BString* buffer) const;
|
||||
ssize_t Format(char* string, size_t maxSize,
|
||||
time_t time, BTimeFormatStyle style) const;
|
||||
ssize_t Format(char* string, size_t maxSize,
|
||||
time_t time, BString format) const;
|
||||
status_t Format(BString& string, const time_t time,
|
||||
const BTimeFormatStyle style,
|
||||
const BTimeZone* timeZone = NULL) const;
|
||||
status_t Format(BString& string, const time_t time,
|
||||
const BString format,
|
||||
const BTimeZone* timeZone) const;
|
||||
status_t Format(BString& string,
|
||||
int*& fieldPositions, int& fieldCount,
|
||||
time_t time, BTimeFormatStyle style) const;
|
||||
|
||||
// TODO: ... basically, all of it!
|
||||
status_t GetTimeFields(BDateElement*& fields,
|
||||
int& fieldCount, BTimeFormatStyle style
|
||||
) const;
|
||||
|
||||
// TODO parsing
|
||||
private:
|
||||
icu::DateFormat* _CreateTimeFormatter(
|
||||
const BString& format) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -47,8 +47,9 @@ public:
|
||||
BTimeUnitFormat& operator=(const BTimeUnitFormat& other);
|
||||
|
||||
virtual status_t SetLanguage(const BLanguage& locale);
|
||||
status_t Format(int32 value, time_unit_element unit,
|
||||
BString* buffer,
|
||||
status_t Format(BString& buffer,
|
||||
const int32 value,
|
||||
const time_unit_element unit,
|
||||
time_unit_style style = B_TIME_UNIT_FULL
|
||||
) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user