A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../error/error_code/../../../cpp/chrono/c/asctime.html below:

std::asctime - cppreference.com

char* asctime( const std::tm* time_ptr );

Converts given calendar time std::tm to a textual representation of the following fixed 25-character form: Www Mmm dd hh:mm:ss yyyy\n.

The behavior is undefined if any member of *time_ptr is outside its normal range.

The behavior is undefined if the calendar year indicated by time_ptr->tm_year has more than 4 digits or is less than the year 1000.

The function does not support localization, and the newline character cannot be removed.

The function modifies static storage and is not thread-safe.

[edit] Parameters time_ptr - pointer to a std::tm object specifying the time to print [edit] Return value

Pointer to a static null-terminated character string holding the textual representation of date and time. The string may be shared between std::asctime and std::ctime, and may be overwritten on each invocation of any of those functions.

[edit] Notes

This function returns a pointer to static data and is not thread-safe. POSIX marks this function obsolete and recommends locale-dependent std::strftime instead. In std::locale("C") the std::strftime format string "%c\n" will be an exact match to std::asctime output, while in other locales the format string "%a %b %e %H:%M:%S %Y\n" will be a potentially closer but not always exact match.

POSIX limits undefined behaviors only to the cases when the output string would be longer than 25 characters, when timeptr->tm_wday or timeptr->tm_mon are not within the expected ranges, or when timeptr->tm_year exceeds INT_MAX-1990.

Some implementations handle timeptr->tm_mday == 0 as meaning the last day of the preceding month.

[edit] Example

Possible output:

locale C:
    asctime                             Wed Nov  4 00:45:01 2020
    strftime %c                         Wed Nov  4 00:45:01 2020
    strftime %a %b %e %H:%M:%S %Y       Wed Nov  4 00:45:01 2020
 
locale en_US.utf8:
    asctime                             Wed Nov  4 00:45:01 2020
    strftime %c                         Wed 04 Nov 2020 12:45:01 AM UTC
    strftime %a %b %e %H:%M:%S %Y       Wed Nov  4 00:45:01 2020
 
locale de_DE.utf8:
    asctime                             Wed Nov  4 00:45:01 2020
    strftime %c                         Mi 04 Nov 2020 00:45:01 UTC
    strftime %a %b %e %H:%M:%S %Y       Mi Nov  4 00:45:01 2020
 
locale ja_JP.utf8:
    asctime                             Wed Nov  4 00:45:01 2020
    strftime %c                         2020å¹´11月04日 00時45分01秒
    strftime %a %b %e %H:%M:%S %Y       æ°´ 11月  4 00:45:01 2020
[edit] See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4