~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/cslib/CSTime.h

  • Committer: Brian Aker
  • Date: 2009-10-15 00:22:33 UTC
  • mto: (1183.1.11 merge)
  • mto: This revision was merged to the branch mainline in revision 1198.
  • Revision ID: brian@gaz-20091015002233-fa4ao2mbc67wls91
First pass of information engine. OMG, ponies... is it so much easier to
deal with creating and engine.

The list table iterator though... its ass, needs to go. We should also
abstract out share. Very few engines need a custom one. Just say'in

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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
 
class CSTime : public CSObject  {
40
 
public:
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);
43
 
        virtual ~CSTime() { }
44
 
 
45
 
        bool isNull();
46
 
        
47
 
        void setNull();
48
 
 
49
 
        /*
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)
57
 
         */
58
 
        void setLocal(s_int year, s_int mon, s_int day, s_int hour, s_int min, s_int sec, s_int nsec);
59
 
 
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);
62
 
 
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);
65
 
 
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);
68
 
 
69
 
        /*
70
 
         * Returns the time as a string in the local time 
71
 
         * (time zone adjusted).
72
 
         */
73
 
        char *getCString();
74
 
 
75
 
        /*
76
 
         * As above, but using the given format.
77
 
         */
78
 
        char *getCString(const char *format);
79
 
 
80
 
        /* Set the time given a value in seconds and nanoseconds in UTC since 1970.
81
 
         * Used by UNIX.
82
 
         */
83
 
        void setUTC1970(time_t sec, s_int nsec);
84
 
        void getUTC1970(time_t& sec, s_int& nsec);
85
 
 
86
 
        /* Set the time given a 100 nanosecond value in UTC since 1601.
87
 
         * Used by Windows.
88
 
         */
89
 
        void setUTC1601(uint64_t nsec100);
90
 
        uint64_t getUTC1601();
91
 
 
92
 
        /* 
93
 
         * Tests if the time is more than 'max_age' seconds in the past.
94
 
         */
95
 
        bool olderThen(time_t max_age);
96
 
 
97
 
        static  uint64_t getTimeCurrentTicks();
98
 
private:
99
 
        bool    iIsNull;
100
 
        char    iCString[100];
101
 
 
102
 
        /* The time based on UTC (GMT): */
103
 
        s_int   iYear;
104
 
        s_int   iMonth;
105
 
        s_int   iDay;
106
 
        s_int   iHours;
107
 
        s_int   iMinutes;
108
 
        s_int   iSeconds;
109
 
        s_int   iNanoSeconds;           /* Plus this number of nano seconds. */
110
 
 
111
 
        uint64_t get1970as1601();
112
 
};
113
 
 
114
 
#endif