|
7 | 7 | #endif
|
8 | 8 |
|
9 | 9 | #include <chrono>
|
10 |
| -#include <string> |
11 | 10 | #include <format>
|
| 11 | +#include <string> |
12 | 12 |
|
13 | 13 | MAA_NS_BEGIN
|
14 | 14 |
|
15 | 15 | inline std::string format_now()
|
16 | 16 | {
|
17 | 17 | #ifndef __APPLE__ // Now Apple's compiler cannot build std::chrono::format. 2023/07/21
|
18 | 18 | return std::format("{}", std::chrono::current_zone()->to_local(
|
19 |
| - std::chrono::floor<std::chrono::milliseconds>(std::chrono::system_clock::now()))); |
| 19 | + std::chrono::floor<std::chrono::milliseconds>(std::chrono::system_clock::now()))); |
20 | 20 | #else
|
21 | 21 | timeval tv = {};
|
22 | 22 | gettimeofday(&tv, nullptr);
|
23 | 23 | time_t nowtime = tv.tv_sec;
|
24 | 24 | tm* tm_info = localtime(&nowtime);
|
25 | 25 | return std::format("{:0>4}-{:0>2}-{:0>2} {:0>2}:{:0>2}:{:0>2}.{:0>3}", tm_info->tm_year + 1900, tm_info->tm_mon,
|
26 |
| - tm_info->tm_mday, tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, tv.tv_usec / 1000); |
| 26 | + tm_info->tm_mday, tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, tv.tv_usec / 1000); |
27 | 27 | #endif
|
28 | 28 | }
|
29 | 29 |
|
30 | 30 | inline std::string format_now_for_filename()
|
31 | 31 | {
|
32 | 32 | #ifndef __APPLE__ // Now Apple's compiler cannot build std::chrono::format. 2023/07/21
|
33 |
| - return std::format("{:%Y.%m.%d-%H.%M.%S}", |
34 |
| - std::chrono::current_zone()->to_local(std::chrono::system_clock::now())); |
| 33 | + return std::format("{:%Y.%m.%d-%H.%M.%S}", std::chrono::current_zone()->to_local(std::chrono::system_clock::now())); |
35 | 34 | #else
|
36 | 35 | timeval tv = {};
|
37 | 36 | gettimeofday(&tv, nullptr);
|
38 | 37 | time_t nowtime = tv.tv_sec;
|
39 | 38 | tm* tm_info = localtime(&nowtime);
|
40 | 39 | return std::format("{:0>4}.{:0>2}.{:0>2}-{:0>2}.{:0>2}.{:0>2}.{}", tm_info->tm_year + 1900, tm_info->tm_mon,
|
41 |
| - tm_info->tm_mday, tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, tv.tv_usec); |
| 40 | + tm_info->tm_mday, tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, tv.tv_usec); |
42 | 41 | #endif
|
43 | 42 | }
|
44 | 43 |
|
|
0 commit comments