bzs1118 commented on code in PR #3773:
URL: https://github.com/apache/brpc/pull/3773#discussion_r4729768567
##########
test/brpc_builtin_service_unittest.cpp:
##########
@@ -171,6 +171,40 @@ void CheckTraceId(const brpc::Controller& cntl,
ASSERT_TRUE(pos != std::string::npos) << expect_str;
}
+void CheckCreatedTimeNearNow(const brpc::Controller& cntl) {
+ const std::string& content = cntl.response_attachment().to_string();
+ const std::size_t header = content.find("CreatedTime");
+ ASSERT_NE(std::string::npos, header) << content;
+ const std::size_t header_end = content.find('\n', header);
+ ASSERT_NE(std::string::npos, header_end) << content;
+ const std::size_t col_end = content.find('|', header_end);
+ ASSERT_NE(std::string::npos, col_end) << content;
+ const std::string created =
+ content.substr(header_end + 1, col_end - header_end - 1);
+ int year = 0, month = 0, day = 0;
+ int hour = 0, minute = 0, second = 0, usec = 0;
+ ASSERT_EQ(7, sscanf(created.c_str(), "%d/%d/%d-%d:%d:%d.%d",
+ &year, &month, &day, &hour, &minute, &second, &usec))
+ << "created=" << created;
+
+ struct tm tm_val;
+ memset(&tm_val, 0, sizeof(tm_val));
+ tm_val.tm_year = year - 1900;
+ tm_val.tm_mon = month - 1;
+ tm_val.tm_mday = day;
+ tm_val.tm_hour = hour;
+ tm_val.tm_min = minute;
+ tm_val.tm_sec = second;
+ tm_val.tm_isdst = -1;
+ const time_t created_s = mktime(&tm_val);
Review Comment:
Fixed by using civil calendar.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]