Namespaces
Variants

std:: time_get

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

class CharT,
class InputIt = std:: istreambuf_iterator < CharT >

> class time_get ;

클래스 템플릿 std::time_get 는 날짜와 시간 파싱 규칙을 캡슐화합니다. I/O 조정자 std::get_time 은 I/O 스트림의 로캘에 있는 std::time_get 패싯을 사용하여 텍스트 입력을 std::tm 객체로 변환합니다.

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

상속 다이어그램

표준 라이브러리에서 보장되지 않는 std::time_get 특수화가 있는 경우(아래 참조), 해당 멤버 함수들의 동작(생성자와 소멸자 제외)은 명시된 대로 보장되지 않습니다.

목차

특수화

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

헤더 파일에 정의됨 <locale>
std :: time_get < char > 날짜와 시간의 narrow 문자열 표현을 파싱함
std :: time_get < wchar_t > 날짜와 시간의 wide 문자열 표현을 파싱함

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

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

중첩 타입

유형 정의
char_type CharT
iter_type InputIt

데이터 멤버

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

멤버 함수

새로운 time_get 패싯을 생성함
(public 멤버 함수)
time_get 패싯을 소멸시킴
(protected 멤버 함수)
do_date_order 를 호출함
(public 멤버 함수)
do_get_time 를 호출함
(public 멤버 함수)
do_get_date 를 호출함
(public 멤버 함수)
do_get_weekday 를 호출함
(public 멤버 함수)
do_get_monthname 를 호출함
(public 멤버 함수)
do_get_year 를 호출함
(public 멤버 함수)
(C++11)
do_get 를 호출함
(public 멤버 함수)

보호된 멤버 함수

[virtual]
일, 월, 연도의 선호되는 순서를 획득함
(가상 protected 멤버 함수)
[virtual]
입력 스트림에서 시, 분, 초를 추출함
(가상 protected 멤버 함수)
[virtual]
입력 스트림에서 월, 일, 연도를 추출함
(가상 protected 멤버 함수)
입력 스트림에서 요일 이름을 추출함
(가상 protected 멤버 함수)
입력 스트림에서 월 이름을 추출함
(가상 protected 멤버 함수)
[virtual]
입력 스트림에서 연도를 추출함
(가상 protected 멤버 함수)
[virtual] (C++11)
지정된 형식에 따라 입력 스트림에서 날짜/시간 구성 요소를 추출함
(가상 protected 멤버 함수)

std:: time_base 로부터 상속됨

중첩 타입

타입 정의
dateorder 날짜 순서 열거형 타입으로, no_order , dmy , mdy , ymd , ydm 값을 정의함

예제

참고: 출력을 확인하려면 clang을 선택하세요. libstdc++는 %b 지정자를 올바르게 구현하지 않습니다: bug 78714 .

#include <iomanip>
#include <iostream>
#include <locale>
#include <sstream>
int main()
{
    std::tm t = {};
    std::istringstream ss("2011-Februar-18 23:12:34");
    ss.imbue(std::locale("de_DE.utf-8"));
    ss >> std::get_time(&t, "%Y-%b-%d %H:%M:%S");
    if (ss.fail())
        std::cout << "Parse failed\n";
    else
        std::cout << std::put_time(&t, "%c") << '\n';
}

가능한 출력:

Sun Feb 18 23:12:34 2011

참고 항목

std::tm 의 내용을 문자 시퀀스로 출력하기 위해 형식화
(클래스 템플릿)
(C++11)
지정된 형식의 날짜/시간 값을 파싱
(함수 템플릿)