Skip to content

Add functions for time formatting #5

@alt-graph

Description

@alt-graph

In the DOOCS clientlib we have functions for formatting local time:

/**
 * Convert a timestamp into local time and format it into a std::string using strftime()
 * format specifiers.
 *
 * Due to the limitations of strftime(), this function does not support sub-second
 * output precision.
 *
 * \param ts   The timestamp to be formatted.
 * \param fmt  A format string following the specifications of strftime(), see
 *             https://en.cppreference.com/w/cpp/chrono/c/strftime . If fmt is a null
 *             pointer, an empty string is returned. The default format generates an
               ISO 8601 compliant date-time string.
 * \returns a string with the formatted output or an empty string if an error occurred.
 */
std::string format_localtime (Timestamp ts, const char *fmt = "%Y-%m-%dT%H:%M:%S");
std::string format_localtime (std::time_t t, const char *fmt = "%Y-%m-%dT%H:%M:%S");

Such functions are useful also for other projects (both for UTC and local times). I'd say we could use them in GUL14.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions