std::chrono::time_zone:: to_local
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
|
time_zone::to_local
|
||||
| Nonmember functions | ||||
|
template
<
class
Duration
>
auto
to_local
(
const
std::
chrono
::
sys_time
<
Duration
>
&
tp
)
const
|
(C++20 이후) | |
sys_time
tp
를 이
시간대
에서 해당하는
local_time
으로 변환합니다.
목차 |
매개변수
| tp | - | 변환할 시간 포인트 |
반환값
tp 와 이 시간대와 연관된 local_time .
참고 사항
결과의 정밀도는 최소 std::chrono::seconds 이며, 인수가 더 세밀한 정밀도를 가질 경우 더 세밀해집니다.
예제
#include <chrono> #include <iostream> int main() { const auto some_zone_name{"Australia/Sydney"}; const auto time_pt_utc{std::chrono::system_clock::now()}; std::cout << "Current time UTC is:\t\t " << time_pt_utc << '\n'; try { std::cout << "Current time local is:\t\t " << std::chrono::current_zone()-> // may throw to_local(time_pt_utc) << '\n' << "Current time " << some_zone_name << " is:\t " << std::chrono::locate_zone(some_zone_name)-> // may throw to_local(time_pt_utc) << '\n'; } catch(const std::runtime_error& ex) { std::cout << ex.what() << '\n'; } }
가능한 출력:
Current time UTC is: 2025-02-10 13:38:13.233872158 Current time local is: 2025-02-10 16:38:13.233872158 Current time Australia/Sydney is: 2025-02-11 00:38:13.233872158