티스토리 뷰

1. 두 COleDateTime 객체간의 차이를 구할 때는

COleDateTime ATime(2007, 4, 26, 17, 20, 30);
COleDateTime BTime(2007, 4, 26, 18, 20, 50);

COleDateTimeSpan C = BTime - ATime;

C.GetTotalDays() - 차이나는 총 날짜
C.GetTotalHours() - 차이나는 총 시간
C.GetTotalMinutes() - 차이나는 총 분
C.GetTotalSeconds() - 차이나는 총 초



2. CString 으로 바꾸고 싶다면.. 멤버 함수 Format 을 사용하면 된다.

COleDateTime nowTime(COleDateTime::GetCurrentTime());
OutputDebugString(nowTime.Format(_T("%H:%M:%S\n")));

Format 에 들어가는 것은

%a     Abbreviated weekday name
%A     Full weekday name
%b     Abbreviated month name
%B     Full month name
%c     Date and time representation appropriate for locale
%d     Day of month as decimal number (01 – 31)
%H     Hour in 24-hour format (00 – 23)
%I      Hour in 12-hour format (01 – 12)
%j      Day of year as decimal number (001 – 366)
%m    Month as decimal number (01 – 12)
%M   Minute as decimal number (00 – 59)
%p    Current locale's A.M./P.M. indicator for 12-hour clock
%S    Second as decimal number (00 – 59)
%U    Week of year as decimal number, with Sunday as first day of week (00 – 53)
%w   Weekday as decimal number (0 – 6; Sunday is 0)
%W   Week of year as decimal number, with Monday as first day of week (00 – 53)
%x    Date representation for current locale
%X    Time representation for current locale
%y    Year without century, as decimal number (00 – 99)
%Y   Year with century, as decimal number
%z, %Z  Either the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown
%%   Percent sign



3. 지정된 시간에서 '분'을 더한 시간 계산


void UpdateTime( SYSTEMTIME& stPatchTime, INT32 wMinute )

{

COleDateTime PatchTime( stPatchTime.wYear, stPatchTime.wMonth, stPatchTime.wDay, stPatchTime.wHour, stPatchTime.wMinute, stPatchTime.wSecond );

 

COleDateTimeSpan SpendTime;

SpendTime.SetDateTimeSpan( 0, 0, wMinute, 0 );

PatchTime += SpendTime;

          

stPatchTime.wYear = PatchTime.GetYear();

stPatchTime.wMonth = PatchTime.GetMonth();

stPatchTime.wDay = PatchTime.GetDay();

stPatchTime.wHour = PatchTime.GetHour();

stPatchTime.wMinute = PatchTime.GetMinute();

}




출처 : 
http://kgpark.net/tools/tag/COleDateTime?TSSESSION=109cc45945c763a714e0dc4668142de2
http://jacking.tistory.com/758


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함