Static class to provide utility functions for formatting date and time.
More...
#include <DateTimeFormat.h>
|
static std::time_t | makeTimeT (int year, int month, int day) |
| Creates a std::time_t from integer year, month, and day.
|
|
static std::string | formatDate (std::time_t t, DateFormatStyle style) |
| Formats a date according to the current locale on POSIX systems.
|
|
static std::string | formatTime (std::time_t t, bool includeSeconds) |
| Formats a time according to the current locale.
|
|
Static class to provide utility functions for formatting date and time.
◆ DateFormatStyle
Defines the date format styles supported by formatDate.
Enumerator |
---|
Short | Short date format (e.g., 7/10/25)
|
Long | Long date format (e.g., July 10, 2025)
|
LongAbbreviated | Long abbreviated date format (e.g., Jul 10, 2025)
|
◆ formatDate()
static std::string musx::util::DateTime::formatDate |
( |
std::time_t |
t, |
|
|
DateFormatStyle |
style |
|
) |
| |
|
inlinestatic |
Formats a date according to the current locale on POSIX systems.
Uses strftime to produce a locale-specific date string.
- Parameters
-
t | The time value to format. |
style | The desired date format style. |
- Returns
- A formatted date string, or an empty string on failure.
◆ formatTime()
static std::string musx::util::DateTime::formatTime |
( |
std::time_t |
t, |
|
|
bool |
includeSeconds |
|
) |
| |
|
inlinestatic |
Formats a time according to the current locale.
If includeSeconds is true, uses locale-based full time formatting. If includeSeconds is false, formats as hh:mm, choosing 12h or 24h based on system or locale preference.
- Parameters
-
t | The time value to format. |
includeSeconds | If true, includes seconds in the formatted time. |
- Returns
- A formatted time string.
◆ makeTimeT()
static std::time_t musx::util::DateTime::makeTimeT |
( |
int |
year, |
|
|
int |
month, |
|
|
int |
day |
|
) |
| |
|
inlinestatic |
Creates a std::time_t from integer year, month, and day.
- Parameters
-
year | Full year (e.g., 2025). |
month | Month of year (1-12). |
day | Day of month (1-31). |
- Returns
- std::time_t representing the local time at midnight of that date.