1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
1 |
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
|
2 |
*
|
|
3 |
* PrimeBase Media Stream for MySQL
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
8 |
* (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
18 |
*
|
19 |
* Original author: Paul McCullagh (H&G2JCtL)
|
|
20 |
* Continued development: Barry Leslie
|
|
21 |
*
|
|
22 |
* 2007-05-20
|
|
23 |
*
|
|
24 |
* Represents a time value from the database.
|
|
25 |
*
|
|
26 |
* NOTE: All times in the database are based on UTC
|
|
27 |
* (Universal Coordinated Time)!
|
|
28 |
*
|
|
29 |
*/
|
|
30 |
||
31 |
#ifndef __DBTIME_H__
|
|
32 |
#define __DBTIME_H__
|
|
33 |
||
34 |
#include <time.h> |
|
35 |
||
36 |
#include "CSDefs.h" |
|
37 |
#include "CSObject.h" |
|
38 |
||
39 |
using namespace std; |
|
40 |
||
41 |
class CSTime : public CSObject { |
|
42 |
public: |
|
43 |
CSTime(): iIsNull(true) { } |
|
44 |
CSTime(s_int year, s_int mon, s_int day, s_int hour, s_int min, s_int sec, s_int nsec); |
|
45 |
virtual ~CSTime() { } |
|
46 |
||
47 |
bool isNull(); |
|
48 |
||
49 |
void setNull(); |
|
50 |
||
51 |
/*
|
|
52 |
* Set the time. The value given is a local time
|
|
53 |
* sec - seconds (0 - 60)
|
|
54 |
* min - minutes (0 - 59)
|
|
55 |
* hour - hours (0 - 23)
|
|
56 |
* day - day of month (1 - 31)
|
|
57 |
* mon - month of year (1 - 12)
|
|
58 |
* year - where year >= 1970 (on UNIX)
|
|
59 |
*/
|
|
60 |
void setLocal(s_int year, s_int mon, s_int day, s_int hour, s_int min, s_int sec, s_int nsec); |
|
61 |
||
62 |
/* Get the local time. */
|
|
63 |
void getLocal(s_int& year, s_int& mon, s_int& day, s_int& hour, s_int& min, s_int& sec, s_int& nsec); |
|
64 |
||
65 |
/* Set the s_int time. */
|
|
66 |
void setUTC(s_int year, s_int mon, s_int day, s_int hour, s_int min, s_int sec, s_int nsec); |
|
67 |
||
68 |
/* Get the universal time. */
|
|
69 |
void getUTC(s_int& year, s_int& mon, s_int& day, s_int& hour, s_int& min, s_int& sec, s_int& nsec); |
|
70 |
||
71 |
/*
|
|
72 |
* Returns the time as a string in the local time
|
|
73 |
* (time zone adjusted).
|
|
74 |
*/
|
|
75 |
char *getCString(); |
|
76 |
||
77 |
/*
|
|
78 |
* As above, but using the given format.
|
|
79 |
*/
|
|
80 |
char *getCString(const char *format); |
|
81 |
||
82 |
/* Set the time given a value in seconds and nanoseconds in UTC since 1970.
|
|
83 |
* Used by UNIX.
|
|
84 |
*/
|
|
85 |
void setUTC1970(time_t sec, s_int nsec); |
|
86 |
void getUTC1970(time_t& sec, s_int& nsec); |
|
87 |
||
88 |
/* Set the time given a 100 nanosecond value in UTC since 1601.
|
|
89 |
* Used by Windows.
|
|
90 |
*/
|
|
91 |
void setUTC1601(uint64_t nsec100); |
|
92 |
uint64_t getUTC1601(); |
|
93 |
||
94 |
private: |
|
95 |
bool iIsNull; |
|
96 |
char iCString[100]; |
|
97 |
||
98 |
/* The time based on UTC (GMT): */
|
|
99 |
s_int iYear; |
|
100 |
s_int iMonth; |
|
101 |
s_int iDay; |
|
102 |
s_int iHours; |
|
103 |
s_int iMinutes; |
|
104 |
s_int iSeconds; |
|
105 |
s_int iNanoSeconds; /* Plus this number of nano seconds. */ |
|
106 |
||
107 |
uint64_t get1970as1601(); |
|
108 |
};
|
|
109 |
||
110 |
#endif
|