diff options
Diffstat (limited to 'devdocs/c/chrono%2Fwcsftime.html')
| -rw-r--r-- | devdocs/c/chrono%2Fwcsftime.html | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/devdocs/c/chrono%2Fwcsftime.html b/devdocs/c/chrono%2Fwcsftime.html new file mode 100644 index 00000000..1b020763 --- /dev/null +++ b/devdocs/c/chrono%2Fwcsftime.html @@ -0,0 +1,136 @@ + <h1 id="firstHeading" class="firstHeading">wcsftime</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><wchar.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl"> <td> <pre data-language="c">size_t wcsftime( wchar_t* str, size_t count, const wchar_t* format, tm* time );</pre> +</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c95">(since C95)</span> </td> </tr> </table> <p>Converts the date and time information from a given calendar time <code>time</code> to a null-terminated wide character string <code>str</code> according to <a href="#Format_string">format string</a> <code>format</code>. Up to <code>count</code> bytes are written.</p> +<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> str </td> <td> - </td> <td> pointer to the first element of the wchar_t array for output </td> +</tr> <tr class="t-par"> <td> count </td> <td> - </td> <td> maximum number of wide characters to write </td> +</tr> <tr class="t-par"> <td> format </td> <td> - </td> <td> pointer to a null-terminated wide character string specifying the <a href="#Format_string">format of conversion</a> </td> +</tr> +</table> <h3 id="Format_string"> Format string</h3> <p>The format string consists of zero or more conversion specifiers and ordinary characters (except <code>%</code>). All ordinary characters, including the terminating null character, are copied to the output string without modification. Each conversion specification begins with <code>%</code> character, optionally followed by <code>E</code> or <code>O</code> modifier (ignored if unsupported by the locale), followed by the character that determines the behavior of the specifier. The following format specifiers are available:</p> +<table class="wikitable"> <tr> <th> Conversion<br> specifier </th> <th> Explanation </th> <th> Used fields </th> +</tr> <tr> <th> <code>%</code> </th> <td> writes literal <code>%</code>. The full conversion specification must be <code>%%</code>. </td> <td> </td> +</tr> <tr> <th> <code>n</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes newline character </td> <td> </td> +</tr> <tr> <th> <code>t</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes horizontal tab character </td> <td> </td> +</tr> <tr> <th colspan="3"> Year </th> +</tr> <tr> <th> <code>Y</code> </th> <td> writes <b>year</b> as a decimal number, e.g. 2017 </td> <td> <code>tm_year</code> </td> +</tr> <tr> <th> <code>EY</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>year</b> in the alternative representation, e.g.平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale </td> <td> <code>tm_year</code> </td> +</tr> <tr> <th> <code>y</code> </th> <td> writes last 2 digits of <b>year</b> as a decimal number (range <code>[00,99]</code>) </td> <td> <code>tm_year</code> </td> +</tr> <tr> <th> <code>Oy</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes last 2 digits of <b>year</b> using the alternative numeric system, e.g. 十一 instead of 11 in ja_JP locale </td> <td> <code>tm_year</code> </td> +</tr> <tr> <th> <code>Ey</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>year</b> as offset from locale's alternative calendar period <code>%EC</code> (locale-dependent) </td> <td> <code>tm_year</code> </td> +</tr> <tr> <th> <code>C</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes first 2 digits of <b>year</b> as a decimal number (range <code>[00,99]</code>) </td> <td> <code>tm_year</code> </td> +</tr> <tr> <th> <code>EC</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes name of the <b>base year (period)</b> in the locale's alternative representation, e.g. 平成 (Heisei era) in ja_JP </td> <td> <code>tm_year</code> </td> +</tr> <tr> <th> <code>G</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>ISO 8601 week-based year</b>, i.e. the year that contains the specified week. <p>In ISO 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements:</p> +<ul> +<li> Includes January 4 </li> +<li> Includes first Thursday of the year </li> +</ul> </td> <td> <code>tm_year</code>, <code>tm_wday</code>, <code>tm_yday</code> </td> +</tr> <tr> <th> <code>g</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes last 2 digits of <b>ISO 8601 week-based year</b>, i.e. the year that contains the specified week (range <code>[00,99]</code>). <p>In ISO 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements:</p> +<ul> +<li> Includes January 4 </li> +<li> Includes first Thursday of the year </li> +</ul> </td> <td> <code>tm_year</code>, <code>tm_wday</code>, <code>tm_yday</code> </td> +</tr> <tr> <th colspan="3"> Month </th> +</tr> <tr> <th> <code>b</code> </th> <td> writes <b>abbreviated month</b> name, e.g. <code>Oct</code> (locale dependent) </td> <td> <code>tm_mon</code> </td> +</tr> <tr> <th> <code>Ob</code><br><span class="t-mark-rev t-since-c23">(C23)</span> </th> <td> writes <b>abbreviated month</b> name in the locale's alternative representation </td> <td> <code>tm_mon</code> </td> +</tr> <tr> <th> <code>h</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> synonym of <code>b</code> </td> <td> <code>tm_mon</code> </td> +</tr> <tr> <th> <code>B</code> </th> <td> writes <b>full month</b> name, e.g. <code>October</code> (locale dependent) </td> <td> <code>tm_mon</code> </td> +</tr> <tr> <th> <code>OB</code><br><span class="t-mark-rev t-since-c23">(C23)</span> </th> <td> writes appropriate <b>full month</b> name in the locale's alternative representation </td> <td> <code>tm_mon</code> </td> +</tr> <tr> <th> <code>m</code> </th> <td> writes <b>month</b> as a decimal number (range <code>[01,12]</code>) </td> <td> <code>tm_mon</code> </td> +</tr> <tr> <th> <code>Om</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>month</b> using the alternative numeric system, e.g. 十二 instead of 12 in ja_JP locale </td> <td> <code>tm_mon</code> </td> +</tr> <tr> <th colspan="3"> Week </th> +</tr> <tr> <th> <code>U</code> </th> <td> writes <b>week of the year</b> as a decimal number (Sunday is the first day of the week) (range <code>[00,53]</code>) </td> <td> <code>tm_year</code>, <code>tm_wday</code>, <code>tm_yday</code> </td> +</tr> <tr> <th> <code>OU</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>week of the year</b>, as by <code>%U</code>, using the alternative numeric system, e.g. 五十二 instead of 52 in ja_JP locale </td> <td> <code>tm_year</code>, <code>tm_wday</code>, <code>tm_yday</code> </td> +</tr> <tr> <th> <code>W</code> </th> <td> writes <b>week of the year</b> as a decimal number (Monday is the first day of the week) (range <code>[00,53]</code>) </td> <td> <code>tm_year</code>, <code>tm_wday</code>, <code>tm_yday</code> </td> +</tr> <tr> <th> <code>OW</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>week of the year</b>, as by <code>%W</code>, using the alternative numeric system, e.g. 五十二 instead of 52 in ja_JP locale </td> <td> <code>tm_year</code>, <code>tm_wday</code>, <code>tm_yday</code> </td> +</tr> <tr> <th> <code>V</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>ISO 8601 week of the year</b> (range <code>[01,53]</code>). <p>In ISO 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements:</p> +<ul> +<li> Includes January 4 </li> +<li> Includes first Thursday of the year </li> +</ul> </td> <td> <code>tm_year</code>, <code>tm_wday</code>, <code>tm_yday</code> </td> +</tr> <tr> <th> <code>OV</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>week of the year</b>, as by <code>%V</code>, using the alternative numeric system, e.g. 五十二 instead of 52 in ja_JP locale </td> <td> <code>tm_year</code>, <code>tm_wday</code>, <code>tm_yday</code> </td> +</tr> <tr> <th colspan="3"> Day of the year/month </th> +</tr> <tr> <th> <code>j</code> </th> <td> writes <b>day of the year</b> as a decimal number (range <code>[001,366]</code>) </td> <td> <code>tm_yday</code> </td> +</tr> <tr> <th> <code>d</code> </th> <td> writes <b>day of the month</b> as a decimal number (range <code>[01,31]</code>) </td> <td> <code>tm_mday</code> </td> +</tr> <tr> <th> <code>Od</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes zero-based <b>day of the month</b> using the alternative numeric system, e.g. 二十七 instead of 27 in ja_JP locale <p>Single character is preceded by a space.</p> +</td> <td> <code>tm_mday</code> </td> +</tr> <tr> <th> <code>e</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>day of the month</b> as a decimal number (range <code>[1,31]</code>). <p>Single digit is preceded by a space.</p> +</td> <td> <code>tm_mday</code> </td> +</tr> <tr> <th> <code>Oe</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes one-based <b>day of the month</b> using the alternative numeric system, e.g. 二十七 instead of 27 in ja_JP locale <p>Single character is preceded by a space.</p> +</td> <td> <code>tm_mday</code> </td> +</tr> <tr> <th colspan="3"> Day of the week </th> +</tr> <tr> <th> <code>a</code> </th> <td> writes <b>abbreviated weekday</b> name, e.g. <code>Fri</code> (locale dependent) </td> <td> <code>tm_wday</code> </td> +</tr> <tr> <th> <code>A</code> </th> <td> writes <b>full weekday</b> name, e.g. <code>Friday</code> (locale dependent) </td> <td> <code>tm_wday</code> </td> +</tr> <tr> <th> <code>w</code> </th> <td> writes <b>weekday</b> as a decimal number, where Sunday is <code>0</code> (range <code>[0-6]</code>) </td> <td> <code>tm_wday</code> </td> +</tr> <tr> <th> <code>Ow</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>weekday</b>, where Sunday is <code>0</code>, using the alternative numeric system, e.g. 二 instead of 2 in ja_JP locale </td> <td> <code>tm_wday</code> </td> +</tr> <tr> <th> <code>u</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>weekday</b> as a decimal number, where Monday is <code>1</code> (ISO 8601 format) (range <code>[1-7]</code>) </td> <td> <code>tm_wday</code> </td> +</tr> <tr> <th> <code>Ou</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>weekday</b>, where Monday is <code>1</code>, using the alternative numeric system, e.g. 二 instead of 2 in ja_JP locale </td> <td> <code>tm_wday</code> </td> +</tr> <tr> <th colspan="3"> Hour, minute, second </th> +</tr> <tr> <th> <code>H</code> </th> <td> writes <b>hour</b> as a decimal number, 24 hour clock (range <code>[00-23]</code>) </td> <td> <code>tm_hour</code> </td> +</tr> <tr> <th> <code>OH</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>hour</b> from 24-hour clock using the alternative numeric system, e.g. 十八 instead of 18 in ja_JP locale </td> <td> <code>tm_hour</code> </td> +</tr> <tr> <th> <code>I</code> </th> <td> writes <b>hour</b> as a decimal number, 12 hour clock (range <code>[01,12]</code>) </td> <td> <code>tm_hour</code> </td> +</tr> <tr> <th> <code>OI</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>hour</b> from 12-hour clock using the alternative numeric system, e.g. 六 instead of 06 in ja_JP locale </td> <td> <code>tm_hour</code> </td> +</tr> <tr> <th> <code>M</code> </th> <td> writes <b>minute</b> as a decimal number (range <code>[00,59]</code>) </td> <td> <code>tm_min</code> </td> +</tr> <tr> <th> <code>OM</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>minute</b> using the alternative numeric system, e.g. 二十五 instead of 25 in ja_JP locale </td> <td> <code>tm_min</code> </td> +</tr> <tr> <th> <code>S</code> </th> <td> writes <b>second</b> as a decimal number (range <code>[00,60]</code>) </td> <td> <code>tm_sec</code> </td> +</tr> <tr> <th> <code>OS</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>second</b> using the alternative numeric system, e.g. 二十四 instead of 24 in ja_JP locale </td> <td> <code>tm_sec</code> </td> +</tr> <tr> <th colspan="3"> Other </th> +</tr> <tr> <th> <code>c</code> </th> <td> writes <b>standard date and time string</b>, e.g. <code>Sun Oct 17 04:41:13 2010</code> (locale dependent) </td> <td> all </td> +</tr> <tr> <th> <code>Ec</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>alternative date and time string</b>, e.g. using 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale </td> <td> all </td> +</tr> <tr> <th> <code>x</code> </th> <td> writes localized <b>date representation</b> (locale dependent) </td> <td> all </td> +</tr> <tr> <th> <code>Ex</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>alternative date representation</b>, e.g. using 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale </td> <td> all </td> +</tr> <tr> <th> <code>X</code> </th> <td> writes localized <b>time representation</b>, e.g. 18:40:20 or 6:40:20 PM (locale dependent) </td> <td> all </td> +</tr> <tr> <th> <code>EX</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>alternative time representation</b> (locale dependent) </td> <td> all </td> +</tr> <tr> <th> <code>D</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> equivalent to <b>"%m/%d/%y"</b> </td> <td> <code>tm_mon</code>, <code>tm_mday</code>, <code>tm_year</code> </td> +</tr> <tr> <th> <code>F</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> equivalent to <b>"%Y-%m-%d"</b> (the ISO 8601 date format) </td> <td> <code>tm_mon</code>, <code>tm_mday</code>, <code>tm_year</code> </td> +</tr> <tr> <th> <code>r</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes localized <b>12-hour clock</b> time (locale dependent) </td> <td> <code>tm_hour</code>, <code>tm_min</code>, <code>tm_sec</code> </td> +</tr> <tr> <th> <code>R</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> equivalent to <b>"%H:%M"</b> </td> <td> <code>tm_hour</code>, <code>tm_min</code> </td> +</tr> <tr> <th> <code>T</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> equivalent to <b>"%H:%M:%S"</b> (the ISO 8601 time format) </td> <td> <code>tm_hour</code>, <code>tm_min</code>, <code>tm_sec</code> </td> +</tr> <tr> <th> <code>p</code> </th> <td> writes localized <b>a.m. or p.m.</b> (locale dependent) </td> <td> <code>tm_hour</code> </td> +</tr> <tr> <th> <code>z</code><br><span class="t-mark-rev t-since-c99">(C99)</span> </th> <td> writes <b>offset from UTC</b> in the ISO 8601 format (e.g. <code>-0430</code>), or no characters if the time zone information is not available </td> <td> <code>tm_isdst</code> </td> +</tr> <tr> <th> <code>Z</code> </th> <td> writes locale-dependent <b>time zone name or abbreviation</b>, or no characters if the time zone information is not available </td> <td> <code>tm_isdst</code> </td> +</tr> +</table> <h3 id="Return_value"> Return value</h3> <p>number of wide characters written into the wide character array pointed to by <code>str</code> not including the terminating <code>L'\0'</code> on success. If <code>count</code> was reached before the entire string could be stored, <code>0</code> is returned and the contents are undefined.</p> +<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdio.h> +#include <time.h> +#include <wchar.h> +#include <locale.h> + +int main(void) +{ + wchar_t buff[40]; + struct tm my_time = { .tm_year=112, // = year 2012 + .tm_mon=9, // = 10th month + .tm_mday=9, // = 9th day + .tm_hour=8, // = 8 hours + .tm_min=10, // = 10 minutes + .tm_sec=20 // = 20 secs + }; + + if (wcsftime(buff, sizeof buff, L"%A %c", &my_time)) { + printf("%ls\n", buff); + } else { + puts("wcsftime failed"); + } + + setlocale(LC_ALL, "ja_JP.utf8"); + + if (wcsftime(buff, sizeof buff, L"%A %c", &my_time)) { + printf("%ls\n", buff); + } else { + puts("wcsftime failed"); + } +}</pre></div> <p>Output:</p> +<div class="text source-text"><pre data-language="c">Sunday Sun Oct 9 08:10:20 2012 +日曜日 2012年10月09日 08時10分20秒</pre></div> </div> <h3 id="References"> References</h3> <ul> +<li> C17 standard (ISO/IEC 9899:2018): </li> +<ul><li> 7.29.5.1 The wcsftime function (p: 230-231) </li></ul> +<li> C11 standard (ISO/IEC 9899:2011): </li> +<ul><li> 7.29.5.1 The wcsftime function (p: 439-440) </li></ul> +<li> C99 standard (ISO/IEC 9899:1999): </li> +<ul><li> 7.24.5.1 The wcsftime function (p: 385-386) </li></ul> +</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="strftime" title="c/chrono/strftime"> <span class="t-lines"><span>strftime</span></span></a></div> </td> <td> converts a <code><a href="tm" title="c/chrono/tm">tm</a></code> object to custom textual representation <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/chrono/c/wcsftime" title="cpp/chrono/c/wcsftime">C++ documentation</a></span> for <code>wcsftime</code> </td> +</tr> </table> <div class="_attribution"> + <p class="_attribution-p"> + © cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br> + <a href="https://en.cppreference.com/w/c/chrono/wcsftime" class="_attribution-link">https://en.cppreference.com/w/c/chrono/wcsftime</a> + </p> +</div> |
