Skip to content

proposal: time: Parse time similar to fmt.Scanf and related functions #30373

@Riven-Spell

Description

@Riven-Spell

In reference to #29911, with being unable to require a 24-hour hour zero-padded.

Perhaps we could have time formats provided similarly to fmt.Printf()?

It'd require reworking some things, but just on a whim, how does this sound?
(_ specifies a missing digit)

%_h - _ length 12 hour zero-padded hour
%_H - _ length 24 hour zero-padded hour
%_m - _ length zero-padded minute
%_s - _ length zero-padded second

%_D - _ length zero-padded days
%_M - _ length zero-padded months
%_Y - _ length zero-padded years

now, this is where the naming convention started feeling shaky.
I figured W since it's an upside-down m, and could still say "word".
But, day, I struggled with. This is where I'd like suggestions, because C does not feel fitting at all, and was more of a placeholder if anything.

%w - 3-letter month word (Ex. Jan)
%W - full month word (Ex. January)
%c - 3-letter day word (Ex. Mon)
%C - full day word (Ex. Monday)

The missing digits could easily be optional, too. It'd allow for very flexible formatting of date and time, in comparison to what we currently have.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions