C-standard-library-time-h
Cライブラリ-<time.h>
*time.h* ヘッダーは、4つの変数タイプ、2つのマクロ、および日付と時刻を操作するためのさまざまな関数を定義します。
ライブラリー変数
以下は、ヘッダーtime.hで定義されている変数タイプです-
Sr.No. | Variable & Description |
---|---|
1 |
size_t これは符号なし整数型であり、 sizeof キーワードの結果です。 |
2 |
clock_t これは、プロセッサー時間の保管に適したタイプです。 |
3 |
time_t is これは、カレンダーの時刻を保存するのに適したタイプです。 |
4 |
struct tm これは、時刻と日付を保持するために使用される構造です。 |
tm構造には次の定義があります-
struct tm {
int tm_sec; /*seconds, range 0 to 59 */
int tm_min; /*minutes, range 0 to 59 */
int tm_hour; /*hours, range 0 to 23 */
int tm_mday; /*day of the month, range 1 to 31 */
int tm_mon; /*month, range 0 to 11 */
int tm_year; /*The number of years since 1900 */
int tm_wday; /*day of the week, range 0 to 6 */
int tm_yday; /*day in the year, range 0 to 365 */
int tm_isdst; /*daylight saving time */
};
ライブラリマクロ
以下は、ヘッダーtime.hで定義されているマクロです-
Sr.No. | Macro & Description |
---|---|
1 |
NULL このマクロは、ヌルポインター定数の値です。 |
2 |
CLOCKS_PER_SEC このマクロは、1秒あたりのプロセッサクロックの数を表します。 |
ライブラリ関数
以下は、ヘッダーtime.hで定義されている機能です-
Sr.No. | Function & Description |
---|---|
1 |
char *asctime(const struct tm *timeptr) 構造体timeptrの日時を表す文字列へのポインターを返します。 |
2 |
実装定義時代(通常はプログラムの開始)の開始以降に使用されたプロセッサクロック時間を返します。 |
3 |
char *ctime(const time_t *timer) 引数タイマーに基づいてローカル時間を表す文字列を返します。 |
4 |
double difftime(time_t time1, time_t time2) time1とtime2(time1-time2)の秒の差を返します。 |
5 |
struct tm *gmtime(const time_t *timer) タイマーの値は構造体tmに分割され、グリニッジ標準時(GMT)とも呼ばれる協定世界時(UTC)で表されます。 |
6 |
struct tm *localtime(const time_t *timer) timerの値は構造体tmに分割され、ローカルタイムゾーンで表されます。 |
7 |
time_t mktime(struct tm *timeptr) timeptrが指す構造体をローカルタイムゾーンに従ってtime_t値に変換します。 |
8 |
size_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr) formatで定義され、strに格納されているフォーマット規則に従って、構造timeptrで表される時間をフォーマットします。 |
9 |
現在のカレンダー時間を計算し、それをtime_t形式にエンコードします。 |