std::mktime
Материал из 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. |
| Заголовочный файл <ctime>
|
||
| std::time_t mktime( std::tm* time ); |
||
Преобразует местному времени календаре время с эпохой, как std::time_t объект, игнорируя значения
time->tm_wday и time->yday. Значения других компонентов time не ограничивается их обычных диапазонов. Отрицательное значение time->tm_isdst вызывает mktime, чтобы попытаться определить, является ли переход на летнее время был в силе.Original:
Converts local calendar time to a time since epoch as a std::time_t object, ignoring the values of
time->tm_wday and time->yday. The values of other components of time are not restricted to their usual ranges. A negative value of time->tm_isdst causes mktime to attempt to determine if Daylight Saving Time was in effect.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.
В случае успеха, пересчитывает и обновляет все поля в
time, чтобы соответствовать их надлежащего диапазона.Original:
If successful, recalculates and updates all fields in
time to fit their proper ranges.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.
Содержание |
[править] Параметры
| time | - | указатель на объект std::tm указанием местного времени календаре, чтобы преобразовать
Original: pointer to a std::tm object specifying local calendar time to convert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[править] Возвращаемое значение
Время после эпохи, как std::time_t объекта на успех или -1 если
time не может быть представлена в виде std::time_t объект.Original:
Time since epoch as a std::time_t object on success or -1 if
time cannot be represented as a std::time_t object.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.
[править] Пример
Отображение времени 100 месяцев назад
Original:
Display the time 100 months ago
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.
#include <iostream> #include <iomanip> #include <ctime> int main() { std::time_t t = std::time(NULL); std::tm tm = *std::localtime(&t); std::cout << "Today is " << std::put_time(&tm, "%c %Z") <<'\n'; tm.tm_mon -= 100; std::mktime(&tm); std::cout << "100 months ago was " << std::put_time(&tm, "%c %Z") << '\n'; }
Вывод:
Today is Wed Dec 28 09:56:10 2011 EST 100 months ago was Thu Aug 28 10:56:10 2003 EDT
[править] См. также
| преобразует времен эпохи к календарному времени выражается по местному времени Original: converts time since epoch to calendar time expressed as local time The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (функция) | |
| C документация для mktime
| |