//===========================================================================
//FILETIME構造体をTTimeStampに変換して文字列として取得する
//===========================================================================
String __fastcall TAttacheCaseFileEncrypt::TimeStampToString(FILETIME ft)
{

SYSTEMTIME st;
TDateTime dt;
TTimeStamp ts;

//FileTime → SystemFileTime
FileTimeToSystemTime(&ft, &st);
//SystemTime → TDateTime
dt = SystemTimeToDateTime(st);
//TDateTime → TimeStamp
ts = DateTimeToTimeStamp(dt);

/*
//ファイル/ディレクトリの日時をなぜ
//わざわざサイズが大きいTTimeStampに変換して格納したのか?
//ごめんなさい、意味はありません(笑)。

struct TTimeStamp
{
	int Time;
	int Date;
};
*/

return(IntToStr(ts.Date)+"\t"+IntToStr(ts.Time));

}
示例#2
0
void DecodeTime(const TDateTime & DateTime, unsigned short & Hour,
  unsigned short & Min, unsigned short & Sec, unsigned short & MSec)
{
  uintptr_t MinCount, MSecCount;
  DivMod(DateTimeToTimeStamp(DateTime).Time, 60000, MinCount, MSecCount);
  uintptr_t H, M, S, MS;
  DivMod(MinCount, 60, H, M);
  DivMod(MSecCount, 1000, S, MS);
  Hour = static_cast<unsigned short>(H);
  Min = static_cast<unsigned short>(M);
  Sec = static_cast<unsigned short>(S);
  MSec = static_cast<unsigned short>(MS);
}
示例#3
0
//---------------------------------------------------------------------------
static bool DecodeDateFully(const TDateTime & DateTime,
  unsigned short & Year, unsigned short & Month, unsigned short & Day,
  unsigned short & DOW)
{
  static const int D1 = 365;
  static const int D4 = D1 * 4 + 1;
  static const int D100 = D4 * 25 - 1;
  static const int D400 = D100 * 4 + 1;
  bool Result = false;
  uintptr_t T = DateTimeToTimeStamp(DateTime).Date;
  if (static_cast<int>(T) <= 0)
  {
    Year = 0;
    Month = 0;
    Day = 0;
    DOW = 0;
    return false;
  }
  else
  {
    DOW = T % 7 + 1;
    T--;
    uintptr_t Y = 1;
    while (T >= D400)
    {
      T -= D400;
      Y += 400;
    }
    uintptr_t D = 0;
    uintptr_t I = 0;
    DivMod(T, D100, I, D);
    if (I == 4)
    {
      I--;
      D += D100;
    }
    Y += I * 100;
    DivMod(D, D4, I, D);
    Y += I * 4;
    DivMod(D, D1, I, D);
    if (I == 4)
    {
      I--;
      D += static_cast<Word>(D1);
    }
    Y += I;
    Result = IsLeapYear(static_cast<Word>(Y));
    const TDayTable * DayTable = &MonthDays[Result];
    uintptr_t M = 1;
    while (true)
    {
      I = (*DayTable)[M - 1];
      if (D < I)
      {
        break;
      }
      D -= I;
      M++;
    }
    Year = static_cast<unsigned short>(Y);
    Month = static_cast<unsigned short>(M);
    Day = static_cast<unsigned short>(D + 1);
  }
  return Result;
}