initial commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user