5d5ec05b1d
The language and formatting conventions can now only be set when creating the objects. This removed the needs for locking them when formatting to avoid some other thread changing the format while it's being used. Adjust tests and DeskBar TimeView to the API changes.
57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
/*
|
|
* Copyright 2010-2014, Haiku, Inc.
|
|
* Distributed under the terms of the MIT Licence.
|
|
*/
|
|
#ifndef _B_TIME_FORMAT_H_
|
|
#define _B_TIME_FORMAT_H_
|
|
|
|
|
|
#include <DateTimeFormat.h>
|
|
|
|
|
|
class BString;
|
|
|
|
namespace BPrivate {
|
|
class BTime;
|
|
}
|
|
|
|
|
|
class BTimeFormat : public BFormat {
|
|
public:
|
|
BTimeFormat();
|
|
BTimeFormat(const BLanguage& language,
|
|
const BFormattingConventions& conventions);
|
|
BTimeFormat(const BTimeFormat &other);
|
|
virtual ~BTimeFormat();
|
|
|
|
void SetTimeFormat(BTimeFormatStyle style,
|
|
const BString& format);
|
|
|
|
// formatting
|
|
|
|
ssize_t Format(char* string, size_t maxSize,
|
|
time_t time, BTimeFormatStyle style) const;
|
|
status_t Format(BString& string, const time_t time,
|
|
const BTimeFormatStyle style,
|
|
const BTimeZone* timeZone = NULL) const;
|
|
status_t Format(BString& string,
|
|
int*& fieldPositions, int& fieldCount,
|
|
time_t time, BTimeFormatStyle style) const;
|
|
|
|
status_t GetTimeFields(BDateElement*& fields,
|
|
int& fieldCount, BTimeFormatStyle style
|
|
) const;
|
|
|
|
// parsing
|
|
|
|
status_t Parse(BString source, BTimeFormatStyle style,
|
|
BPrivate::BTime& output);
|
|
|
|
private:
|
|
icu::DateFormat* _CreateTimeFormatter(
|
|
const BTimeFormatStyle style) const;
|
|
};
|
|
|
|
|
|
#endif // _B_TIME_FORMAT_H_
|