잠토의 잠망경

본문

카테고리 없음

잠수함토끼 2012. 1. 7. 10:39

[시간을 표현하는 함수]

 

UTC는 세계 표준 시간으로 지역시간과는 차이가 보인다.

하여 지역시간으로 동기화를 위해서는 Convert할 수 있는 함수가 필요한데 이는

SystemTimeToTzSpecificLocalTime 함수이다.

 

 

void C시간SystemTimeToTzSpecificLocalTimeDlg::OnBnClickedButton1()

{

    // TODO: 여기에컨트롤알림처리기코드를추가합니다.

    

    /*

    The GetSystemTime function retrieves the current system date and time.

    The system time is expressed in Coordinated Universal Time (UTC).

 

    VOID GetSystemTime    (

                LPSYSTEMTIME lpSystemTime     // address of system time structure

                );

 

    The SystemTimeToTzSpecificLocalTime function converts a Coordinated Universal Time (UTC) to a specified time zone's corresponding local time.

 

    BOOL SystemTimeToTzSpecificLocalTime (

 

        LPTIME_ZONE_INFORMATION lpTimeZoneInformation,    // pointer to time zone of interest

        LPSYSTEMTIME lpUniversalTime,    // pointer to universal time of interest

        LPSYSTEMTIME lpLocalTime    // pointer to structure to receive local time

    );

    */

      

 

    

    SYSTEMTIME Global;     // UTC 시간이저장됨

    GetSystemTime(&Global);    // UTC 시간을얻음

                    // 현지의한국시간이아님

 

    SYSTEMTIME Korea;        // 한국시간(LOCAL 시간이저장될변수)

      

                            // UTC 시간을한국시간으로변경

    BOOL retVal = SystemTimeToTzSpecificLocalTime(NULL, &Global, &Korea);

 

    if(!retVal)

    {

        DWORD dWord = GetLastError();

    }

}

 

해당 부분은 해당 함수를 동작 시키고 난 후의 Debug 화면이다.

 

 

Comments