Skip to content

<chrono>: Parsing "00:00:60" as utc_time incorrectly returns 00:00:59.0000000 #2698

@statementreply

Description

@statementreply

Command-line test case

C:\Users\He\source\test>type chronat.cpp
#include <chrono>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>

using namespace std;
using namespace std::chrono;

int main() {
    try {
        utc_clock::time_point t;
        if (istringstream{"2021-08-28 00:00:60"} >> parse("%F %T"s, t)) {
            cout << t << "\n";
        } else {
            cout << "parse failed\n";
        }
    } catch (const exception& e) {
        cout << "error: " << e.what() << "\n";
    }
    return 0;
}
C:\Users\He\source\test>cl /EHsc /W4 /WX /std:c++20 chronat.cpp
用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.32.31328 版
版权所有(C) Microsoft Corporation。保留所有权利。

chronat.cpp
Microsoft (R) Incremental Linker Version 14.32.31328.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:chronat.exe
chronat.obj

C:\Users\He\source\test>.\chronat.exe
2021-08-28 00:00:59.0000000

Expected behavior
Prints either "parse failed" or "2021-08-28 00:00:59.9999999", depending on the design choice.

STL version
Microsoft Visual Studio Community 2022 (64 位) - Preview
版本 17.2.0 Preview 5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingchronoC++20 chronofixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions