wcsftime
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <wchar.h> で定義
|
||
size_t wcsftime( wchar_t* str, size_t count, const wchar_t* format, tm* time ); |
(C95以上) | |
書式文字列 format に従って日付および時刻の情報を指定されたカレンダー時刻 time からヌル終端ワイドバイト文字列 str に変換します。 最大 count 文字が書き込まれます。
引数
| str | - | 出力用の wchar_t 配列の最初の要素を指すポインタ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| count | - | 書き込む最大ワイド文字数 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| format | - | 変換の書式を指定するヌル終端ワイドバイト文字列を指すポインタ。
書式文字列はゼロ個以上の変換指定子と (
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
戻り値
成功した場合は、 str の指すワイド文字配列に書き込まれた、終端の L'\0' を含まないワイド文字数。 文字列全体を格納する前に count に達した場合は、 0 が返され、内容は未定義になります。
例
Run this code
#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");
}
}
出力:
Sunday Sun Oct 9 08:10:20 2012
日曜日 2012年10月09日 08時10分20秒