Support RFC3339 timestamps for wslc container logs --since/--until (#40826)
* Add --timestamps, --since, and --until flags to wslc container logs Wire up the existing WSLCLogsFlagsTimestamps flag and Since/Until parameters from the IWSLCContainer::Logs COM interface to the CLI. Previously these were hardcoded to 0/disabled despite the backend already supporting them. Changes: - Add Timestamps (flag, -t), Since (value), Until (value) argument types - Add ULONGLONG validation for --since and --until - Register new args on the container logs command - Pass timestamps flag and since/until values through to the COM call - Add localization strings with {Locked} comments for the new flags - Add 8 command-line parsing unit test cases - Add 6 end-to-end test methods covering timestamps, since, until, combined usage, and short flag (-t) Usage: wslc container logs --timestamps mycontainer wslc container logs --since 1700000000 mycontainer wslc container logs --until 1700001000 mycontainer wslc container logs -t -f --since 0 --tail 50 mycontainer Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add localization placeholders for new log flag strings Add WSLCCLI_TimestampsArgDescription, WSLCCLI_SinceArgDescription, and WSLCCLI_UntilArgDescription to all 21 non-en-US locale files with English placeholder values. These will be translated by the localization team. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Support RFC3339 timestamps for wslc container logs --since/--until Add RFC3339 date-time parsing (e.g. 2024-01-15T10:30:00Z) as an alternative to Unix epoch seconds for the --since and --until arguments of 'wsl container logs'. This aligns with the Docker CLI timestamp format. The parser handles: - UTC timestamps with 'Z' suffix - Timezone offsets in +HH:MM and +HHMM formats - Fractional seconds (ignored for epoch conversion) - Validation of date/time component ranges Invalid inputs (pre-1970 dates, malformed strings, trailing garbage) are rejected with a descriptive error message. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review feedback: use std::chrono::parse, revert non-en-US locales - Replace custom RFC3339 parser with std::chrono::parse, matching the pattern used in WSLCContainer.cpp's ParseDockerTimestamp - Pre-validate year_month_day to reject impossible dates (e.g. Feb 31) that std::chrono::parse normalizes instead of rejecting - Strip fractional seconds before parsing (second-level precision only) - Normalize Z suffix to +00:00 to avoid %Z greedy timezone matching - Reject trailing garbage after timezone designator via stream.peek() - Revert non-en-US locale files (generated by localization pipeline) - Strengthen E2E timestamp tests to validate RFC3339 structure instead of just checking for 'T' character - Add test cases for invalid day-of-month and dot-without-digits Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address code review: simplify TryParseRfc3339 and improve tests - Parse into sys_time<milliseconds> to handle fractional seconds natively instead of manually stripping them (per @OneBlue review) - Remove manual year_month_day pre-validation since std::chrono::parse already rejects invalid dates on MSVC (confirmed via godbolt) - Add +HHMM (no colon) test case showing it is correctly rejected - Fix AllOptionsCombined test to validate RFC3339 structure properly (check separator positions instead of just finding 'T') - Document that since=0/until=0 means 'unset' in Docker API Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add unit tests for TryParseRfc3339 timestamp parsing Per @dkbennett review: add dedicated unit tests exercising the timestamp parsing logic directly via GetTimestampFromString. Tests cover: - Valid Unix epoch integers - Valid RFC3339 with Z, lowercase z, and +/-HH:MM offsets - Fractional seconds (truncated to whole seconds) - Invalid inputs: bad month/hour/day, missing TZ, date-only, trailing chars, +HHMM (no colon), dot with no digits, random text, pre-1970 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix RFC3339 timestamp parsing tests and validation - Fix incorrect expected Unix timestamps in unit tests (off by 3600s due to computation errors in the original values) - Add date validation to reject invalid calendar dates (e.g. Feb 31) that std::chrono::parse silently wraps - Reject bare dot with no fractional digits (e.g. '10:30:00.Z') - Use nanosecond precision for std::chrono::parse to properly consume long fractional seconds (e.g. '.123456789') Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Pooja Trivedi <trivedipooja@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>