[ Web Proxy ]
URL:
Viewing: https://ko.cppreference.com/cpp/chrono#Time_zone [Back]  [Original]

Date and time utilities - cppreference.com
cppreference.com

Date and time utilities

cppreference.com
< cpp

C++ 2 :

  • chrono , (e.g. std::chrono::time_point).
  • C (e.g. std::time)

std::chrono library

chrono 3 typedef .

  • (clocks)
  • (time points)
  • (durations)

(Clocks)

( 1970 1 1) tick rate . , 1970 1 1 . C++ .:

<chrono> .
Defined in namespace std::chrono
wall clock time from the system-wide realtime clock
(class) [edit]
monotonic clock that will never be adjusted
(class) [edit]
the clock with the shortest tick period available
(class) [edit]
determines if a type is a Clock
(class template) (variable template) [edit]
(C++20)
Clock for Coordinated Universal Time (UTC)
(class) [edit]
(C++20)
Clock for International Atomic Time (TAI)
(class) [edit]
(C++20)
Clock for GPS time
(class) [edit]
Clock used for file time
(typedef) [edit]
(C++20)
pseudo-clock representing local time
(class) [edit]

(Time point)

(time point) .

<chrono> .
Defined in namespace std::chrono
a point in time
(class template) [edit]
traits class defining how to convert time points of one clock to another
(class template) [edit]
convert time points of one clock to another
(function template) [edit]

(Duration)

(duration) tick . , "42" 1 42 tick .

<chrono> .
Defined in namespace std::chrono
(C++11)
a time interval
(class template) [edit]

Time of day

hh_mm_ss ,,, . .

<chrono> .
Defined in namespace std::chrono
(C++20)
represents a time of day
(class template) [edit]
translates between a 12h/24h format time of day
(function) [edit]

(Calendar)

<chrono> .
Defined in namespace std::chrono
(C++20)
tag class indicating the last day or weekday in a month
(class) [edit]
(C++20)
represents a day of a month
(class) [edit]
(C++20)
represents a month of a year
(class) [edit]
(C++20)
represents a year in the Gregorian calendar
(class) [edit]
(C++20)
represents a day of the week in the Gregorian calendar
(class) [edit]
represents the n-th weekday of a month
(class) [edit]
represents the last weekday of a month
(class) [edit]
(C++20)
represents a specific day of a specific month
(class) [edit]
represents the last day of a specific month
(class) [edit]
represents the n-th weekday of a specific month
(class) [edit]
represents the last weekday of a specific month
(class) [edit]
represents a specific month of a specific year
(class) [edit]
represents a specific year, month, and day
(class) [edit]
represents the last day of a specific year and month
(class) [edit]
represents the n-th weekday of a specific year and month
(class) [edit]
represents the last weekday of a specific year and month
(class) [edit]
(C++20)
conventional syntax for Gregorian calendar date creation
(function) [edit]

(Time zone)

<chrono> .
Defined in namespace std::chrono
(C++20)
describes a copy of the IANA time zone database
(class) [edit]
(C++20)
represents a linked list of tzdb
(class) [edit]
accesses and controls the global time zone database information
(function) [edit]
locates a time_zone based on its name
(function) [edit]
returns the current time_zone
(function) [edit]
(C++20)
represents a time zone
(class) [edit]
(C++20)
represents information about a time zone at a particular time point
(class) [edit]
represents information about a local time to UNIX time conversion
(class) [edit]
(C++20)
selects how an ambiguous local time should be resolved
(enum) [edit]
traits class for time zone pointers used by zoned_time
(class template) [edit]
represents a time zone and a time point
(class) [edit]
contains information about a leap second insertion
(class) [edit]
leap second insertion information
(class) [edit]
obtains leap second insertion information from a utc_time object
(function template) [edit]
represents an alternative name for a time zone
(class) [edit]
exception thrown to report that a local time is nonexistent
(class) [edit]
exception thrown to report that a local time is ambiguous
(class) [edit]

chrono I/O

<chrono> .
Defined in namespace std::chrono
(C++20)
parses a chrono object from a stream
(function template) [edit]

C-style date and time library

std::time_t, std::difftime, CLOCKS_PER_SEC C .


:

#include <iostream>
#include <chrono>
 
long fibonacci(unsigned n)
{
    if (n < 2) return n;
    return fibonacci(n-1) + fibonacci(n-2);
}
 
int main()
{
    auto start = std::chrono::steady_clock::now();
    std::cout << "f(42) = " << fibonacci(42) << '\n';
    auto end = std::chrono::steady_clock::now();
    std::chrono::duration<double> elapsed_seconds = end-start;
    std::cout << "elapsed time: " << elapsed_seconds.count() << "s\n";
}

Possible output:

f(42) = 267914296
elapsed time: 1.88232s

Web Proxy Viewer  |  New URL  |  Original Page