"Fossies" - the Fresh Open Source Software Archive

Member "unrar/timefn.hpp" (4 May 2022, 1904 Bytes) of package /linux/misc/unrarsrc-6.1.7.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "timefn.hpp" see the Fossies "Dox" file reference documentation.

    1 #ifndef _RAR_TIMEFN_
    2 #define _RAR_TIMEFN_
    3 
    4 struct RarLocalTime
    5 {
    6   uint Year;
    7   uint Month;
    8   uint Day;
    9   uint Hour;
   10   uint Minute;
   11   uint Second;
   12   uint Reminder; // Part of time smaller than 1 second, represented in 1/REMINDER_PRECISION intervals.
   13   uint wDay;
   14   uint yDay;
   15 };
   16 
   17 
   18 class RarTime
   19 {
   20   private:
   21     static const uint TICKS_PER_SECOND = 1000000000; // Internal precision.
   22 
   23     // Internal time representation in 1/TICKS_PER_SECOND since 01.01.1601.
   24     // We use nanoseconds here to handle the high precision Unix time.
   25     uint64 itime;
   26   public:
   27     // RarLocalTime::Reminder precision. Must be equal to TICKS_PER_SECOND.
   28     // Unlike TICKS_PER_SECOND, it is a public field.
   29     static const uint REMINDER_PRECISION = TICKS_PER_SECOND;
   30   public:
   31     RarTime() {Reset();}
   32     bool operator == (RarTime &rt) {return itime==rt.itime;}
   33     bool operator != (RarTime &rt) {return itime!=rt.itime;}
   34     bool operator < (RarTime &rt)  {return itime<rt.itime;}
   35     bool operator <= (RarTime &rt) {return itime<rt.itime || itime==rt.itime;}
   36     bool operator > (RarTime &rt)  {return itime>rt.itime;}
   37     bool operator >= (RarTime &rt) {return itime>rt.itime || itime==rt.itime;}
   38 
   39     void GetLocal(RarLocalTime *lt);
   40     void SetLocal(RarLocalTime *lt);
   41 #ifdef _WIN_ALL
   42     void GetWinFT(FILETIME *ft);
   43     void SetWinFT(FILETIME *ft);
   44 #endif
   45     uint64 GetWin();
   46     void SetWin(uint64 WinTime);
   47     time_t GetUnix();
   48     void SetUnix(time_t ut);
   49     uint64 GetUnixNS();
   50     void SetUnixNS(uint64 ns);
   51     uint GetDos();
   52     void SetDos(uint DosTime);
   53     void GetText(wchar *DateStr,size_t MaxSize,bool FullMS);
   54     void SetIsoText(const wchar *TimeText);
   55     void SetAgeText(const wchar *TimeText);
   56     void SetCurrentTime();
   57     void Reset() {itime=0;}
   58     bool IsSet() {return itime!=0;}
   59     void Adjust(int64 ns);
   60 };
   61 
   62 const wchar *GetMonthName(int Month);
   63 bool IsLeapYear(int Year);
   64 
   65 #endif