Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/windows/wslcsession/WSLCContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,19 @@ WSLCContainerNetworkType DockerNetworkModeToWSLCNetworkType(const std::string& m
std::uint64_t ParseDockerTimestamp(const std::string& timestamp)
{
// Docker timestamps are UTC ISO 8601, e.g. "2026-03-05T10:30:00.123456789Z".
// We only need epoch seconds, so strip the optional fractional component before parsing.
std::string normalized = timestamp;
if (const auto tPos = normalized.find('T'); tPos != std::string::npos)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing this, I think we can just drop the %Z part of the format and std::chrono::parse() should just ignore the fractional second part

{
if (const auto dot = normalized.find('.', tPos + 1); dot != std::string::npos)
Comment on lines +309 to +313
{
const auto tzStart = normalized.find_first_of("Z+-", dot + 1);
normalized.erase(dot, (tzStart == std::string::npos) ? std::string::npos : tzStart - dot);
}
}

std::chrono::sys_seconds utcSeconds;
std::istringstream stream(timestamp);
std::istringstream stream(normalized);
stream >> std::chrono::parse("%FT%H:%M:%S%Z", utcSeconds);
THROW_HR_IF_MSG(E_INVALIDARG, stream.fail(), "Failed to parse timestamp '%hs'", timestamp.c_str());

Expand Down