https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105450
Bug ID: 105450 Summary: get_time %y reads more than 2 digits (and differ from strptime) Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: fsb4000 at yandex dot ru Target Milestone: --- Hi. MattStephanson found that std::get_time with %y differ from strptime. I decided to inform you. https://godbolt.org/z/YaMM5PdnT ```c++ #include <ctime> #include <iomanip> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; void test_get_time(const vector<string>& dates) { for (const auto& date : dates) { tm time{}; istringstream iss{date}; iss >> get_time(&time, "%y"); cout << "get_time: \"" << date << "\"; 1900 + time.tm_year: " << 1900 + time.tm_year << endl; } } void test_get_year(const vector<string>& dates) { const auto& f = use_facet<time_get<char>>(locale{}); for (const auto& date : dates) { tm time{}; ios_base::iostate err = ios_base::goodbit; istringstream iss{date}; f.get_year({iss}, {}, iss, err, &time); cout << "get_year: \"" << date << "\"; 1900 + time.tm_year: " << 1900 + time.tm_year << endl; } } void test_strptime(const vector<string>& dates) { for (const auto& date : dates) { tm time{}; strptime(date.c_str(), "%y", &time); cout << "strptime: \"" << date << "\"; 1900 + time.tm_year: " << 1900 + time.tm_year << endl; } } int main() { vector<string> dates = {"1"s, "01"s, "85"s, "085"s, "111"s}; test_get_time(dates); cout << '\n'; test_get_year(dates); cout << '\n'; test_strptime(dates); } ``` This code prints: get_time: "085"; 1900 + time.tm_year: 85 get_time: "111"; 1900 + time.tm_year: 111 and strptime: "085"; 1900 + time.tm_year: 2008 strptime: "111"; 1900 + time.tm_year: 2011