線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1217
推到 Plurk!
推到 Facebook!

Difference of time

尚未結案
chgtauhan
一般會員


發表:10
回覆:21
積分:6
註冊:2005-07-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-07-27 19:54:37 IP:60.48.xxx.xxx 未訂閱
Can i now how to calculate the difference of time.Here is the code i write: TTime d; d=Time(); //do..... Label1->Caption=Time()-d; The difference of time is calculated if your computer time system is set to 24 hours system. If your computer time system is set to 12 hours sistem, something weird is shown, example 12:00:01 am. How to overcome this problem? And then can i know how to calculate the difference of time until mili seconds.... Please.......
justdo
高階會員


發表:2
回覆:359
積分:222
註冊:2004-08-17

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-07-27 21:11:17 IP:221.169.xxx.xxx 未訂閱
改用ftime()吧 查查BCB的help,上面有個範例
andychang1690
資深會員


發表:20
回覆:694
積分:442
註冊:2003-03-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-07-28 02:11:21 IP:221.169.xxx.xxx 未訂閱
chgtauhan:方法有一些
一、你可以統一電腦時間格式
  AnsiString sgs;
  sgs.SetLength(12);
  // 得到目前系統時間格式
  GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_STIMEFORMAT ,sgs.c_str(),12);
  if (sgs.Trim() != "HH:mm:ss") {
    AnsiString str;
    str = "HH:mm:ss"; // HH:24小時制 hh:12小時制
    if (SetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_STIMEFORMAT, str.c_str()))
      ShowMessage("更改時間格式成功");
  }
二、使用DecodeTime,EncodeTime做運算
  Word Hour,Min,Sec,mSec;
  TTime d;
  d=Time();
  DecodeTime(d,Hour,Min,Sec,mSec);
  d =EncodeTime((Word)Hour, (Word)Min, (Word)Sec, (Word)mSec);
三、直接如你一般直接運算!(只要時間格式如一般統一)
請參考!
Andy Chang
------
Andy Chang
chgtauhan
一般會員


發表:10
回覆:21
積分:6
註冊:2005-07-23

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-07-28 10:20:46 IP:161.139.xxx.xxx 未訂閱
oic, thank you. But can i know why we must set the length t o 12? AnsiString sgs; sgs.SetLength(12);
andychang1690
資深會員


發表:20
回覆:694
積分:442
註冊:2003-03-14

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-07-29 01:37:37 IP:221.169.xxx.xxx 未訂閱
chgtauhan:因為使用了windows API函數
int GetLocaleInfo(
  LCID Locale, // locale identifier 
  LCTYPE LCType, // type of information 
  LPTSTR lpLCData, // address of buffer for information 
  int cchData // size of buffer 
); 
而最長的時間格式為:tt hh:mm:ss(11位數)
所以我習慣設為12,你可以試試
  AnsiString sgs;
  sgs.SetLength(12);
  // 得到目前系統時間格式
  GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_STIMEFORMAT ,sgs.c_str(),12);
Edit1->Text=sgs;
將12改為6出現HH:mm:
將12改為7出現HH:mm:s
8以上為HH:mm:ss
請參考!
Andy Chang
------
Andy Chang
chgtauhan
一般會員


發表:10
回覆:21
積分:6
註冊:2005-07-23

發送簡訊給我
#6 引用回覆 回覆 發表時間:2005-07-29 22:01:08 IP:219.93.xxx.xxx 未訂閱
oic, thanks a lot....
chgtauhan
一般會員


發表:10
回覆:21
積分:6
註冊:2005-07-23

發送簡訊給我
#7 引用回覆 回覆 發表時間:2005-08-05 19:48:16 IP:218.111.xxx.xxx 未訂閱
here is the code:
AnsiString sgs;
  sgs.SetLength(12);
  // 得到目前系統時間格式
  GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_STIMEFORMAT ,sgs.c_str(),12);
  if (sgs.Trim() != "HH:mm:ss") {
    AnsiString str;
    str = "HH:mm:ss"; // HH:24小時制 hh:12小時制
    if (SetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_STIMEFORMAT, str.c_str()))
      ShowMessage("更改時間格式成功");
  }
after i apply the code above, it only change the format but it doesn't apply to the cpu. how to apply to the cpu?
andychang1690
資深會員


發表:20
回覆:694
積分:442
註冊:2003-03-14

發送簡訊給我
#8 引用回覆 回覆 發表時間:2005-08-06 23:49:04 IP:221.169.xxx.xxx 未訂閱
引言: here is the code:
AnsiString sgs;
  sgs.SetLength(12);
  // 得到目前系統時間格式
  GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_STIMEFORMAT ,sgs.c_str(),12);
  if (sgs.Trim() != "HH:mm:ss") {
    AnsiString str;
    str = "HH:mm:ss"; // HH:24小時制 hh:12小時制
    if (SetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_STIMEFORMAT, str.c_str()))
      ShowMessage("更改時間格式成功");
  }
after i apply the code above, it only change the format but it doesn't apply to the cpu. how to apply to the cpu?
chgtauhan:這可難倒我了,我確定我的程式可以更改Windows系統上
的日期及時間設置,但CPU............?!
Andy Chang
------
Andy Chang
chgtauhan
一般會員


發表:10
回覆:21
積分:6
註冊:2005-07-23

發送簡訊給我
#9 引用回覆 回覆 發表時間:2005-08-14 13:17:17 IP:203.106.xxx.xxx 未訂閱
thanks ya, andychang1690. You have solved my problem.
系統時間:2024-05-09 14:48:37
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!