Library: Foundation
Package: DateTime
Header: Poco/DateTimeFormatter.h
This class converts dates and times into strings, supporting a variety of standard and custom formats.
There are two kind of static member functions:
Member Functions: append, format, tzdISO, tzdRFC
UTC = 0xFFFF
Special value for timeZoneDifferential denoting UTC.
static void append(
std::string & str,
const Timestamp & timestamp,
const std::string & fmt,
int timeZoneDifferential = UTC
);
Formats the given timestamp according to the given format and appends it to str.
See format() for documentation of the formatting string.
static void append(
std::string & str,
const DateTime & dateTime,
const std::string & fmt,
int timeZoneDifferential = UTC
);
Formats the given date and time according to the given format and appends it to str.
See format() for documentation of the formatting string.
static void append(
std::string & str,
const LocalDateTime & dateTime,
const std::string & fmt
);
Formats the given local date and time according to the given format and appends it to str.
See format() for documentation of the formatting string.
static void append(
std::string & str,
const Timespan & timespan,
const std::string & fmt = "%dd %H:%M:%S.%i"
);
Formats the given timespan according to the given format and appends it to str.
See format() for documentation of the formatting string.
static std::string format(
const Timestamp & timestamp,
const std::string & fmt,
int timeZoneDifferential = UTC
);
Formats the given timestamp according to the given format. The format string is used as a template to format the date and is copied character by character except for the following special characters, which are replaced by the corresponding value.
Class DateTimeFormat defines format strings for various standard date/time formats.
static std::string format(
const DateTime & dateTime,
const std::string & fmt,
int timeZoneDifferential = UTC
);
Formats the given date and time according to the given format. See format(const Timestamp&, const std::string&, int) for more information.
static std::string format(
const LocalDateTime & dateTime,
const std::string & fmt
);
Formats the given local date and time according to the given format. See format(const Timestamp&, const std::string&, int) for more information.
static std::string format(
const Timespan & timespan,
const std::string & fmt = "%dd %H:%M:%S.%i"
);
Formats the given timespan according to the given format. The format string is used as a template to format the date and is copied character by character except for the following special characters, which are replaced by the corresponding value.
static std::string tzdISO(
int timeZoneDifferential
);
Formats the given timezone differential in ISO format. If timeZoneDifferential is UTC, "Z" is returned, otherwise, +HH.MM (or -HH.MM) is returned.
static void tzdISO(
std::string & str,
int timeZoneDifferential
);
Formats the given timezone differential in ISO format and appends it to the given string. If timeZoneDifferential is UTC, "Z" is returned, otherwise, +HH.MM (or -HH.MM) is returned.
static std::string tzdRFC(
int timeZoneDifferential
);
Formats the given timezone differential in RFC format. If timeZoneDifferential is UTC, "GMT" is returned, otherwise ++HHMM (or -HHMM) is returned.
static void tzdRFC(
std::string & str,
int timeZoneDifferential
);
Formats the given timezone differential in RFC format and appends it to the given string. If timeZoneDifferential is UTC, "GMT" is returned, otherwise ++HHMM (or -HHMM) is returned.