MGF Server  2.1
Multigaze framework server
 All Classes Functions
CGDTimestamp.h
1 #pragma once
2 
3 #ifndef CGDTIMESTAMP_H
4 #define CGDTIMESTAMP_H
5 
6 #ifdef _WIN32
7 #include <ctime>
8 #endif
9 
10 #include <ostream>
11 
12 using namespace std;
13 
18 {
19  unsigned short Year; //current year
20  unsigned int Days; //days past since January 1st
21  unsigned long Milliseconds; //Milliseconds past since 00:00 for the current day
22 
23 public:
25  {
26 #ifdef _WIN32
27  time_t systime(0);
28  tm t;
29  gmtime_s(&t, &systime);
30 
31  Year = t.tm_year;
32  Days = t.tm_yday;
33  Milliseconds = (t.tm_hour*3600 + t.tm_min*60 + t.tm_sec) * 1000;
34 #else
35 
36  Year = 0;
37  Days = 0;
38  Milliseconds = 0;
39 #endif
40  }
41 
42  CGDTimestamp(unsigned short Y, unsigned int D, unsigned long M):
43  Year(Y), Days(D), Milliseconds(M)
44  {}
45 
46  friend ostream &operator<<(ostream &stream, CGDTimestamp ts)
47  {
48  stream << ts.Year << "-";
49  stream << ts.Days << "-";
50  stream << ts.Milliseconds;
51 
52  return stream;
53  }
54 };
55 
56 #endif