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)!
40
class CSTime : public CSObject {
42
CSTime(): iIsNull(true) { }
43
CSTime(s_int year, s_int mon, s_int day, s_int hour, s_int min, s_int sec, s_int nsec);
51
* Set the time. The value given is a local time
52
* sec - seconds (0 - 60)
53
* min - minutes (0 - 59)
54
* hour - hours (0 - 23)
55
* day - day of month (1 - 31)
56
* mon - month of year (1 - 12)
57
* year - where year >= 1970 (on UNIX)
59
void setLocal(s_int year, s_int mon, s_int day, s_int hour, s_int min, s_int sec, s_int nsec);
61
/* Get the local time. */
62
void getLocal(s_int& year, s_int& mon, s_int& day, s_int& hour, s_int& min, s_int& sec, s_int& nsec);
64
/* Set the s_int time. */
65
void setUTC(s_int year, s_int mon, s_int day, s_int hour, s_int min, s_int sec, s_int nsec);
67
/* Get the universal time. */
68
void getUTC(s_int& year, s_int& mon, s_int& day, s_int& hour, s_int& min, s_int& sec, s_int& nsec);
71
* Returns the time as a string in the local time
72
* (time zone adjusted).
77
* As above, but using the given format.
79
char *getCString(const char *format);
81
/* Set the time given a value in seconds and nanoseconds in UTC since 1970.
84
void setUTC1970(time_t sec, s_int nsec);
85
void getUTC1970(time_t& sec, s_int& nsec);
87
/* Set the time given a 100 nanosecond value in UTC since 1601.
90
void setUTC1601(uint64_t nsec100);
91
uint64_t getUTC1601();
94
* Tests if the time is more than 'max_age' seconds in the past.
96
bool olderThen(time_t max_age);
98
static uint64_t getTimeCurrentTicks();
103
/* The time based on UTC (GMT): */
110
s_int iNanoSeconds; /* Plus this number of nano seconds. */
112
uint64_t get1970as1601();