Espacios de nombres
Variantes
Acciones

std::get_time

De cppreference.com
< cpp‎ | io‎ | manip
 
 
 
Manipuladores de E/S
Formateo de punto flotante
Formateo de enteros
Formateo de booleanos
Control de ancho de campo y relleno
Otro formateo
Procesamiento de espacio en blanco
Vaciado de salida
Manipulación de indicadores de estado
E/S de tiempo y dinero
(C++11)
get_time
(C++11)
(C++11)
(C++11)
Manipulación entre comillas
(C++14)
 
Definido en el archivo de encabezado <iomanip>
template<class CharT >
/*unspecified*/ get_time(std::tm* tmb, const CharT* fmt);
(desde C++11)
Cuando se utiliza en una expresión in >> get_time(tmb, fmt), analiza la entrada de caracteres como un valor de fecha / hora según la cadena de formato fmt de acuerdo con la faceta std::time_get de la configuración regional seleccionada imbuido en la out flujo de salida. El valor resultante se almacena en un objeto std::tm apuntado por 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.

Contenido

[editar]Parámetros

tmb -
puntero válido para el objeto std :: tm en la que se almacenará el resultado
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 -
puntero a una cadena terminada en cero la gráfica que especifica el formato de conversión
La cadena de formato se compone de cero o más especificadores de conversión, los espacios en blanco y caracteres ordinarios (excepto %). Cada carácter ordinario se espera que coincida con un carácter en el flujo de entrada en mayúsculas y minúsculas comparación. Cada espacio en blanco espacio en blanco coincide arbitrario en la cadena de entrada. Cada especificación de conversión comienza con carácter %, seguido opcionalmente por E o modificador O (se ignora si no soportado por el entorno local), seguido por el carácter que determina el comportamiento del especificador. Los especificadores de formato que coincida con la función 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 %ECtm_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. Octtm_mon
h synonym of btm_mon
B synonym of btm_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 dtm_mday
Oe synonym of Odtm_mday
Day of the week
a parses the name of the day of the week, either full or abbreviated, e.g. Fritm_wday
A synonym of atm_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
La cadena de formato se compone de cero o más especificadores de conversión, los espacios en blanco y caracteres ordinarios (excepto %). Cada carácter ordinario se espera que coincida con un carácter en el flujo de entrada en mayúsculas y minúsculas comparación. Cada espacio en blanco espacio en blanco coincide arbitrario en la cadena de entrada. Cada especificación de conversión comienza con carácter %, seguido opcionalmente por E o modificador O (se ignora si no soportado por el entorno local), seguido por el carácter que determina el comportamiento del especificador. Los especificadores de formato que coincida con la función 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 %ECtm_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. Octtm_mon
h synonym of btm_mon
B synonym of btm_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 dtm_mday
Oe synonym of Odtm_mday
Day of the week
a parses the name of the day of the week, either full or abbreviated, e.g. Fritm_wday
A synonym of atm_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.

[editar]Valor de retorno

Devuelve un objeto de tipo no especificado de tal manera que si in es el nombre de un flujo de entrada de std::basic_istream<CharT, Traits> tipo, entonces la expresión in >> get_time(tmb, fmt) comporta como si el código se ha ejecutado:
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.

typedefstd::istreambuf_iterator<CharT, Traits> Iter;
typedefstd::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):


[editar]Ejemplo

#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';}

Salida:

Sun Feb 18 23:12:34 2011

[editar]Ver también

Analiza valores de hora y fecha a partir de una secuencia de caracteres y los deposita en structstd::tm.
(plantilla de clase)[editar]
(C++11)
formatos y las salidas un valor de fecha / tiempo de acuerdo con el formato especificado
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.

(plantilla de función)[editar]
close