📄 _time_facets.c
字号:
case 'j': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_yday, __STATIC_CAST(_Ch*, 0)); if (!__pr) return __format; break; } case 'm': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_mon, __STATIC_CAST(_Ch*, 0)); --__t->tm_mon; if (!__pr || __t->tm_mon < 0 || __t->tm_mon > 11) { __err |= ios_base::failbit; return __format; } break; } case 'M': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_min, __STATIC_CAST(_Ch*, 0)); if (!__pr) return __format; break; } case 'p': { const string* __pr = __match(__first, __last, __table._M_am_pm + 0, __table._M_am_pm + 2, __ct); if (__pr == __table._M_am_pm + 2) return __format; // 12:00 PM <=> 12:00, 12:00 AM <=> 00:00 if (__pr == __table._M_am_pm + 1 && __t->tm_hour != 12 ) __t->tm_hour += 12; if (__pr == __table._M_am_pm && __t->tm_hour == 12 ) __t->tm_hour = 0; break; } case 'S': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_sec, __STATIC_CAST(_Ch*, 0)); if (!__pr) return __format; break; } case 'y': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_year, __STATIC_CAST(_Ch*, 0)); if (!__pr) return __format; break; } case 'Y': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_year, __STATIC_CAST(_Ch*, 0)); __t->tm_year -= 1900; if (!__pr) return __format; break; } default: break; } } else { if (*__first++ != __ct.widen(*__format)) break; } ++__format; } return __format;}template <class _InIt, class _CharT>bool _STLP_CALL__get_short_or_long_dayname(_InIt& __first, _InIt& __last, const ctype<_CharT>& __ct, const _Time_Info& __table, tm* __t) { const string* __pr = __match(__first, __last, __table._M_dayname + 0, __table._M_dayname + 14, __ct); __t->tm_wday = __STATIC_CAST(int, (__pr - __table._M_dayname) % 7); return __pr != __table._M_dayname + 14;}template <class _InIt, class _CharT>bool _STLP_CALL__get_short_or_long_monthname(_InIt& __first, _InIt& __last, const ctype<_CharT>& __ct, const _Time_Info& __table, tm* __t) { const string* __pr = __match(__first, __last, __table._M_monthname + 0, __table._M_monthname + 24, __ct); __t->tm_mon = __STATIC_CAST(int, (__pr - __table._M_monthname) % 12); return __pr != __table._M_monthname + 24;}#if !defined (_STLP_NO_WCHAR_T)template <class _OuIt>_OuIt _STLP_CALL__put_time(char * __first, char * __last, _OuIt __out_ite, const ios_base& __s, wchar_t) { const ctype<wchar_t>& __ct = *__STATIC_CAST(const ctype<wchar_t>*, __s._M_ctype_facet()); wchar_t __wbuf[64]; __ct.widen(__first, __last, __wbuf); ptrdiff_t __len = __last - __first; wchar_t * __eend = __wbuf + __len; return copy((wchar_t*)__wbuf, __eend, __out_ite);}#endif_STLP_MOVE_TO_STD_NAMESPACEtemplate <class _Ch, class _InIt>_InIttime_get<_Ch, _InIt>::do_get_date(_InIt __s, _InIt __end, ios_base& __str, ios_base::iostate& __err, tm* __t) const { typedef string::const_iterator string_iterator; string_iterator __format = _M_timeinfo._M_date_format.begin(); string_iterator __format_end = _M_timeinfo._M_date_format.end(); string_iterator __result = _STLP_PRIV __get_formatted_time(__s, __end, __format, __format_end, __STATIC_CAST(_Ch*, 0), _M_timeinfo, __str, __err, __t); if (__result == __format_end) __err = ios_base::goodbit; else { __err = ios_base::failbit; if (__s == __end) __err |= ios_base::eofbit; } return __s;}template <class _Ch, class _InIt>_InIttime_get<_Ch, _InIt>::do_get_time(_InIt __s, _InIt __end, ios_base& __str, ios_base::iostate& __err, tm* __t) const { typedef string::const_iterator string_iterator; string_iterator __format = _M_timeinfo._M_time_format.begin(); string_iterator __format_end = _M_timeinfo._M_time_format.end(); string_iterator __result = _STLP_PRIV __get_formatted_time(__s, __end, __format, __format_end, __STATIC_CAST(_Ch*, 0), _M_timeinfo, __str, __err, __t); __err = __result == __format_end ? ios_base::goodbit : ios_base::failbit; if (__s == __end) __err |= ios_base::eofbit; return __s;}template <class _Ch, class _InIt>_InIttime_get<_Ch, _InIt>::do_get_year(_InIt __s, _InIt __end, ios_base&, ios_base::iostate& __err, tm* __t) const { if (__s == __end) { __err = ios_base::failbit | ios_base::eofbit; return __s; } bool __pr = _STLP_PRIV __get_decimal_integer(__s, __end, __t->tm_year, __STATIC_CAST(_Ch*, 0)); __t->tm_year -= 1900; __err = __pr ? ios_base::goodbit : ios_base::failbit; if (__s == __end) __err |= ios_base::eofbit; return __s;}template <class _Ch, class _InIt>_InIttime_get<_Ch, _InIt>::do_get_weekday(_InIt __s, _InIt __end, ios_base &__str, ios_base::iostate &__err, tm *__t) const { const ctype<_Ch>& __ct = *__STATIC_CAST(const ctype<_Ch>*, __str._M_ctype_facet()); bool __result = _STLP_PRIV __get_short_or_long_dayname(__s, __end, __ct, _M_timeinfo, __t); if (__result) __err = ios_base::goodbit; else { __err = ios_base::failbit; if (__s == __end) __err |= ios_base::eofbit; } return __s;}template <class _Ch, class _InIt>_InIttime_get<_Ch, _InIt>::do_get_monthname(_InIt __s, _InIt __end, ios_base &__str, ios_base::iostate &__err, tm *__t) const { const ctype<_Ch>& __ct = *__STATIC_CAST(const ctype<_Ch>*, __str._M_ctype_facet()); bool __result = _STLP_PRIV __get_short_or_long_monthname(__s, __end, __ct, _M_timeinfo, __t); if (__result) __err = ios_base::goodbit; else { __err = ios_base::failbit; if (__s == __end) __err |= ios_base::eofbit; } return __s;}template<class _Ch, class _OutputIter>_OutputItertime_put<_Ch,_OutputIter>::put(_OutputIter __s, ios_base& __f, _Ch __fill, const tm* __tmb, const _Ch* __pat, const _Ch* __pat_end) const { // locale __loc = __f.getloc(); // const ctype<_Ch>& _Ct = use_facet<ctype<_Ch> >(__loc); const ctype<_Ch>& _Ct = *__STATIC_CAST(const ctype<_Ch>*, __f._M_ctype_facet()); while (__pat != __pat_end) { char __c = _Ct.narrow(*__pat, 0); if (__c == '%') { char __mod = 0; ++__pat; __c = _Ct.narrow(*__pat++, 0); if (__c == '#') { // MS extension __mod = __c; __c = _Ct.narrow(*__pat++, 0); } __s = do_put(__s, __f, __fill, __tmb, __c, __mod); } else *__s++ = *__pat++; } return __s;}template<class _Ch, class _OutputIter>_OutputItertime_put<_Ch,_OutputIter>::do_put(_OutputIter __s, ios_base& __f, _Ch /* __fill */, const tm* __tmb, char __format, char __modifier ) const { char __buf[64]; char * __iend = _STLP_PRIV __write_formatted_time(_STLP_ARRAY_AND_SIZE(__buf), __format, __modifier, _M_timeinfo, __tmb); // locale __loc = __f.getloc(); return _STLP_PRIV __put_time(__buf, __iend, __s, __f, _Ch());}_STLP_END_NAMESPACE#endif /* _STLP_TIME_FACETS_C */// Local Variables:// mode:C++// End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -