std::get_time
De cppreference.com
![]() | Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate. La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
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.
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.
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.
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.
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
Ejecuta este código
#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) | |
(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) |