티스토리 뷰
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 을 사용하면 된다.
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
'Programming > C,C++' 카테고리의 다른 글
C#으로 만든 DLL을 C++에서 사용하기 (1) | 2017.07.07 |
---|---|
웹에서 간단한 C/C++ 코드 테스트를 하자 (0) | 2016.07.08 |
[C] format 형식 지정시 숫자 앞에 0 붙이기 (0) | 2016.05.03 |
[Effective C++ 정리] #define을 쓰려거든 const, enum, inline을 떠올리자 (0) | 2014.06.05 |