SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWTimeTupleFormatter Class Reference

Formats a RWTimeTuple based on a user-defined format. More...

#include <rw/tools/timetupleformatter.h>

Public Member Functions

 RWTimeTupleFormatter (const RWCString &format)
 
 RWTimeTupleFormatter (RWCString &&format)
 
 RWTimeTupleFormatter (const RWTimeTupleFormatter &rhs)
 
 RWTimeTupleFormatter (RWTimeTupleFormatter &&rhs)
 
 ~RWTimeTupleFormatter ()
 
RWCString operator() (const RWTimeTuple &tt) const
 
RWCString operator() (const RWTimeTuple &tt, const RWLocale &locale) const
 
RWTimeTupleFormatteroperator= (const RWTimeTupleFormatter &rhs)
 
RWTimeTupleFormatteroperator= (RWTimeTupleFormatter &&rhs)
 

Detailed Description

RWTimeTupleFormatter uses a strftime()-based format specification, however not all strftime() format specifiers are supported, and some have a different meaning than in strftime().

The format specification may contain conversion specifications and literal characters. A conversion specification consists of a leading '%' character, an optional format flag character, an optional field width, and a conversion specification character to terminate. All other characters are considered to be literals and are copied to the output directly. For example, the format string '%+6Y' uses the format flag '+', a field width of 6, and the format specification character 'Y'.

The following table shows the conversion specification characters that may be used with RWTimeTupleFormatter. In all cases, the behavior of the format function is unspecified when the input tuple is not normalized.

Conversion character Meaning
%b Replaced by the locale's abbreviated month name. Month values outside the range [1,12] result in unspecified behavior.
%B Replaced by the locale's full month name. Month values outside the range [1,12] result in unspecified behavior.
%C Replaced by the year divided by 100 and truncated to an integer, as a decimal number. Year values outside the range [INT_MIN + 1,INT_MAX] result in unspecified behavior.
%d Replaced by the day of the month as a decimal number [01,31]. Day of month values outside the range [1,31] result in unspecified behavior.
%e Replaced by the day of the month as a decimal number [1,31]; a single digit is preceded by a space. Day of month values outside the range [1,31] result in unspecified behavior.
%m Replaced by the month as a decimal number [01,12]. Month values outside the range [1,12] result in unspecified behavior.
%y Replaced by the last two digits of the year as a decimal number [00,99]. Year values outside the range [INT_MIN + 1,INT_MAX] result in unspecified behavior.
%Y Replaced by the year as a decimal number (for example, 1997). Year values outside the range [INT_MIN + 1,INT_MAX] result in unspecified behavior.
%F Replaced by the fractional seconds as a decimal number [000000000000,999999999999]. Picosecond values outside the range [0,999999999999] result in unspecified behavior.
%H Replaced by the hour (24-hour clock) as a decimal number [00,23]. Hour values outside the range [0,23] result in unspecified behavior.
%I Replaced by the hour (12-hour clock) as a decimal number [01,12]. hour values outside the range [0,23] result in unspecified behavior.
%M Replaced by the minute as a decimal number [00,59]. Minute values outside the range [0,59] result in unspecified behavior.
%p Replaced by the locale's equivalent of either a.m. or p.m., as if a call were made to locale.asString(..., 'p') for the provided locale, or RWLocale::global() if no locale is provided.
%r Replaced by the time in a.m. and p.m. notation, as if a call were made to locale.asString(..., 'r') for the provided locale, or RWLocale::global() if no locale is provided.
%S Replaced by the second as a decimal number [00,60]. The range is up to 60 to allow for occasional leap seconds. Second values outside the range [0,60] result in unspecified behavior.

Not all conversions support the flag or field width specifiers. The following tables summarize the supported format options and their meanings for each format specification character that supports them.

Conversion character Flag Meaning
%C + Sign should be output for positive values, but only when the specified field width or the number of digits to represent is greater than 2. A minimum field width must be specified.
0 The output should be padded with 0 out to the minimum field width or 2, whichever is greater. A minimum field width must be specified.
<width> An unsigned integer that specifies the minimum field width, including the sign.
%Y + Sign should be output for positive values, but only when the specified field width or the number of digits to represent is greater than 4. A minimum field width must be specified.
0 The output should be padded with 0 out to the minimum field width or 2, whichever is greater. A minimum field width must be specified.
<width> An unsigned integer that specifies the minimum field width, including the sign.
%F <width> An unsigned integer that specifies the field width. If the number of digits to represent is greater than this value, the result will be truncated.

As an example, given the year 15, the full format specification "%+5Y" would produce "+0015", and "%5Y" would produce "00015".

Constructor & Destructor Documentation

RWTimeTupleFormatter::RWTimeTupleFormatter ( const RWCString format)
inline

Constructs an RWTimeTupleFormatter with the format specification format.

RWTimeTupleFormatter::RWTimeTupleFormatter ( RWCString &&  format)
inline

Constructs an RWTimeTupleFormatter with the format specification format.

Condition:
This method is available only on platforms with rvalue reference support.
RWTimeTupleFormatter::RWTimeTupleFormatter ( const RWTimeTupleFormatter rhs)
inline

Copy constructor.

RWTimeTupleFormatter::RWTimeTupleFormatter ( RWTimeTupleFormatter &&  rhs)
inline

Move constructor.

Condition:
This method is available only on platforms with rvalue reference support.
RWTimeTupleFormatter::~RWTimeTupleFormatter ( )
inline

Destructor.

Member Function Documentation

RWCString RWTimeTupleFormatter::operator() ( const RWTimeTuple tt) const

Generates a string representation of tt based on the current format. For locale-specific behavior, the RWLocale returned by RWLocale::global() is used.

RWCString RWTimeTupleFormatter::operator() ( const RWTimeTuple tt,
const RWLocale locale 
) const

Generates a string representation of tt based on the current format. For locale-specific behavior, locale is used.

RWTimeTupleFormatter & RWTimeTupleFormatter::operator= ( const RWTimeTupleFormatter rhs)
inline

Copy assignment operator.

RWTimeTupleFormatter & RWTimeTupleFormatter::operator= ( RWTimeTupleFormatter &&  rhs)
inline

Move assignment operator.

Condition:
This method is available only on platforms with rvalue reference support.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.