Namespaces
Variants

std:: time_put

From cppreference.net
헤더에 정의됨 <locale>
template <

class CharT,
class OutputIt = std:: ostreambuf_iterator < CharT >

> class time_put ;

클래스 템플릿 std::time_put 는 날짜와 시간 형식화 규칙을 캡슐화합니다. I/O 조정자 std::put_time 는 I/O 스트림의 로캘에 있는 std::time_put 패싯을 사용하여 std::tm 객체의 텍스트 표현을 생성합니다.

cpp/locale/time base cpp/locale/locale/facet std-time put-inheritance.svg

상속 다이어그램

만약 std::time_put 특수화가 표준 라이브러리에서 보장되지 않는 경우(아래 참조), 해당 put() do_put() 함수의 동작은 명세된 대로 보장되지 않습니다.

목차

특수화

표준 라이브러리는 다음과 같은 특수화를 제공함을 보장합니다 (이들은 모든 locale 객체에 의해 구현되어야 합니다 ):

헤더 파일에 정의됨 <locale>
std :: time_put < char > 날짜와 시간의 좁은 문자열 표현을 생성함
std :: time_put < wchar_t > 날짜와 시간의 넓은 문자열 표현을 생성함

또한, 표준 라이브러리는 다음 타입 요구사항을 충족하는 모든 특수화를 제공하는 것도 보장됩니다:

  • CharT char wchar_t 중 하나이며,
  • OutputIt LegacyOutputIterator 요구사항을 충족해야 합니다.

중첩 타입

타입 정의
char_type CharT
iter_type OutputIt

데이터 멤버

멤버 설명
std::locale::id id [static] facet 의 식별자

멤버 함수

새로운 time_put 패싯을 생성함
(public member function)
time_put 패싯을 파괴함
(protected member function)
do_put 을 호출함
(public member function)

보호된 멤버 함수

[virtual]
날짜/시간을 형식화하고 출력 스트림에 기록
(가상 protected 멤버 함수)

예제

#include <codecvt>
#include <ctime>
#include <iomanip>
#include <iostream>
int main()
{
    std::time_t t = std::time(nullptr);
    std::wbuffer_convert<std::codecvt_utf8<wchar_t>> conv(std::cout.rdbuf());
    std::wostream out(&conv);
    out.imbue(std::locale("ja_JP.utf8"));
    // this I/O manipulator std::put_time uses std::time_put<wchar_t>
    out << std::put_time(std::localtime(&t), L"%A %c") << '\n';
}

출력:

水曜日 2011年11月09日 12時32分05秒

참고 항목

지정된 로케일에 대한 시스템 제공 std::time_put 을 나타냄
(클래스 템플릿)
입력 문자 시퀀스로부터 시간/날짜 값을 std::tm 으로 파싱함
(클래스 템플릿)
(C++11)
지정된 형식에 따라 날짜/시간 값을 형식화하고 출력함
(함수 템플릿)