시간계산을 해야하는데여....
단말기로부터오는 시간 정보를 계산해서 출력해야합니다.
예전엔 C에서 Time_T Type으로 선언해서 계산을 했는데...
델파이에선 이와 같은 Type이 없는 건지... 아님 다른 방법이 있는지 갈켜 주세여...
아래는 예전에 MFC에서 시간을 계산한 Source 입니다. 이것을 Pascal로 바꾸고 시포 여...
------ C Source -----
__int64 time = reset_time; // reset_time은 단말로 부터 들어온 데이터....
time >>= 16;
__int64 time_t = (__int64)(time *1.25) % 1000;
DWord e_time = (DWord)(time / 800);
time_t time_x = (time_t)(e_time + 315964800);
char temp[30];
strcpy(temp, ctime(&time_x));
temp[24] = NULL;
Stamp.Format("%s", temp);
GetDlgItem(IDC_TIME) -> SetWindowText(stamp);
//---------------------------------------------//
근데 님께서 쓰신 단말기서 온 데이터가 어떤건지 몰라서리 확답은 몬하겠네여
년월일시분초 계산은 알아서 하시고 그거 스트링으로 바꾼담에 strtodatetime(..)으로 바꿔 쓰시면 됩니다.
그리고 한달 늘리구 싶으시면 incMonth(temDate,1), 하루 늘리고 싶으시면 temDate := temDate + 1 (단 temDate는 TDate)
밑에는 TDateTime 의 도움말 임당... 틈틈이 F1 눌려 보시길 고거이 바이블이죠..
즐푸하세염...
----------
type TDateTime = type Double;
Description
Most VCL objects represent date and time values using the TDateTime type. The integral part of a TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of a TDateTime value is fraction of a 24 hour day that has elapsed.
Following are some examples of TDateTime values and their corresponding dates and times:
0 12/30/1899 12:00 am
2.75 1/1/1900 6:00 pm
-1.25 12/29/1899 6:00 am
35065 1/1/1996 12:00 am
To find the fractional number of days between two dates, simply subtract the two values. Likewise, to increment a date and time value by a certain fractional number of days, simply add the fractional number to the date and time value.
Note: Delphi 1.0 calculated the date from year 1 instead of from 1899. To convert a Delphi 1.0 date to a Delphi 2.0 date, subtract 693594.0 from the Delphi 1.0 date. The date format changed to be more compatible with OLE 2.0 Automation.
albireo wrote:
>
> 시간계산을 해야하는데여....
> 단말기로부터오는 시간 정보를 계산해서 출력해야합니다.
> 예전엔 C에서 Time_T Type으로 선언해서 계산을 했는데...
> 델파이에선 이와 같은 Type이 없는 건지... 아님 다른 방법이 있는지 갈켜 주세여...
> 아래는 예전에 MFC에서 시간을 계산한 Source 입니다. 이것을 Pascal로 바꾸고 시포 여...
>
> ------ C Source -----
> __int64 time = reset_time; // reset_time은 단말로 부터 들어온 데이터....
> time >>= 16;
> __int64 time_t = (__int64)(time *1.25) % 1000;
> DWord e_time = (DWord)(time / 800);
> time_t time_x = (time_t)(e_time + 315964800);
>
> char temp[30];
> strcpy(temp, ctime(&time_x));
> temp[24] = NULL;
> Stamp.Format("%s", temp);
> GetDlgItem(IDC_TIME) -> SetWindowText(stamp);
> //---------------------------------------------//
>
>