Poco

class DateTimeFormatter

Library: Foundation
Package: DateTime
Header: Poco/DateTimeFormatter.h

Description

This class converts dates and times into strings, supporting a variety of standard and custom formats.

Member Summary

Member Functions: format, tzdISO, tzdRFC

Enumerations

Anonymous

UTC = 0xFFFF

Special value for timeZoneDifferential denoting UTC.

Member Functions

format static

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.

format static

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.

format static

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.

format static

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.

tzdISO static

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.

tzdRFC static

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.