[C++] 원하는 시간 time(timestamp) 설정. mktime, localtime_s
//!< 현재 시간 초 단위로 담기.
//time_t nowTime = time(NULL);
//tm tmTime;
//localtime_s(&tmTime, &atm);
////////////////////////////////////////
struct tm atm;
//!< 또는,
// tm atm;
//!< 2011.12.31. 00:00:00
atm.tm_isdst = 0; //!< daylight saving time
atm.tm_sec = 0; //!< seconds
atm.tm_min = 0; //!< minutes
atm.tm_hour = 0; //!< hours
atm.tm_year = 2011 - 1900; //!< year (-1900 계산 필요.)
atm.tm_mon = 12 - 1; //!< month (1월 = 0, 12월 = 11 이라 -1 계산 필요.)
atm.tm_mday = 31; //!< day of the month
//!< 2011.12.31. 00:00:00 에서 +5일 합산. -> 2012. 1. 5. 00:00:00 설정 됨.
atm.tm_mday = atm.tm_mday + 5;
//!< mktime 에서 초과된 Day 값 계산.
time_t m_time = mktime(&atm); //!< timestamp
printf("Test : %d \n", m_time);
/* Test : 1325689200 */
tm _tm;
/* 현재 초단위 시간을 분리하여 구조체 담기.
2번째 인자에 Tick을 넣으면 그 Tick 시간 설정된 시간으로 구조체 담기.
localtime 함수로 현재 시간 구할 수 있으나 VS 2005 이후 보안 강화.
localtime 사용시 waring c4996 경고 뜸 */
localtime_s(&_tm &m_time);
printf("localTime : Year(%d) Month(%d) Day(%d) \n", (_tm->tm_year+1900), (_tm->tm_mon+1), _tm->tm_mday);
/* localTime : Year(2012) Month(1) Day(5) */