반응형
mktime(3)
#include <time.h>
time_t mktime(struct tm *tm);
struct tm type의 데이터를 timt_t의 시간으로 변환합니다. mktime(3)은 localtime(3)의 값을 기준으로 time_t로 변환됩니다.
struct tm은 데이터 구조는 다음과 같습니다.
struct tm {
int tm_sec; /* seconds */
int tm_min; /* minutes */
int tm_hour; /* hours */
int tm_mday; /* day of the month */
int tm_mon; /* month */
int tm_year; /* year */
int tm_wday; /* day of the week */
int tm_yday; /* day in the year */
int tm_isdst; /* daylight saving time */
};
time_t는 대체로 long type으로 표현되며, 1970년 1월 1일 00:00:00부터 경과된 시간을 초로 표현됩니다.
파라미터
tm
- sturct tm * type의 시간 정보 구조체
RETURN
0 이상
- 1970년 1월 1일 00:00:00부터 경과된 시간을 초단위(time_t).
-1
- 오류가 발생하였습니다.
see also : 시간 관련 함수
반응형
'C언어 header > time.h' 카테고리의 다른 글
strptime(3) - format된 문자열 시간을 struct tm으로 변환 (0) | 2019.09.30 |
---|---|
strftime(3) - struct tm을 format된 문자열로 변환 (0) | 2019.09.30 |
asctime_r(3) - struct tm 구조체를 날짜 및 시간 표시 문자열로 변환(thread-safe) (0) | 2019.09.30 |
asctime(3) - struct tm 구조체를 날짜 및 시간 표시 문자열로 변환 (1) | 2019.09.30 |
ctime_r(3) - 초단위 시간을 문자열로 변환(thread-safe) (0) | 2019.09.30 |