@@ -12,17 +12,25 @@ using namespace std;
1212using namespace web ;
1313using namespace websocketpp ;
1414
15+ utility::string_t convert_str (std::string s) {
16+ #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
17+ return utility::conversions::utf8_to_utf16 (s);
18+ #else
19+ return s;
20+ #endif
21+ }
22+
1523utility::string_t get_timestamp () {
16- time_t t = time (NULL );
17- utility::char_t tmp[32 ];
18- strftime ((char *)tmp, sizeof (tmp), " %Y-%m-%d %H:%M:%S" , localtime (&t));
19- return utility::string_t (tmp);
20- // struct tm tm;
2124// time_t t = time(NULL);
22- // gmtime_r(&t, &tm);
23- // char timestamp[32];
24- // strftime(timestamp, sizeof(timestamp), U("%Y-%m-%d %H:%M:%S"), &tm);
25- // return utility::string_t(timestamp);
25+ // utility::char_t tmp[32];
26+ // strftime((char*)tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", localtime(&t));
27+ // return utility::string_t(tmp);
28+ auto now = std::chrono::system_clock::now ();
29+ auto in_time_t = std::chrono::system_clock::to_time_t (now);
30+ std::stringstream ss;
31+ ss << std::put_time (std::localtime (&in_time_t ), " %Y-%m-%d %H:%M:%S" );
32+ std::string result = ss.str ();
33+ return convert_str (result);
2634}
2735
2836time_t date_string_to_timestamp (const utility::string_t &date_string) {
0 commit comments