Back to index

nux  3.0.0
TimeFunctions.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef TIMEFUNCTIONS_H
00024 #define TIMEFUNCTIONS_H
00025 
00026 namespace nux
00027 {
00028 // Store time from [Midnight(00:00:00), January 1, 1970 UTC] up to [23:59:59, December 31, 3000 UTC]  or [03:14:07 January 19, 2038 UTC]
00029   class TimeStamp
00030   {
00031   public:
00032 
00033     TimeStamp();
00034     ~TimeStamp();
00035     // Time is in UTC
00036     unsigned int     m_Year;           /* year                             */
00037     unsigned int     m_Month;          /* months since January - [0,11]    */
00038     unsigned int     m_Day;            /* day of the month - [1,31]        */
00039     unsigned int     m_Hour;           /* hours since midnight - [0,23]    */
00040     unsigned int     m_Minute;         /* minutes after the hour - [0,59]  */
00041     unsigned int     m_Second;         /* seconds after the minute - [0,59]*/
00042     //unsigned int     m_DayOfWeek;      /* days since Sunday - [0,6]        */
00043     //unsigned int     m_DayOfYear;      /* days since January 1 - [0,365]   */
00044     unsigned int     m_MicroSecond;
00045 
00046     long long  GetJulianDayNumber()             const;
00047     double  GetJulianDate()                  const;
00048     unsigned int    GetSecondOfDay()                 const;
00049     bool   operator== ( TimeStamp &Other )  const;
00050     bool   operator!= ( TimeStamp &Other )  const;
00051     bool   operator< ( TimeStamp &Other )  const;
00052     bool   operator> ( TimeStamp &Other )  const;
00053     bool   operator>= ( TimeStamp &Other )  const;
00054     bool   operator<= ( TimeStamp &Other )  const;
00055 
00056     void GetTime();
00057   };
00058 
00060 
00065   double Seconds();
00066 
00068 
00073   double MilliSeconds();
00074 
00075   // Retrieves the current local date and time.
00076   void GetLocalTime (unsigned int &Year,
00077                      unsigned int &Month,
00078                      unsigned int &Day,
00079                      unsigned int &Hour,
00080                      unsigned int &Min,
00081                      unsigned int &Sec,
00082                      unsigned int &MicroSec);
00083 
00084   // Retrieves the current system date and time. The system time is expressed in Coordinated Universal Time (UTC).
00085   void GetUTCTime (unsigned int &Year,
00086                    unsigned int &Month,
00087                    unsigned int &Day,
00088                    unsigned int &Hour,
00089                    unsigned int &Min,
00090                    unsigned int &Sec,
00091                    unsigned int &MicroSec);
00092 
00093   
00095 
00098   NString GetFormattedLocalTime();
00099 
00105   void SleepForMilliseconds (unsigned int Milliseconds);
00106 
00107 }
00108 
00109 #endif // TIMEFUNCTIONS_H