time_get::get_time

分析字符串作为 strftimex 说明符生成的日期。

iter_type get_time( 
   iter_type _First,  
   iter_type _Last, 
   ios_base& _Iosbase,  
   ios_base::iostate& _State,  
   tm* _Pt 
) const;

参数

  • _First
    输入解决的序列开始的迭代器是转换。

  • _Last
    输入解决序列末尾的迭代器是转换。

  • _Iosbase
    未使用。

  • _State
    设置流状态的相应位掩码元素,可以根据选择的操作成功。

  • _Pt
    指向的指针日期信息中的存储位置。

返回值

输入解决超出范围之外的输入迭代器的第一个元素。

备注

成员函数返回 do_get_time(_First、_Last、_Iosbase、_State,_Pt)。

示例

// time_get_get_time.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
#include <time.h>
using namespace std;
int main( )
{
   locale loc;
   basic_stringstream<char> pszGetF, pszPutF, pszGetI, pszPutI;
   ios_base::iostate st = 0;
   struct tm t;
   memset( &t, 0, sizeof( struct tm ) );

   pszGetF << "11:13:20";
   pszGetF.imbue( loc );
   basic_istream<char>::_Iter i = use_facet 
      <time_get <char> >
      (loc).get_time(basic_istream<char>::_Iter(pszGetF.rdbuf( )),
               basic_istream<char>::_Iter(0), pszGetF, st, &t);

   if (st & ios_base::failbit)
      cout << "time_get::get_time("<< pszGetF.rdbuf( )->str( )<< ") FAILED on char: " << *i << endl;
   else

      cout << "time_get::get_time("<< pszGetF.rdbuf( )->str( )<< ") ="
      << "\ntm_sec: " << t.tm_sec
      << "\ntm_min: " << t.tm_min
      << "\ntm_hour: " << t.tm_hour
      << endl;
}
  

要求

页眉: <区域设置>

命名空间: std

请参见

参考

time_get 类