名前空間
変種
操作

std::get_time

提供: cppreference.com
< cpp‎ | io‎ | manip

 
 
入力/出力ライブラリ
I / Oのマニピュレータ
CスタイルのI / O
バッファ
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf(廃止予定)
ストリーム
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
抽象化
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
ファイルI / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
文字列I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
アレイのI / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream(廃止予定)
ostrstream(廃止予定)
strstream(廃止予定)
タイプ
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
エラーカテゴリインターフェース
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category(C++11)
io_errc(C++11)
 
入力/出力マニピュレータ
浮動小数点の書式
Original:
Floating-point formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
整数フォーマット
Original:
Integer formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ブールの書式
Original:
Boolean formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
boolalpha
noboolalpha
フィールド幅と塗りつぶしコントロール
Original:
Field width and fill control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
その他の書式
Original:
Other formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
空白処理
Original:
Whitespace processing
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
出力がフラッシュします
Original:
Output flushing
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ステータスフラグ操作
Original:
Status flags manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
時間とお金のI / O
Original:
Time and money I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
get_money(C++11)
get_time(C++11)
put_money(C++11)
put_time(C++11)
 
Defined in header <iomanip>
template< class CharT >
/*unspecified*/ get_time( std::tm* tmb, const CharT* fmt);
(C++11およびそれ以降)
表現in >> get_time(tmb, fmt)で使用する場合は、fmt現在出力ストリームstd::time_getに吹き込まれたロケールのoutファセットに応じて書式文字列に従って日付/時刻値として文字入力を解析します。結果の値はstd::tmによって指さtmbオブジェクトに格納されてい.
Original:
When used in an expression in >> get_time(tmb, fmt), parses the character input as a date/time value according to format string fmt according to the std::time_get facet of the locale currently imbued in the output stream out. The resultant value is stored in a std::tm object pointed to by tmb.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

tmb -
はstd :: tmオブジェクト結果が格納されるへの有効なポインタ
Original:
valid pointer to the std::tm object where the result will be stored
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
fmt -
変換形式を指定するNULLで終わるグラフの文字列へのポインタ
書式文字列は、ゼロ個以上の変換指定子、空白文字と通常文字(%を除く)で構成されています。それぞれの通常の文字は大文字と小文字を区別しない比較で、入力ストリームに1文字に一致すると予測される。各空白文字は入力文字列内の任意の空白文字と一致します。各変換指定は、オプションに続く%文字で始まりEまたはO修飾子(ロケールによってサポートされていない場合は無視されます)、指定の動作を決定します文字が続く。書式指定子は、POSIX関数strptime()に一致します
Original:
The format string consists of zero or more conversion specifiers, whitespace characters, and ordinary characters (except %). Each ordinary character is expected to match one character in the input stream in case-insensitive comparison. Each whitespace character matches arbitrary whitespace in the input string. Each conversion specification begins with % character, optionally followed by E or O modifier (ignored if unsupported by the locale), followed by the character that determines the behavior of the specifier. The format specifiers match the POSIX function strptime():
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversion
specifier
Explanation Writes to fields
% matches a literal %. The full conversion specification must be %%. (none)
t matches any whitespace. (none)
n matches any whitespace. (none)
Year
Y parses full year as a 4 digit decimal number, leading zeroes permitted but not required tm_year
EY parses year in the alternative representation, e.g.平成23年 (year Heisei 23) which writes 2011 to tm_year in ja_JP locale tm_year
y parses last 2 digits of year as a decimal number. Range [69,99] results in values 1969 to 1999, range [00,68] results in 2000-2068 tm_year
Oy parses last 2 digits of year using the alternative numeric system, e.g. 十一 is parsed as 11 in ja_JP locale tm_year
Ey parses year as offset from locale's alternative calendar period %EC tm_year
C parses the first 2 digits of year as a decimal number (range [00,99]) tm_year
EC parses the name of the base year (period) in the locale's alternative representation, e.g. 平成 (Heisei era) in ja_JP tm_year
Month
b parses the month name, either full or abbreviated, e.g. Oct tm_mon
h synonym of b tm_mon
B synonym of b tm_mon
m parses the month as a decimal number (range [01,12]), leading zeroes permitted but not required tm_mon
Om parses the month using the alternative numeric system, e.g. 十二 parses as 12 in ja_JP locale tm_mon
Week
U parses the week of the year as a decimal number (Sunday is the first day of the week) (range [00,53]), leading zeroes permitted but not required tm_year, tm_wday, tm_yday
OU parses the week of the year, as by %U, using the alternative numeric system, e.g. 五十二 parses as 52 in ja_JP locale tm_year, tm_wday, tm_yday
W parses the week of the year as a decimal number (Monday is the first day of the week) (range [00,53]), leading zeroes permitted but not required tm_year, tm_wday, tm_yday
OW parses the week of the year, as by %W, using the alternative numeric system, e.g. 五十二 parses as 52 in ja_JP locale tm_year, tm_wday, tm_yday
Day of the year/month
j parses day of the year as a decimal number (range [001,366]), leading zeroes permitted but not required tm_yday
d parses the day of the month as a decimal number (range [01,31]), leading zeroes permitted but not required tm_mday
Od parses the day of the month using the alternative numeric system, e.g 二十七 parses as 23 in ja_JP locale, leading zeroes permitted but not required tm_mday
e synonym of d tm_mday
Oe synonym of Od tm_mday
Day of the week
a parses the name of the day of the week, either full or abbreviated, e.g. Fri tm_wday
A synonym of a tm_wday
w parses weekday as a decimal number, where Sunday is 0 (range [0-6]) tm_wday
Ow parses weekday as a decimal number, where Sunday is 0, using the alternative numeric system, e.g. 二 parses as 2 in ja_JP locale tm_wday
Hour, minute, second
H parses the hour as a decimal number, 24 hour clock (range [00-23]), leading zeroes permitted but not required tm_hour
OH parses hour from 24-hour clock using the alternative numeric system, e.g. 十八 parses as 18 in ja_JP locale tm_hour
I parses hour as a decimal number, 12 hour clock (range [01,12]), leading zeroes permitted but not required tm_hour
OI parses hour from 12-hour clock using the alternative numeric system, e.g. 六 reads as 06 in ja_JP locale tm_hour
M parses minute as a decimal number (range [00,59]), leading zeroes permitted but not required tm_min
OM parses minute using the alternative numeric system, e.g. 二十五 parses as 25 in ja_JP locale tm_min
S parses second as a decimal number (range [00,60]), leading zeroes permitted but not required tm_sec
OS parses second using the alternative numeric system, e.g. 二十四 parses as 24 in ja_JP locale tm_sec
Other
c parses the locale's standard date and time string format, e.g. Sun Oct 17 04:41:13 2010 (locale dependent) all
Ec parses the locale's alternative date and time string format, e.g. expecting 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale all
x parses the locale's standard date representation all
Ex parses the locale's alternative date representation, e.g. expecting 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale all
X parses the locale's standard time representation all
EX parses the locale's alternative time representation all
D equivalent to "%m / %d / %y " tm_mon, tm_mday, tm_year
r parses locale's standard 12-hour clock time (in POSIX, "%I : %M : %S %p") tm_hour, tm_min, tm_sec
R equivalent to "%H : %M" tm_hour, tm_min
T equivalent to "%H : %M : %S" tm_hour, tm_min, tm_sec
p parses the locale's equivalent of a.m. or p.m. tm_hour
Original:
pointer to a null-terminated CharT string specifying the conversion format
書式文字列は、ゼロ個以上の変換指定子、空白文字と通常文字(%を除く)で構成されています。それぞれの通常の文字は大文字と小文字を区別しない比較で、入力ストリームに1文字に一致すると予測される。各空白文字は入力文字列内の任意の空白文字と一致します。各変換指定は、オプションに続く%文字で始まりEまたはO修飾子(ロケールによってサポートされていない場合は無視されます)、指定の動作を決定します文字が続く。書式指定子は、POSIX関数strptime()に一致します
Original:
The format string consists of zero or more conversion specifiers, whitespace characters, and ordinary characters (except %). Each ordinary character is expected to match one character in the input stream in case-insensitive comparison. Each whitespace character matches arbitrary whitespace in the input string. Each conversion specification begins with % character, optionally followed by E or O modifier (ignored if unsupported by the locale), followed by the character that determines the behavior of the specifier. The format specifiers match the POSIX function strptime():
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversion
specifier
Explanation Writes to fields
% matches a literal %. The full conversion specification must be %%. (none)
t matches any whitespace. (none)
n matches any whitespace. (none)
Year
Y parses full year as a 4 digit decimal number, leading zeroes permitted but not required tm_year
EY parses year in the alternative representation, e.g.平成23年 (year Heisei 23) which writes 2011 to tm_year in ja_JP locale tm_year
y parses last 2 digits of year as a decimal number. Range [69,99] results in values 1969 to 1999, range [00,68] results in 2000-2068 tm_year
Oy parses last 2 digits of year using the alternative numeric system, e.g. 十一 is parsed as 11 in ja_JP locale tm_year
Ey parses year as offset from locale's alternative calendar period %EC tm_year
C parses the first 2 digits of year as a decimal number (range [00,99]) tm_year
EC parses the name of the base year (period) in the locale's alternative representation, e.g. 平成 (Heisei era) in ja_JP tm_year
Month
b parses the month name, either full or abbreviated, e.g. Oct tm_mon
h synonym of b tm_mon
B synonym of b tm_mon
m parses the month as a decimal number (range [01,12]), leading zeroes permitted but not required tm_mon
Om parses the month using the alternative numeric system, e.g. 十二 parses as 12 in ja_JP locale tm_mon
Week
U parses the week of the year as a decimal number (Sunday is the first day of the week) (range [00,53]), leading zeroes permitted but not required tm_year, tm_wday, tm_yday
OU parses the week of the year, as by %U, using the alternative numeric system, e.g. 五十二 parses as 52 in ja_JP locale tm_year, tm_wday, tm_yday
W parses the week of the year as a decimal number (Monday is the first day of the week) (range [00,53]), leading zeroes permitted but not required tm_year, tm_wday, tm_yday
OW parses the week of the year, as by %W, using the alternative numeric system, e.g. 五十二 parses as 52 in ja_JP locale tm_year, tm_wday, tm_yday
Day of the year/month
j parses day of the year as a decimal number (range [001,366]), leading zeroes permitted but not required tm_yday
d parses the day of the month as a decimal number (range [01,31]), leading zeroes permitted but not required tm_mday
Od parses the day of the month using the alternative numeric system, e.g 二十七 parses as 23 in ja_JP locale, leading zeroes permitted but not required tm_mday
e synonym of d tm_mday
Oe synonym of Od tm_mday
Day of the week
a parses the name of the day of the week, either full or abbreviated, e.g. Fri tm_wday
A synonym of a tm_wday
w parses weekday as a decimal number, where Sunday is 0 (range [0-6]) tm_wday
Ow parses weekday as a decimal number, where Sunday is 0, using the alternative numeric system, e.g. 二 parses as 2 in ja_JP locale tm_wday
Hour, minute, second
H parses the hour as a decimal number, 24 hour clock (range [00-23]), leading zeroes permitted but not required tm_hour
OH parses hour from 24-hour clock using the alternative numeric system, e.g. 十八 parses as 18 in ja_JP locale tm_hour
I parses hour as a decimal number, 12 hour clock (range [01,12]), leading zeroes permitted but not required tm_hour
OI parses hour from 12-hour clock using the alternative numeric system, e.g. 六 reads as 06 in ja_JP locale tm_hour
M parses minute as a decimal number (range [00,59]), leading zeroes permitted but not required tm_min
OM parses minute using the alternative numeric system, e.g. 二十五 parses as 25 in ja_JP locale tm_min
S parses second as a decimal number (range [00,60]), leading zeroes permitted but not required tm_sec
OS parses second using the alternative numeric system, e.g. 二十四 parses as 24 in ja_JP locale tm_sec
Other
c parses the locale's standard date and time string format, e.g. Sun Oct 17 04:41:13 2010 (locale dependent) all
Ec parses the locale's alternative date and time string format, e.g. expecting 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale all
x parses the locale's standard date representation all
Ex parses the locale's alternative date representation, e.g. expecting 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale all
X parses the locale's standard time representation all
EX parses the locale's alternative time representation all
D equivalent to "%m / %d / %y " tm_mon, tm_mday, tm_year
r parses locale's standard 12-hour clock time (in POSIX, "%I : %M : %S %p") tm_hour, tm_min, tm_sec
R equivalent to "%H : %M" tm_hour, tm_min
T equivalent to "%H : %M : %S" tm_hour, tm_min, tm_sec
p parses the locale's equivalent of a.m. or p.m. tm_hour
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

inがタイプstd::basic_istream<CharT, Traits>の入力ストリームの名前である場合、次のコードが実行された場合、その式in >> get_time(tmb, fmt)ように振る舞うことなど不特定の型のオブジェクトを返します
Original:
Returns an object of unspecified type such that if in is the name of an input stream of type std::basic_istream<CharT, Traits>, then the expression in >> get_time(tmb, fmt) behaves as if the following code was executed:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

typedef std::istreambuf_iterator<CharT, Traits> Iter;
typedef std::time_get<CharT, Iter> TimeGet;
std::ios_base::iostate err = std::ios_base::goodbit;
const TimeGet& tg = std::use_facet<TimeGet>(in.getloc());
tg.get(Iter(in.rdbuf()), Iter(), in, err, tmb, fmt, fmt + traits::length(fmt));
if (err != std::ios_base::goodbit)
    in.setstate(err):


[編集]

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

Output:

Sun Feb 18 23:12:34 2011

[編集] も参照してください

struct std::tmに入力文字列から時刻/日付の値を解析します
Original:
parses time/date values from an input character sequence into struct std::tm
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(クラステンプレート) [edit]
(C++11)
フォーマットと指定された書式に従って日付/時刻の値を出力します
Original:
formats and outputs a date/time value according to the specified format
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]