std::get_time
Da cppreference.com.
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Elemento definito nell'header <iomanip>
|
||
template< class CharT > /*unspecified*/ get_time( std::tm* tmb, const CharT* fmt); |
(dal C++11) | |
Quando viene utilizzato in un in >> get_time(tmb, fmt) espressione, analizza l'input di caratteri come un valore data / ora secondo la stringa di formato
fmt
secondo l'aspetto std::time_get del locale attualmente intriso nel out
flusso di output. Il valore risultante è memorizzata in un oggetto std::tm puntato da 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.
Indice |
[modifica] Parametri
tmb | - | puntatore valido alla std :: oggetto tm in cui il risultato viene memorizzato
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 | - | puntatore ad una stringa con terminazione null alla tabella che specifica il formato di conversione
La stringa di formato è composto da zero o più identificatori di conversione, gli spazi vuoti e caratteri comuni (ad eccezione
% ). Ogni carattere ordinario dovrebbe corrispondere un carattere nel flusso di input in case-insensitive confronto. Ogni carattere di spaziatura corrisponde arbitrario spazi nella stringa di input. Ogni specifica di conversione inizia con il carattere % , eventualmente seguita da E o modificatore O (ignorato se non supportato dal locale), seguito dal carattere che determina il comportamento del committente. Il identificatori di formato corrisponde la funzione 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 stringa di formato è composto da zero o più identificatori di conversione, gli spazi vuoti e caratteri comuni (ad eccezione
% ). Ogni carattere ordinario dovrebbe corrispondere un carattere nel flusso di input in case-insensitive confronto. Ogni carattere di spaziatura corrisponde arbitrario spazi nella stringa di input. Ogni specifica di conversione inizia con il carattere % , eventualmente seguita da E o modificatore O (ignorato se non supportato dal locale), seguito dal carattere che determina il comportamento del committente. Il identificatori di formato corrisponde la funzione 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. |
[modifica] Valore di ritorno
Restituisce un oggetto di tipo tale che, se non specificato
in
è il nome di un flusso di ingresso di tipo std::basic_istream<CharT, Traits>, allora l'espressione in >> get_time(tmb, fmt) comporta come se il codice è stato eseguito il seguente: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):
[modifica] Esempio
#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
[modifica] Vedi anche
analizza ora / data valori da una sequenza di input di caratteri in 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. (classe template) | |
(C++11) |
i formati e le uscite di un valore data / ora secondo il formato specificato 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. (funzione di modello) |