~om26er/ubuntu/oneiric/nux/sru-819721

« back to all changes in this revision

Viewing changes to NuxCore/NTime.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-11-18 19:17:32 UTC
  • Revision ID: james.westby@ubuntu.com-20101118191732-rn35790vekj6o4my
Tags: upstream-0.9.4
ImportĀ upstreamĀ versionĀ 0.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010 Inalogic Inc.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3, as
 
6
 * published by the  Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
 
12
 * License for more details.
 
13
 *
 
14
 * You should have received a copy of both the GNU Lesser General Public
 
15
 * License version 3 along with this program.  If not, see
 
16
 * <http://www.gnu.org/licenses/>
 
17
 *
 
18
 * Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
 
19
 *
 
20
 */
 
21
 
 
22
 
 
23
#ifndef NTIME_H
 
24
#define NTIME_H
 
25
 
 
26
namespace nux
 
27
{
 
28
// 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]
 
29
  class NTimeStamp
 
30
  {
 
31
  public:
 
32
 
 
33
    NTimeStamp();
 
34
    ~NTimeStamp();
 
35
    // Time is in UTC
 
36
    unsigned int     m_Year;           /* year                             */
 
37
    unsigned int     m_Month;          /* months since January - [0,11]    */
 
38
    unsigned int     m_Day;            /* day of the month - [1,31]        */
 
39
    unsigned int     m_Hour;           /* hours since midnight - [0,23]    */
 
40
    unsigned int     m_Minute;         /* minutes after the hour - [0,59]  */
 
41
    unsigned int     m_Second;         /* seconds after the minute - [0,59]*/
 
42
    //unsigned int     m_DayOfWeek;      /* days since Sunday - [0,6]        */
 
43
    //unsigned int     m_DayOfYear;      /* days since January 1 - [0,365]   */
 
44
    unsigned int     m_MicroSecond;
 
45
 
 
46
    t_s64  GetJulianDayNumber()             const;
 
47
    t_f64  GetJulianDate()                  const;
 
48
    unsigned int    GetSecondOfDay()                 const;
 
49
    bool   operator== ( NTimeStamp &Other )  const;
 
50
    bool   operator!= ( NTimeStamp &Other )  const;
 
51
    bool   operator< ( NTimeStamp &Other )  const;
 
52
    bool   operator> ( NTimeStamp &Other )  const;
 
53
    bool   operator>= ( NTimeStamp &Other )  const;
 
54
    bool   operator<= ( NTimeStamp &Other )  const;
 
55
 
 
56
    void GetTime();
 
57
  };
 
58
 
 
59
//! Returns the number of cycles that have passed. The origin is unknown.
 
60
  /*!
 
61
      Returns the number of cycles that have passed. The origin is unknown.
 
62
 
 
63
      @return current value of high resolution cycle counter.
 
64
  */
 
65
  DWORD inlCycles();
 
66
 
 
67
#if STATS
 
68
#define inl_clock(Timer)   {Timer -= inlCycles();}
 
69
#define inl_unclock(Timer) {Timer += inlCycles();}
 
70
#else
 
71
#define inl_clock(Timer)
 
72
#define inl_unclock(Timer)
 
73
#endif
 
74
 
 
75
 
 
76
//! Returns the time that has passed in seconds. The origin is unknown.
 
77
  /*!
 
78
      Returns the time that has passed in seconds. The origin is unknown.
 
79
 
 
80
      @return the time passed in seconds.
 
81
  */
 
82
  double Seconds();
 
83
 
 
84
//! Returns the time that has passed in milliseconds. The origin is unknown.
 
85
  /*!
 
86
      Returns the time that has passed in milliseconds. The origin is unknown.
 
87
 
 
88
      @return the time passed in milliseconds.
 
89
  */
 
90
  double MilliSeconds();
 
91
 
 
92
// Retrieves the current local date and time.
 
93
  void GetLocalTime (unsigned int &Year,
 
94
                     unsigned int &Month,
 
95
                     unsigned int &Day,
 
96
                     unsigned int &Hour,
 
97
                     unsigned int &Min,
 
98
                     unsigned int &Sec,
 
99
                     unsigned int &MicroSec);
 
100
 
 
101
// Retrieves the current system date and time. The system time is expressed in Coordinated Universal Time (UTC).
 
102
  void GetUTCTime (unsigned int &Year,
 
103
                   unsigned int &Month,
 
104
                   unsigned int &Day,
 
105
                   unsigned int &Hour,
 
106
                   unsigned int &Min,
 
107
                   unsigned int &Sec,
 
108
                   unsigned int &MicroSec);
 
109
 
 
110
//! Returns the time formatted in a string
 
111
  /*!
 
112
      Returns the time formatted in a string.
 
113
  */
 
114
  const TCHAR *GetFormattedLocalTime();
 
115
 
 
116
//! Sleep the thread for Seconds.
 
117
  /*!
 
118
      Sleep the thread for Seconds.
 
119
      A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run.
 
120
  */
 
121
  void SleepSeconds ( float Seconds );
 
122
 
 
123
//! Sleep the thread for MilliSeconds.
 
124
  /*!
 
125
      Sleep the thread for MilliSeconds.
 
126
      A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run.
 
127
  */
 
128
  void SleepMilliSeconds ( float MilliSeconds );
 
129
 
 
130
//! Get the time zone in hours.
 
131
  /*!
 
132
      Get the time zone in hours. Estern North American time zone is -5 hours.
 
133
  */
 
134
  t_long GetTimeZone();
 
135
 
 
136
  /*!
 
137
      Suspend thread execution for an interval measured in microseconds.
 
138
 
 
139
      @Milliseconds duration in Milliseconds.
 
140
  */
 
141
  void SleepForMilliseconds (unsigned int Milliseconds);
 
142
 
 
143
}
 
144
 
 
145
#endif // NTIME_H