Skip to content

Trying to format a time and also a date, help requested #1373

Closed Answered by WerWolv
graydav1 asked this question in Pattern Language Q&A
Discussion options

You must be logged in to vote

Hey, you don't really need to mess with any date-time things since the format is super easy. The stuff that's included in the standard library deals with Unix / Epoch time.

A pattern for this could maybe look like this:

struct DateTime {
    u8 hour, minute, second;
    u8 day, month;
} [[format("format_date_time")]];

fn format_date_time(ref auto dateTime) {
    return std::format("{}:{}:{} {}.{}", dateTime.hour, dateTime.minute, dateTime.second, dateTime.day, dateTime.month);
};

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@graydav1
Comment options

@jumanji144
Comment options

@WerWolv
Comment options

Answer selected by WerWolv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants