1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
3
* PrimeBase Media Stream for MySQL
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.
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.
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
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
* Original author: Paul McCullagh (H&G2JCtL)
20
* Continued development: Barry Leslie
24
* Represents a time value from the database.
26
* NOTE: All times in the database are based on UTC
27
* (Universal Coordinated Time)!
39
class CSTime : public CSObject {
41
CSTime(): iIsNull(true) { }
42
CSTime(s_int year, s_int mon, s_int day, s_int hour, s_int min, s_int sec, s_int nsec);
50
* Set the time. The value given is a local time
51
* sec - seconds (0 - 60)
52
* min - minutes (0 - 59)
53
* hour - hours (0 - 23)
54
* day - day of month (1 - 31)
55
* mon - month of year (1 - 12)
56
* year - where year >= 1970 (on UNIX)
58
void setLocal(s_int year, s_int mon, s_int day, s_int hour, s_int min, s_int sec, s_int nsec);
60
/* Get the local time. */
61
void getLocal(s_int& year, s_int& mon, s_int& day, s_int& hour, s_int& min, s_int& sec, s_int& nsec);
63
/* Set the s_int time. */
64
void setUTC(s_int year, s_int mon, s_int day, s_int hour, s_int min, s_int sec, s_int nsec);
66
/* Get the universal time. */
67
void getUTC(s_int& year, s_int& mon, s_int& day, s_int& hour, s_int& min, s_int& sec, s_int& nsec);
70
* Returns the time as a string in the local time
71
* (time zone adjusted).
76
* As above, but using the given format.
78
char *getCString(const char *format);
80
/* Set the time given a value in seconds and nanoseconds in UTC since 1970.
83
void setUTC1970(time_t sec, s_int nsec);
84
void getUTC1970(time_t& sec, s_int& nsec);
86
/* Set the time given a 100 nanosecond value in UTC since 1601.
89
void setUTC1601(uint64_t nsec100);
90
uint64_t getUTC1601();
93
* Tests if the time is more than 'max_age' seconds in the past.
95
bool olderThen(time_t max_age);
97
static uint64_t getTimeCurrentTicks();
102
/* The time based on UTC (GMT): */
109
s_int iNanoSeconds; /* Plus this number of nano seconds. */
111
uint64_t get1970as1601();