Formatter for times.
More...
Inherits BFormat.
|
| BTimeFormat () |
| Default Constructor. The current system locale is used.
|
|
| BTimeFormat (const BLanguage &language, const BFormattingConventions &conventions) |
| Language and formatting convention constructor.
|
|
| BTimeFormat (const BTimeFormat &other) |
| Copy Constructor.
|
|
virtual | ~BTimeFormat () |
| Destructor.
|
|
status_t | Format (BString &string, const time_t time, const BTimeFormatStyle style, const BTimeZone *timeZone=NULL) const |
| Fills in string with a formatted time for the given time, style, and timeZone for the locale.
|
|
status_t | Format (BString &string, int *&fieldPositions, int &fieldCount, time_t time, BTimeFormatStyle style) const |
| Fills in string with a custom formatted date according to the given parameters for the locale and fills out an array of fieldPositions which must be freed by the caller and a fieldCount which contains the number of positions.
|
|
ssize_t | Format (char *string, size_t maxSize, time_t time, BTimeFormatStyle style) const |
| Fills in string with a formatted time up to maxSize bytes for the given time and style for the locale.
|
|
status_t | GetTimeFields (BDateElement *&fields, int &fieldCount, BTimeFormatStyle style) const |
| Get the type of each field in the time format of the locale.
|
|
Formatter for times.
- Since
- Haiku R1
◆ BTimeFormat() [1/3]
BTimeFormat::BTimeFormat |
( |
| ) |
|
Default Constructor. The current system locale is used.
- Since
- Haiku R1
◆ BTimeFormat() [2/3]
BTimeFormat::BTimeFormat |
( |
const BLanguage & |
language, |
|
|
const BFormattingConventions & |
format |
|
) |
| |
Language and formatting convention constructor.
- Parameters
-
language | The language to use. |
format | The formatting convention to use. |
- Since
- Haiku R1
◆ BTimeFormat() [3/3]
Copy Constructor.
- Parameters
-
- Since
- Haiku R1
◆ ~BTimeFormat()
BTimeFormat::~BTimeFormat |
( |
| ) |
|
|
virtual |
Destructor.
- Since
- Haiku R1
◆ Format() [1/3]
Fills in string with a formatted time for the given time, style, and timeZone for the locale.
- Parameters
-
string | The string buffer to fill with the formatted time. |
time | The time (in seconds since epoch) to format. |
style | Specifies whether to use the long format or short format. |
timeZone | Specifies the time zone to use, if NULL , use the system default time zone (usually UTC). |
- Returns
- A status code.
- Return values
-
B_OK | Everything went fine. |
B_ERROR | Unable to lock the BLocale. |
B_NO_MEMORY | Ran out of memory while creating the object. |
B_BAD_VALUE | There was not enough space to store the result. |
- Since
- Haiku R1
◆ Format() [2/3]
status_t BTimeFormat::Format |
( |
BString & |
string, |
|
|
int *& |
fieldPositions, |
|
|
int & |
fieldCount, |
|
|
time_t |
time, |
|
|
BTimeFormatStyle |
style |
|
) |
| const |
Fills in string with a custom formatted date according to the given parameters for the locale and fills out an array of fieldPositions which must be freed by the caller and a fieldCount which contains the number of positions.
The positions are offsets in the string at which each element of the time (hour, minute, second, etc) and the separator starting positions. These can be used, for example, to split the string in parts to use in a locale-aware set of BMenuFields to edit the time in the local format.
- Parameters
-
string | The string buffer to fill with the formatted time. |
fieldPositions | An array of time field positions to be filled out. |
fieldCount | The number of fields in fieldPositions to be filled out. |
time | The time (in seconds since epoch) to format. |
style | Specify the long format (with day name, full month name) or the short format, 08/12/2010 or similar. |
- Returns
- A status code.
- Return values
-
B_OK | Everything went fine. |
B_ERROR | Unable to lock the BLocale. |
B_NO_MEMORY | Ran out of memory while creating the object. |
B_BAD_VALUE | There was not enough space to store the result. |
- Since
- Haiku R1
◆ Format() [3/3]
ssize_t BTimeFormat::Format |
( |
char * |
string, |
|
|
size_t |
maxSize, |
|
|
time_t |
time, |
|
|
BTimeFormatStyle |
style |
|
) |
| const |
Fills in string with a formatted time up to maxSize bytes for the given time and style for the locale.
- Parameters
-
string | The string buffer to fill with the formatted time. |
maxSize | The size of the buffer. |
time | The time (in seconds since midnight) to format. |
style | Specify the long format or the short format. |
- Returns
- The number of bytes written during the time formatting.
- Return values
-
B_ERROR | Unable to lock the BLocale. |
B_NO_MEMORY | Ran out of memory while creating the object. |
B_BAD_VALUE | There was not enough space to store the result. |
- Since
- Haiku R1
◆ GetTimeFields()
status_t BTimeFormat::GetTimeFields |
( |
BDateElement *& |
fields, |
|
|
int & |
fieldCount, |
|
|
BTimeFormatStyle |
style |
|
) |
| const |
Get the type of each field in the time format of the locale.
This method is used most often in combination with FormatTime(). FormatTime() gives you the offset of each field in a formatted string, and GetTimeFields() gives you the type of the field at a given offset. With this information you can handle the formatted time string as a list of fields that you can split and alter at will.
- Parameters
-
fields | Pointer to the fields object. |
fieldCount | The number of fields. |
style | Specify the long format or the short format. |
- Returns
- A status code.
- Return values
-
B_OK | Everything went fine. |
B_ERROR | Unable to lock the BLocale. |
B_NO_MEMORY | Ran out of memory while creating the object. |
B_BAD_VALUE | Bad or invalid fields data. |
- Since
- Haiku R1