home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Source / Vcl / DATETIME.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  2.4 KB  |  103 lines

  1. #include    <system.hpp>
  2. #include    <sysutils.hpp>
  3.  
  4. namespace System
  5. {
  6.     TDateTime __fastcall TDateTime::CurrentDate()
  7.     {
  8.         return Sysutils::Date();
  9.     }
  10.  
  11.     TDateTime __fastcall TDateTime::CurrentTime()
  12.     {
  13.         return Sysutils::Time();
  14.     }
  15.  
  16.     TDateTime __fastcall TDateTime::CurrentDateTime()
  17.     {
  18.         return Sysutils::Now();
  19.     }
  20.  
  21.     TDateTime __fastcall TDateTime::FileDateToDateTime(int fileDate)
  22.     {
  23.         return Sysutils::FileDateToDateTime(fileDate);
  24.     }
  25.  
  26. //ctors
  27.     __fastcall TDateTime::TDateTime(const AnsiString& src, TDateTimeFlag flag)
  28.     {
  29.         TDateTime tmp;
  30.         if (flag == DateTime )
  31.             tmp = Sysutils::StrToDateTime(src);
  32.         else if (flag == Date)
  33.             tmp = Sysutils::StrToDate(src);
  34.         else // flag == Time
  35.             tmp    = Sysutils::StrToTime(src);
  36.         Val = tmp.Val;
  37.     }
  38.  
  39.     __fastcall TDateTime::TDateTime(unsigned short year, unsigned short month,
  40.                                     unsigned short day)
  41.     {
  42.         TDateTime tmp = Sysutils::EncodeDate(year, month, day);
  43.         Val = tmp.Val;
  44.     }
  45.  
  46.     __fastcall TDateTime::TDateTime(unsigned short hour, unsigned short min,
  47.                                     unsigned short sec, unsigned short msec)
  48.     {
  49.         TDateTime tmp = Sysutils::EncodeTime(hour, min, sec, msec);
  50.         Val = tmp.Val;
  51.     }
  52.  
  53. //other TDateTime functions
  54.     __fastcall TDateTime::operator AnsiString() const
  55.     {
  56.         if (Val < 1)
  57.             return Sysutils::TimeToStr(*this);
  58.         else if ((Val - int(Val)))
  59.             return Sysutils::DateTimeToStr(*this);
  60.         return Sysutils::DateToStr(*this);
  61.     }
  62.  
  63.     AnsiString __fastcall TDateTime::FormatString(const AnsiString& format)
  64.     {
  65.         return Sysutils::FormatDateTime(format, *this);
  66.     }
  67.  
  68.     AnsiString __fastcall TDateTime::DateString() const
  69.     {
  70.         return Sysutils::DateToStr(*this);
  71.     }
  72.  
  73.     AnsiString __fastcall TDateTime::TimeString() const
  74.     {
  75.         return Sysutils::TimeToStr(*this);
  76.     }
  77.  
  78.     AnsiString __fastcall TDateTime::DateTimeString() const
  79.     {
  80.         return Sysutils::DateTimeToStr(*this);
  81.     }
  82.  
  83.     int __fastcall TDateTime::DayOfWeek() const
  84.     {
  85.         return Sysutils::DayOfWeek(*this);
  86.     }
  87.  
  88.     int __fastcall TDateTime::FileDate() const
  89.     {
  90.         return Sysutils::DateTimeToFileDate(*this);
  91.     }
  92.     void __fastcall TDateTime::DecodeDate(unsigned short* year,
  93.                                           unsigned short* month, unsigned short* day) const
  94.     {
  95.         Sysutils::DecodeDate(*this, *year, *month, *day);
  96.     }
  97.     void __fastcall TDateTime::DecodeTime(unsigned short* hour,
  98.                                           unsigned short* min, unsigned short* sec, unsigned short* msec) const
  99.     {
  100.         Sysutils::DecodeTime(*this, *hour, *min, *sec, *msec);
  101.     }
  102. }
  103.