wcsptime()— ワイド文字ストリングから日付/時刻への変換

フォーマット

#include <wchar.h>
wchar_t *wcsptime(const wchar_t *buf, const wchar_t *format, struct tm *tm);

言語レベル: Extended

スレッド・セーフ: はい。

ロケール依存: この関数の振る舞いは、 現行ロケールの LC_UNI_CTYPE、LC_UNI_TIME、および LC_UNI_TOD カテゴリーの影響を 受ける可能性があります。この関数は、コンパイル・コマンドで LOCALETYPE(*LOCALEUTF) が指定される場合のみ使用可能です。詳細については、CCSID およびロケールの理解を参照してください。

ワイド文字関数: 詳細については、ワイド文字 を参照してください。

説明

wcsptime() 関数は、format で指定された形式を使用し、 buf により示されるワイド文字ストリングを、 tm により示される tm 構造体に保管される 値に変換します。この関数は、strptime() と同等ですが、ワイド文字を使用する点が異なります。

書式ストリングの説明については、strptime()— ストリングから日付/時刻への変換を参照してください。

戻り値

wcsptime() 関数が正常終了すると、解析した最終ワイド文字の後に続く文字へのポインターを戻します。それ以外の場合は、NULL ポインターが戻されます。 errno の値は ECONVERT (変換エラー) に設定される可能性があります。

wcsptime() の使用例

#include <stdio.h>
#include <time.h>
#include <wchar.h>

int main(void)
{
    wchar_t buf[100];
    time_t t;
    struct tm *timeptr,result;

    t = time(NULL);
    timeptr = localtime(&t);
    wcsftime(buf, 100, L"%a %m/%d/%Y %r", timeptr);

    if (wcsptime(buf, L"%a %m/%d/%Y %r", &result) == NULL)
          printf("¥nwcsptime failed¥n");
   else
   {
          printf("tm_hour:  %d¥n",result.tm_hour);
          printf("tm_min:  %d¥n",result.tm_min);
          printf("tm_sec:  %d¥n",result.tm_sec);
          printf("tm_mon:  %d¥n",result.tm_mon);
          printf("tm_mday:  %d¥n",result.tm_mday);
          printf("tm_year:  %d¥n",result.tm_year);
          printf("tm_yday:  %d¥n",result.tm_yday);
          printf("tm_wday:  %d¥n",result.tm_wday);
   }

   return 0;
}

/************************************************************
     The output should be similar to:
      
      tm_hour:  14
   	tm_min:  25
   	tm_sec:  34
   	tm_mon:  7
   	tm_mday:  19
   	tm_year:  103
   	tm_yday:  230
   	tm_wday:  2
************************************************************/

関連情報



[ ページのトップ | 前ページ | 次ページ | 目次 | 索引 ]