std::get_time
Da cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Definido no cabeçalho <iomanip>
|
||
template< class CharT > /*unspecified*/ get_time( std::tm* tmb, const CharT* fmt); |
(desde C++11) | |
Quando usado em um in >> get_time(tmb, fmt) expressão, analisa a entrada de caracteres como um valor de data / hora de acordo com a seqüência de formato
fmt
de acordo com a faceta std::time_get do local atualmente imbuídos no out
fluxo de saída. O valor resultante é armazenado num objecto std::tm apontado 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.
Índice |
[editar] Parâmetros
tmb | - | ponteiro válido para o std :: tm objeto onde o resultado será armazenado
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 | - | ponteiro para uma string terminada em nulo gráfico especificando o formato de conversão
A cadeia de formato consiste de zero ou mais especificadores de conversão, caracteres em branco e caracteres comuns (exceto
% ). Cada personagem comum é esperado para coincidir com um personagem do fluxo de entrada em maiúsculas e minúsculas comparação. Cada personagem espaços corresponde espaços arbitrária na cadeia de entrada. Cada especificação de conversão começa com o personagem % , opcionalmente seguido por E ou O modificador (ignorado se não suportado pelo local), seguido pelo caráter que determina o comportamento do especificador. Os especificadores de formato de corresponder à funçã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.
Original: pointer to a null-terminated CharT string specifying the conversion format
A cadeia de formato consiste de zero ou mais especificadores de conversão, caracteres em branco e caracteres comuns (exceto
% ). Cada personagem comum é esperado para coincidir com um personagem do fluxo de entrada em maiúsculas e minúsculas comparação. Cada personagem espaços corresponde espaços arbitrária na cadeia de entrada. Cada especificação de conversão começa com o personagem % , opcionalmente seguido por E ou O modificador (ignorado se não suportado pelo local), seguido pelo caráter que determina o comportamento do especificador. Os especificadores de formato de corresponder à funçã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.
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
Devolve um objecto de tipo não especificado de tal forma que se
in
é o nome de um fluxo de entrada de std::basic_istream<CharT, Traits> tipo, então a expressão in >> get_time(tmb, fmt) se comporta como se o seguinte código foi executado: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.
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):
[editar] Exemplo
#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'; }
Saída:
Sun Feb 18 23:12:34 2011
[editar] Veja também
analisa hora / data valores de uma sequência de caracteres de entrada em 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. (modelo de classe) | |
(C++11) |
formatos e saídas de um valor de data / hora de acordo com o 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. (modelo de função) |