TimestampConverter Module

Module Contents

class TimestampConverter

TimestampConverter - timestamp to/from string

We need to be able to convert strings to tracktable::Timestamp instances and the reverse while using custom time input/output facets. There are enough differences in the way locales are implemented across platforms that I insist on encapsulating it in this class. We will use this in readers and writers.

Public Functions

TimestampConverter()
virtual ~TimestampConverter()
TimestampConverter(TimestampConverter const &other)
TimestampConverter &operator=(TimestampConverter const &other)
bool operator==(TimestampConverter const &other) const
bool operator!=(TimestampConverter const &other) const
void set_input_format(string_type const &format)

Set format string for parsing timestamps

This format string must adhere to the guidelines in the documentation for Boost’s date/time input format. See the following page:

http://www.boost.org/doc/libs/master/doc/html/date_time/date_time_io.html

Parameters:

format[in] Format string for timestamp parsing

string_type input_format() const

Return the current input format

Returns:

Format string for timestamp parsing

void set_output_format(string_type const &format)

Set format string for writing timestamps to strings

This format string must adhere to the guidelines in the documentation for Boost’s date/time input format. See the following page:

http://www.boost.org/doc/libs/master/doc/html/date_time/date_time_io.html

Parameters:

format[in] Format string for timestamp output

string_type output_format() const

Return the current output format

Returns:

Format string for timestamp output

string_type timestamp_to_string(Timestamp const &timestamp) const

Convert a timestamp to a string

Convert a timestamp to a string according to the current output format.

Parameters:

timestamp[in] Timestamp to write

Returns:

String representation of timestamp

Timestamp timestamp_from_string(string_type const &time_string) const

Convert a string to a timestamp

Parse a string to create a timestamp according to the current input format.

Parameters:

time_string[in] Timestamp represented as string

Returns:

Timestamp parsed from string

Private Members

string_type InputFormat
string_type OutputFormat
mutable std::ostringstream OutputBuf
mutable std::istringstream InputBuf