Files
radiantwave/src/date_format.h
T
2026-08-07 14:51:41 -05:00

30 lines
847 B
C++

#pragma once
#include <ctime>
#include <string>
#include <vector>
namespace radiantwave::datetime {
// Default date format (US convention): MM/DD/YYYY.
constexpr const char* DEFAULT_DATE_FORMAT = "%m/%d/%Y";
// One selectable date format. `name` is a human-friendly convention label;
// `pattern` is the strftime spec used to render it.
struct DateFormatOption {
std::string name;
std::string pattern;
};
// The formats offered to the end user, ordered most-to-least common.
std::vector<DateFormatOption> getDateFormatOptions();
// Render `t` in local time using a strftime pattern (e.g. "%m/%d/%Y").
// Falls back to an empty string on error.
std::string formatDate(std::time_t t, const std::string& pattern);
// Render `t` as a 24-hour clock: HH:MM:SS.
std::string formatTime(std::time_t t);
} // namespace radiantwave::datetime