Public Member Functions | List of all members
BDateTimeFormat Class Reference

Formatter for datetimes. More...

Inherits BFormat.

Public Member Functions

 BDateTimeFormat (const BLocale *locale=NULL)
 Locale constructor. More...
 
 BDateTimeFormat (const BLanguage &language, const BFormattingConventions &conventions)
 Language and formatting convention constructor. More...
 
 BDateTimeFormat (const BDateTimeFormat &other)
 Copy Constructor. More...
 
virtual ~BDateTimeFormat ()
 Destructor. More...
 
ssize_t Format (char *target, const size_t maxSize, const time_t time, BDateFormatStyle dateStyle, BTimeFormatStyle timeStyle) const
 Fills in string with a formatted datetime up to maxSize bytes for the given time and style for the locale. More...
 
status_t Format (BString &buffer, const time_t time, BDateFormatStyle dateStyle, BTimeFormatStyle timeStyle, const BTimeZone *timeZone=NULL) const
 Fills in string with a formatted datetime for the given time, timeStyle, and timeZone for the locale. More...
 

Detailed Description

Formatter for datetimes.

Since
Haiku R1

Constructor & Destructor Documentation

◆ BDateTimeFormat() [1/3]

BDateTimeFormat::BDateTimeFormat ( const BLocale locale = NULL)

Locale constructor.

Parameters
localeThe locale to use, can be NULL for the default locale.

◆ BDateTimeFormat() [2/3]

BDateTimeFormat::BDateTimeFormat ( const BLanguage &  language,
const BFormattingConventions &  format 
)

Language and formatting convention constructor.

Parameters
languageThe language to use.
formatThe formatting convention to use.

◆ BDateTimeFormat() [3/3]

BDateTimeFormat::BDateTimeFormat ( const BDateTimeFormat other)

Copy Constructor.

Parameters
otherThe BDateTimeFormat object to copy from.
Since
Haiku R1

◆ ~BDateTimeFormat()

BDateTimeFormat::~BDateTimeFormat ( )
virtual

Destructor.

Since
Haiku R1

Member Function Documentation

◆ Format() [1/2]

ssize_t BDateTimeFormat::Format ( char *  target,
const size_t  maxSize,
const time_t  time,
BDateFormatStyle  dateStyle,
BTimeFormatStyle  timeStyle 
) const

Fills in string with a formatted datetime up to maxSize bytes for the given time and style for the locale.

Parameters
targetThe string buffer to fill with the formatted datetime.
maxSizeThe size of the buffer.
timeThe time (in seconds since epoch) to format
dateStyleSpecify the long format or the short format of the date.
timeStyleSpecify the long format or the short format of the time.
Returns
The number of bytes written during the datetime formatting.
Return values
B_ERRORUnable to lock the BLocale.
B_NO_MEMORYRan out of memory while creating the object.
B_BAD_VALUEThere was not enough space to store the result.
Since
Haiku R1

◆ Format() [2/2]

status_t BDateTimeFormat::Format ( BString buffer,
const time_t  time,
BDateFormatStyle  dateStyle,
BTimeFormatStyle  timeStyle,
const BTimeZone timeZone = NULL 
) const

Fills in string with a formatted datetime for the given time, timeStyle, and timeZone for the locale.

Parameters
bufferThe string buffer to fill with the formatted date.
timeThe time (in seconds since epoch) to format
dateStyleSpecifies the long format or the short format of the date.
timeStyleSpecifies the long format or the short format of the time.
timeZoneSpecifies the time zone to use, if NULL, use the system default time zone (usually UTC).
Returns
A status code.
Return values
B_OKEverything went fine.
B_ERRORUnable to lock the BLocale.
B_NO_MEMORYRan out of memory while creating the object.
Since
Haiku R1