Expand description
Strftime-subset pattern parser shared by DateEdit and TimeEdit.
Supported tokens:
| Token | Meaning |
|---|---|
%Y | 4-digit year (zero-padded; sign printed for negatives) |
%m / %-m | 2-digit / 1-or-2-digit month |
%d / %-d | 2-digit / 1-or-2-digit day |
%H / %-H | 24-hour hour |
%I / %-I | 12-hour hour |
%M / %-M | minute |
%S / %-S | second |
%p | AM/PM (12-hour mode) |
%% | literal % |
Anything else between tokens is preserved verbatim as a literal
separator. Locale-localized literal text (%B / %A) is deliberately
NOT supported here — month and weekday names come from tr! keys,
not from the pattern.
Structs§
- Parsed
Pattern - A pattern parsed into segments + literals, ready for formatting and reverse parsing.
Enums§
- Parse
Target - What kind of value is being parsed.
- Parsed
Value - Parsed value.
- Pattern
Error - Pattern parse errors.
- Pattern
Token - One token in a parsed pattern.
- Segment
Kind - What a segment edits.
Functions§
- format_
value - Format a
Dateagainst a parsed pattern. Time segments emit “00”. - mask_
for_ pattern - Build an InputMask grammar string from a parsed pattern. Each
digit segment becomes the corresponding number of
9chars; the AM/PM period segment becomes>AA(two uppercase-locked letters); literals stay as fixed separators. - parse_
value - Reverse-parse a string against a pattern.
- render_
segment - Format a value into its segment string.
- segment_
at_ position - Find the segment under
caret_pos(in formatted-text display coordinates). A caret resting on a segment boundary belongs to the segment to its right (typing-into semantics). A caret on a separator snaps to the preceding segment so Up/Down keep working when the caret is between two segments. ReturnsNoneonly when the pattern has no editable segments at all. - segment_
value_ for_ date - What a segment evaluates to.
Yearcan be negative; the rest are non-negative integers.Periodis0for AM,1for PM. - segment_
value_ for_ time - Time-half evaluator.
- segments_
layout - One editable segment’s span in formatted-text display coordinates.
(start_char_offset, end_char_offset_exclusive, kind). Computed by walkingParsedPattern::tokensand accumulating the rendered width of each segment (4 forYear, 2 forPeriod(AM/PM), 2 for every digit segment) and each literal. Drives caret-in- segment lookups for segment-stepping and per-segment selection. - step_
date_ field - Step a single field of a
Datebydelta. Year saturates at the jiff range and clamps the day if the new year+month no longer holds the current day (e.g. Feb 29 → Feb 28 in non-leap years). Month wraps within[1, 12]and clamps the day to the new month’s last day. Day wraps within the current month — does not advance to the next month, matching QtQDateEditand macOS Calendar behaviour. Returns the inputdateunchanged whenkindis not a date field. - step_
time_ field - Step a single field of a
Timebydelta. Hour wraps in[0, 24)(whether 12h or 24h segment kind — internal storage is 24h). Minute and second wrap in[0, 60). AM/PM toggles on any non-zerodelta(sign-agnostic). Returns the inputtimeunchanged whenkindis not a time field.