813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
1 |
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008-2009 Sun Microsystems, Inc.
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; either version 2 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
*/
|
|
20 |
||
21 |
/**
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
22 |
* @file
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
23 |
*
|
24 |
* Defines the API for dealing with temporal data inside the server.
|
|
25 |
*
|
|
26 |
* The Temporal class is the base class for all data of any temporal
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
27 |
* type. A number of derived classes define specialized classes
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
28 |
* representng various date, date-time, time, or timestamp types.
|
29 |
*
|
|
30 |
* All Temporal derived classes are ValueObjects. That is to say that
|
|
31 |
* Temporal class instances are not part of the Item hierarchy and serve
|
|
32 |
* <em>only</em> to represent a time or date-related piece of data.
|
|
33 |
*
|
|
34 |
* @note
|
|
35 |
*
|
|
36 |
* Low-level calendrical calculations are done via routines in the
|
|
37 |
* calendar.cc file.
|
|
38 |
*
|
|
39 |
* @see drizzled/calendar.cc
|
|
40 |
*/
|
|
41 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
42 |
#pragma once
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
43 |
|
44 |
#define DRIZZLE_MAX_SECONDS 59
|
|
2168.2.17
by Stewart Smith
actually use some of the constants in temporal.h for MAX minutes/seconds et al (including leap seconds) in temporal.cc |
45 |
#define DRIZZLE_MAX_SECONDS_WITH_LEAP 61
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
46 |
#define DRIZZLE_MAX_MINUTES 59
|
47 |
#define DRIZZLE_MAX_HOURS 23
|
|
48 |
#define DRIZZLE_MAX_DAYS 31
|
|
49 |
#define DRIZZLE_MAX_MONTHS 12
|
|
50 |
#define DRIZZLE_MAX_YEARS_SQL 9999
|
|
51 |
#define DRIZZLE_MAX_YEARS_EPOCH 2038
|
|
52 |
#define DRIZZLE_MIN_SECONDS 0
|
|
53 |
#define DRIZZLE_MIN_MINUTES 0
|
|
54 |
#define DRIZZLE_MIN_HOURS 0
|
|
55 |
#define DRIZZLE_MIN_DAYS 1
|
|
56 |
#define DRIZZLE_MIN_MONTHS 1
|
|
57 |
#define DRIZZLE_MIN_YEARS_SQL 1
|
|
58 |
#define DRIZZLE_MIN_YEARS_EPOCH 1970
|
|
59 |
||
60 |
#define DRIZZLE_SECONDS_IN_MINUTE 60
|
|
61 |
#define DRIZZLE_SECONDS_IN_HOUR (60*60)
|
|
62 |
#define DRIZZLE_SECONDS_IN_DAY (60*60*24)
|
|
63 |
#define DRIZZLE_NANOSECONDS_IN_MICROSECOND 1000
|
|
64 |
||
813.1.12
by Jay Pipes
Fixes for SECOND() function to use new Temporal system. Because |
65 |
#define DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING 40
|
66 |
||
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
67 |
#define DRIZZLE_YY_PART_YEAR 70
|
68 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
69 |
#include <drizzled/calendar.h> |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
70 |
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
71 |
#include <cassert> |
907.1.7
by Jay Pipes
Merged in remove-timezone work |
72 |
#include <ostream> |
73 |
||
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
74 |
/* Outside forward declarations */
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
75 |
namespace type { |
76 |
class Decimal; |
|
77 |
}
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
78 |
|
892.2.8
by Monty Taylor
Whitespace fixes. |
79 |
namespace drizzled |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
80 |
{
|
81 |
||
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
82 |
/* Forward declaration needed */
|
83 |
class TemporalInterval; |
|
84 |
class TemporalIntervalYear; |
|
85 |
class TemporalIntervalDayOrLess; |
|
86 |
class TemporalIntervalDayOrWeek; |
|
87 |
class TemporalIntervalYearMonth; |
|
88 |
||
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
89 |
/**
|
90 |
* Base class for all temporal data classes.
|
|
91 |
*/
|
|
92 |
class Temporal |
|
93 |
{
|
|
94 |
protected: |
|
95 |
enum calendar _calendar; |
|
96 |
uint32_t _years; |
|
97 |
uint32_t _months; |
|
98 |
uint32_t _days; |
|
99 |
uint32_t _hours; |
|
100 |
uint32_t _minutes; |
|
101 |
uint32_t _seconds; |
|
102 |
time_t _epoch_seconds; |
|
103 |
uint32_t _useconds; |
|
104 |
uint32_t _nseconds; |
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
105 |
/** Set on some operator overloads. Indicates that an overflow occurred. */
|
106 |
bool _overflow; |
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
107 |
/** Returns number of seconds in time components (hour + minute + second) */
|
108 |
uint64_t _cumulative_seconds_in_time() const; |
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
109 |
/** Resets all temporal components to zero */
|
892.2.8
by Monty Taylor
Whitespace fixes. |
110 |
inline void _reset() |
111 |
{
|
|
112 |
_years= _months= _days= _hours= _minutes= |
|
113 |
_seconds= _epoch_seconds= _useconds= _nseconds= 0; |
|
114 |
}
|
|
115 |
||
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
116 |
public: |
117 |
Temporal(); |
|
118 |
virtual ~Temporal() {} |
|
119 |
||
120 |
/** Returns the calendar component. */
|
|
121 |
inline enum calendar calendar() const {return _calendar;} |
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
122 |
/** Sets the nseconds component. */
|
123 |
inline void set_nseconds(const uint32_t nsecond) {_nseconds= nsecond;} |
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
124 |
/** Returns the nanoseconds component. */
|
125 |
inline uint32_t nseconds() const {return _nseconds;} |
|
126 |
/** Sets the useconds component. */
|
|
127 |
inline void set_useconds(const uint32_t usecond) {_useconds= usecond;} |
|
128 |
/** Returns the microsseconds component. */
|
|
129 |
inline uint32_t useconds() const {return _useconds;} |
|
892.2.8
by Monty Taylor
Whitespace fixes. |
130 |
/**
|
131 |
* Sets the epoch_seconds component automatically,
|
|
132 |
* based on the temporal's components.
|
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
133 |
*/
|
873.1.6
by Jay Pipes
More shadowing fixes. Good buddy Solaris is fixing improper virtuality in subclasses. Nice. :) |
134 |
void set_epoch_seconds(); |
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
135 |
/** Sets the epch_seconds component manually. */
|
892.2.8
by Monty Taylor
Whitespace fixes. |
136 |
inline void set_epoch_seconds(const uint32_t epoch_second) |
137 |
{_epoch_seconds= epoch_second;} |
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
138 |
/** Returns the UNIX epoch seconds component. */
|
139 |
inline time_t epoch_seconds() const {return _epoch_seconds;} |
|
140 |
/** Sets the seconds component. */
|
|
141 |
inline void set_seconds(const uint32_t second) {_seconds= second;} |
|
142 |
/** Returns the seconds component. */
|
|
143 |
inline uint32_t seconds() const {return _seconds;} |
|
144 |
/** Sets the days component. */
|
|
145 |
inline void set_minutes(const uint32_t minute) {_minutes= minute;} |
|
146 |
/** Returns the minutes component. */
|
|
147 |
inline uint32_t minutes() const {return _minutes;} |
|
148 |
/** Sets the hours component. */
|
|
149 |
inline void set_hours(const uint32_t hour) {_hours= hour;} |
|
150 |
/** Returns the hours component. */
|
|
151 |
inline uint32_t hours() const {return _hours;} |
|
152 |
/** Sets the days component. */
|
|
153 |
inline void set_days(const uint32_t day) {_days= day;} |
|
154 |
/** Returns the days component. */
|
|
155 |
inline uint32_t days() const {return _days;} |
|
156 |
/** Sets the months component. */
|
|
157 |
inline void set_months(const uint32_t month) {_months= month;} |
|
158 |
/** Returns the months component. */
|
|
159 |
inline uint32_t months() const {return _months;} |
|
160 |
/** Sets the years component. */
|
|
161 |
inline void set_years(const uint32_t year) {_years= year;} |
|
162 |
/** Returns the years component. */
|
|
163 |
inline uint32_t years() const {return _years;} |
|
892.2.8
by Monty Taylor
Whitespace fixes. |
164 |
/** Returns whether the overflow flag was set
|
165 |
* (which can occur during an overloaded operator's execution) */
|
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
166 |
inline bool overflow() const {return _overflow;} |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
167 |
|
168 |
/** Returns whether the temporal value is valid as a date. */
|
|
169 |
virtual bool is_valid_date() const= 0; |
|
170 |
/** Returns whether the temporal value is valid as a datetime. */
|
|
171 |
virtual bool is_valid_datetime() const= 0; |
|
172 |
/** Returns whether the temporal value is valid as a time. */
|
|
173 |
virtual bool is_valid_time() const= 0; |
|
174 |
/** Returns whether the temporal value is valid as a UNIX timestamp. */
|
|
175 |
virtual bool is_valid_timestamp() const= 0; |
|
176 |
||
177 |
/**
|
|
178 |
* Returns whether the temporal
|
|
179 |
* value is valid. Each subclass defines what is
|
|
180 |
* valid for the range of temporal data it contains.
|
|
181 |
*/
|
|
182 |
virtual bool is_valid() const= 0; |
|
183 |
||
184 |
/**
|
|
185 |
* All Temporal derived classes must implement
|
|
186 |
* conversion routines for converting to and from
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
187 |
* a string. Subclasses implement other conversion
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
188 |
* routines, but should always follow these notes:
|
189 |
*
|
|
190 |
* 1) Ensure that ALL from_xxx methods call is_valid()
|
|
191 |
* 2) Ensure that ALL to_xxx methods are void returns and
|
|
192 |
* do not call is_valid()
|
|
193 |
*
|
|
194 |
* This minimizes the repeated bounds-checking to
|
|
195 |
* just the conversion from_xxx routines.
|
|
196 |
*/
|
|
197 |
friend class TemporalFormat; |
|
198 |
};
|
|
199 |
||
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
200 |
/* Forward declaration needed */
|
201 |
class DateTime; |
|
892.2.9
by Monty Taylor
Raped Jay's code. |
202 |
class Timestamp; |
892.2.10
by Monty Taylor
More raping of Jay's code. |
203 |
class Time; |
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
204 |
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
205 |
/**
|
206 |
* Class representing temporal components in a valid
|
|
207 |
* SQL date range, with no time component
|
|
208 |
*/
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
209 |
class Date: public Temporal |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
210 |
{
|
211 |
public: |
|
873.1.9
by Jay Pipes
This patch fixes the following functions to properly error out |
212 |
Date() :Temporal() {} |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
213 |
/**
|
214 |
* Comparison operator overloads to compare a Date against
|
|
215 |
* another Date value.
|
|
216 |
*
|
|
217 |
* @param Date to compare against.
|
|
218 |
*/
|
|
910.2.10
by Monty Taylor
Merged in jay's patch again. |
219 |
virtual bool operator==(const Date &rhs); |
220 |
virtual bool operator!=(const Date &rhs); |
|
221 |
virtual bool operator>(const Date &rhs); |
|
222 |
virtual bool operator>=(const Date &rhs); |
|
223 |
virtual bool operator<(const Date &rhs); |
|
224 |
virtual bool operator<=(const Date &rhs); |
|
892.2.9
by Monty Taylor
Raped Jay's code. |
225 |
|
226 |
/**
|
|
227 |
* Comparison operator overloads to compare a Date against
|
|
228 |
* a DateTime value.
|
|
229 |
*
|
|
230 |
* @param DateTime to compare against.
|
|
231 |
*/
|
|
910.2.10
by Monty Taylor
Merged in jay's patch again. |
232 |
virtual bool operator==(const DateTime &rhs); |
233 |
virtual bool operator!=(const DateTime &rhs); |
|
234 |
virtual bool operator>(const DateTime &rhs); |
|
235 |
virtual bool operator>=(const DateTime &rhs); |
|
236 |
virtual bool operator<(const DateTime &rhs); |
|
237 |
virtual bool operator<=(const DateTime &rhs); |
|
238 |
||
239 |
/**
|
|
240 |
* Comparison operator overloads to compare this against
|
|
241 |
* a Timestamp value.
|
|
242 |
*
|
|
243 |
* @param Timestamp to compare against.
|
|
244 |
*/
|
|
245 |
virtual bool operator==(const Timestamp &rhs); |
|
246 |
virtual bool operator!=(const Timestamp &rhs); |
|
247 |
virtual bool operator>(const Timestamp &rhs); |
|
248 |
virtual bool operator>=(const Timestamp &rhs); |
|
249 |
virtual bool operator<(const Timestamp &rhs); |
|
250 |
virtual bool operator<=(const Timestamp &rhs); |
|
892.2.9
by Monty Taylor
Raped Jay's code. |
251 |
|
252 |
/**
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
253 |
* Operator overload for adding/subtracting another Date
|
892.2.8
by Monty Taylor
Whitespace fixes. |
254 |
* (or subclass) to/from this temporal. When subtracting
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
255 |
* or adding two Dates, we return a new Date instance.
|
256 |
*
|
|
892.2.9
by Monty Taylor
Raped Jay's code. |
257 |
* @param Date instance to add/subtract to/from
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
258 |
*/
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
259 |
const Date operator-(const Date &rhs); |
260 |
const Date operator+(const Date &rhs); |
|
261 |
Date& operator+=(const Date &rhs); |
|
262 |
Date& operator-=(const Date &rhs); |
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
263 |
|
892.2.10
by Monty Taylor
More raping of Jay's code. |
264 |
/**
|
265 |
* Operator to add/subtract a Time from a Time.
|
|
266 |
* We can return a Time new temporal instance.
|
|
267 |
*
|
|
268 |
* @param Temporal instance to add/subtract to/from
|
|
269 |
*/
|
|
270 |
const Date operator-(const Time &rhs); |
|
271 |
const Date operator+(const Time &rhs); |
|
272 |
Date& operator-=(const Time &rhs); |
|
273 |
Date& operator+=(const Time &rhs); |
|
274 |
||
892.2.9
by Monty Taylor
Raped Jay's code. |
275 |
|
276 |
/**
|
|
277 |
* Operator overload for adding/subtracting a DateTime
|
|
278 |
* (or subclass) to/from this temporal. When subtracting
|
|
279 |
* or adding two Dates, we return a new Date instance.
|
|
280 |
*
|
|
281 |
* @param DateTime instance to add/subtract to/from
|
|
282 |
*/
|
|
283 |
const Date operator-(const DateTime &rhs); |
|
284 |
const Date operator+(const DateTime &rhs); |
|
285 |
Date& operator+=(const DateTime &rhs); |
|
286 |
Date& operator-=(const DateTime &rhs); |
|
287 |
||
892.2.11
by Monty Taylor
One more temporal hack. |
288 |
|
289 |
/**
|
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
290 |
* Operator overload for when a DateTime instance is
|
291 |
* assigned to a Date. We do a copy of the DateTime's
|
|
292 |
* date-related components.
|
|
293 |
*
|
|
294 |
* @param The DateTime to copy from
|
|
295 |
*/
|
|
296 |
Date& operator=(const DateTime &rhs); |
|
297 |
||
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
298 |
virtual bool is_valid_date() const {return is_valid();} |
299 |
virtual bool is_valid_datetime() const {return is_valid();} |
|
300 |
virtual bool is_valid_time() const {return false;} |
|
892.2.8
by Monty Taylor
Whitespace fixes. |
301 |
virtual bool is_valid_timestamp() const |
302 |
{
|
|
303 |
return is_valid() && in_unix_epoch(); |
|
304 |
}
|
|
305 |
||
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
306 |
/** Returns whether the temporal value is valid date. */
|
307 |
virtual bool is_valid() const; |
|
308 |
/* Returns whether the Date (or subclass) instance is in the Unix Epoch. */
|
|
309 |
virtual bool in_unix_epoch() const; |
|
310 |
||
311 |
/**
|
|
312 |
* Fills a supplied char string with a
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
313 |
* string representation of the Date
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
314 |
* value.
|
315 |
*
|
|
316 |
* @param C-String to fill.
|
|
1079.3.1
by Stewart Smith
Change temporal to_string routines to use snprintf instead of sprintf. |
317 |
* @param Length of to C-String
|
1377.8.25
by Paweł Blokus
this was the first working build, and these changes make almost all the tests pass |
318 |
* @returns length of string written (including trailing '\0').
|
1079.3.1
by Stewart Smith
Change temporal to_string routines to use snprintf instead of sprintf. |
319 |
* If output was truncated, returns length that would have
|
320 |
* been outputted.
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
321 |
*/
|
1079.3.1
by Stewart Smith
Change temporal to_string routines to use snprintf instead of sprintf. |
322 |
virtual int to_string(char *to, size_t to_len) const; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
323 |
|
324 |
/**
|
|
1079.3.2
by Stewart Smith
Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types. |
325 |
* Maximum length of C-String needed to represent type
|
326 |
* (including '\0').
|
|
327 |
*/
|
|
328 |
static const int MAX_STRING_LENGTH= 11; |
|
329 |
||
330 |
/**
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
331 |
* Attempts to populate the Date instance based
|
332 |
* on the contents of a supplied string.
|
|
333 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
334 |
* Returns whether the conversion was
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
335 |
* successful.
|
336 |
*
|
|
337 |
* @param String to convert from
|
|
1377.8.25
by Paweł Blokus
this was the first working build, and these changes make almost all the tests pass |
338 |
* @param Length of supplied string (not including trailing '\0').
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
339 |
*/
|
340 |
virtual bool from_string(const char *from, size_t from_len); |
|
341 |
||
342 |
/**
|
|
343 |
* Fills a supplied 8-byte integer pointer with an
|
|
344 |
* integer representation of the Date
|
|
345 |
* value.
|
|
346 |
*
|
|
347 |
* @param Integer to fill.
|
|
348 |
*/
|
|
349 |
virtual void to_int64_t(int64_t *to) const; |
|
350 |
||
351 |
/**
|
|
352 |
* Fills a supplied 4-byte integer pointer with an
|
|
353 |
* integer representation of the Date
|
|
354 |
* value.
|
|
355 |
*
|
|
356 |
* @param Integer to fill.
|
|
357 |
*/
|
|
358 |
virtual void to_int32_t(int32_t *to) const; |
|
359 |
||
360 |
/**
|
|
361 |
* Attempts to populate the Date instance based
|
|
362 |
* on the contents of a supplied 4-byte integer.
|
|
363 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
364 |
* Returns whether the conversion was
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
365 |
* successful.
|
366 |
*
|
|
367 |
* @param Integer to convert from
|
|
368 |
*/
|
|
369 |
virtual bool from_int32_t(const int32_t from); |
|
370 |
||
371 |
/**
|
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
372 |
* Fills a supplied int64_t with the Julian Day Number
|
373 |
* representation of this Date.
|
|
374 |
*
|
|
375 |
* @note Julian Day Number != julian day!
|
|
376 |
*
|
|
377 |
* Julian Day Number is the monotonically increasing number
|
|
378 |
* of days from the start of the Julian calendar (~4713 B.C.)
|
|
379 |
*
|
|
380 |
* julian day is the ordinal day number of a day in a year.
|
|
381 |
*
|
|
382 |
* @param int64_t to fill
|
|
383 |
*/
|
|
384 |
void to_julian_day_number(int64_t *to) const; |
|
385 |
||
386 |
/**
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
387 |
* Attempts to populate the Date instance based
|
388 |
* on the contents of a supplied Julian Day Number
|
|
389 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
390 |
* Returns whether the conversion was
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
391 |
* successful.
|
392 |
*
|
|
393 |
* @param Integer to convert from
|
|
394 |
*/
|
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
395 |
bool from_julian_day_number(const int64_t from); |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
396 |
|
397 |
/**
|
|
398 |
* Fills a supplied tm pointer with an
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
399 |
* representation of the Date
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
400 |
* value.
|
401 |
*
|
|
402 |
* @param tm to fill.
|
|
403 |
*/
|
|
404 |
virtual void to_tm(struct tm *to) const; |
|
405 |
||
406 |
/**
|
|
407 |
* Attempts to populate the Date instance based
|
|
408 |
* on the contents of a supplied pointer to struct tm
|
|
409 |
* (broken time).
|
|
410 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
411 |
* Returns whether the conversion was
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
412 |
* successful.
|
413 |
*
|
|
414 |
* @param Pointe rto the struct tm to convert from
|
|
415 |
*/
|
|
416 |
virtual bool from_tm(const struct tm *from); |
|
417 |
||
418 |
/**
|
|
419 |
* Attempts to convert the Date value into
|
|
420 |
* a supplied time_t.
|
|
421 |
*
|
|
422 |
* @param Pointer to a time_t to convert to
|
|
423 |
*/
|
|
2016.1.7
by Brian Aker
Remove MyISAM flip bit, and make sure that we only pass in a good time_t to |
424 |
virtual void to_time_t(time_t &to) const; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
425 |
|
426 |
/**
|
|
427 |
* Attempts to populate the Date instance based
|
|
428 |
* on the contents of a supplied time_t
|
|
429 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
430 |
* Returns whether the conversion was
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
431 |
* successful.
|
432 |
*
|
|
433 |
* @param time_t to convert from
|
|
434 |
*/
|
|
435 |
virtual bool from_time_t(const time_t from); |
|
436 |
||
437 |
/**
|
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
438 |
* Fills a supplied type::Decimal with a representation of
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
439 |
* the Date value.
|
440 |
*
|
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
441 |
* @param Pointer to the type::Decimal to fill
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
442 |
*/
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
443 |
virtual void to_decimal(type::Decimal *to) const; |
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
444 |
|
445 |
friend class TemporalInterval; |
|
910.2.10
by Monty Taylor
Merged in jay's patch again. |
446 |
friend class Timestamp; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
447 |
};
|
448 |
||
449 |
/* Forward declare needed for friendship */
|
|
450 |
class DateTime; |
|
451 |
||
452 |
/**
|
|
453 |
* Class representing temporal components having only
|
|
454 |
* a time component, with no date structure
|
|
455 |
*/
|
|
456 |
class Time: public Temporal |
|
457 |
{
|
|
458 |
public: |
|
873.1.9
by Jay Pipes
This patch fixes the following functions to properly error out |
459 |
Time() :Temporal() {} |
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
460 |
/* Maximum number of seconds in 23:59:59 (24 * 60 * 60) */
|
1240.9.5
by Monty Taylor
remark #82: storage class is not first |
461 |
static const uint32_t MAX_CUMULATIVE_SECONDS= 86400L; |
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
462 |
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
463 |
/**
|
464 |
* Comparison operator overloads to compare a Time against
|
|
465 |
* another Time value.
|
|
466 |
*
|
|
467 |
* @param Time to compare against.
|
|
468 |
*/
|
|
469 |
bool operator==(const Time &rhs); |
|
470 |
bool operator!=(const Time &rhs); |
|
471 |
bool operator>(const Time &rhs); |
|
472 |
bool operator>=(const Time &rhs); |
|
473 |
bool operator<(const Time &rhs); |
|
474 |
bool operator<=(const Time &rhs); |
|
475 |
/**
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
476 |
* Operator to add/subtract a Time from a Time.
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
477 |
* We can return a Time new temporal instance.
|
478 |
*
|
|
479 |
* @param Temporal instance to add/subtract to/from
|
|
480 |
*/
|
|
481 |
const Time operator-(const Time &rhs); |
|
482 |
const Time operator+(const Time &rhs); |
|
483 |
Time& operator-=(const Time &rhs); |
|
484 |
Time& operator+=(const Time &rhs); |
|
485 |
||
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
486 |
bool is_valid_date() const {return false;} |
487 |
bool is_valid_datetime() const {return false;} |
|
488 |
bool is_valid_time() const {return is_valid();} |
|
489 |
bool is_valid_timestamp() const {return false;} |
|
2020
by Brian Aker
This takes time and turns it into a fuzzy type so that we can do |
490 |
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
491 |
/** Returns whether the temporal value is valid date. */
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
492 |
bool is_valid() const; |
2020
by Brian Aker
This takes time and turns it into a fuzzy type so that we can do |
493 |
bool is_fuzzy_valid() const; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
494 |
|
495 |
/**
|
|
496 |
* Fills a supplied char string with a
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
497 |
* string representation of the Time
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
498 |
* value.
|
499 |
*
|
|
1079.3.1
by Stewart Smith
Change temporal to_string routines to use snprintf instead of sprintf. |
500 |
* @param C-String to fill
|
501 |
* @param Length of to C-String
|
|
502 |
* @returns length of string written (not including trailing '\0').
|
|
503 |
* If output was truncated, returns length that would have
|
|
504 |
* been outputted.
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
505 |
*/
|
1079.3.1
by Stewart Smith
Change temporal to_string routines to use snprintf instead of sprintf. |
506 |
int to_string(char *to, size_t to_len) const; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
507 |
|
508 |
/**
|
|
1079.3.2
by Stewart Smith
Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types. |
509 |
* Maximum length of C-String needed to represent type
|
510 |
* (including '\0').
|
|
511 |
*/
|
|
512 |
static const int MAX_STRING_LENGTH= 9; |
|
513 |
||
514 |
||
515 |
/**
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
516 |
* Attempts to populate the Time instance based
|
517 |
* on the contents of a supplied string.
|
|
518 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
519 |
* Returns whether the conversion was
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
520 |
* successful.
|
521 |
*
|
|
522 |
* @param String to convert from
|
|
523 |
* @param Length of supplied string
|
|
524 |
*/
|
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
525 |
bool from_string(const char *from, size_t from_len); |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
526 |
|
527 |
/**
|
|
528 |
* Fills a supplied 4-byte integer pointer with an
|
|
529 |
* integer representation of the Time
|
|
530 |
* value.
|
|
531 |
*
|
|
532 |
* @param Integer to fill.
|
|
533 |
*/
|
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
534 |
void to_int32_t(int32_t *to) const; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
535 |
|
536 |
/**
|
|
1999.4.7
by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time). |
537 |
* Fills a supplied 8-byte integer pointer with an
|
538 |
* integer representation of the Time
|
|
539 |
* value. It is assume seconds past unix epoch
|
|
540 |
*
|
|
541 |
* @param Integer to fill.
|
|
542 |
*/
|
|
543 |
void to_uint64_t(uint64_t &to) const; |
|
544 |
||
545 |
/**
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
546 |
* Attempts to populate the Time instance based
|
547 |
* on the contents of a supplied 4-byte integer.
|
|
548 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
549 |
* Returns whether the conversion was
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
550 |
* successful.
|
551 |
*
|
|
552 |
* @param Integer to convert from
|
|
553 |
*/
|
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
554 |
bool from_int32_t(const int32_t from); |
555 |
||
556 |
/**
|
|
557 |
* Attempts to populate the Time instance based
|
|
558 |
* on the contents of a supplied time_t
|
|
559 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
560 |
* Returns whether the conversion was
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
561 |
* successful.
|
562 |
*
|
|
563 |
* @note
|
|
564 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
565 |
* We can only convert *from* a time_t, not back
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
566 |
* to a time_t since it would be a lossy conversion.
|
567 |
*
|
|
568 |
* @param time_t to convert from
|
|
569 |
*/
|
|
570 |
bool from_time_t(const time_t from); |
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
571 |
|
572 |
/**
|
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
573 |
* Fills a supplied type::Decimal with a representation of
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
574 |
* the Time value.
|
575 |
*
|
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
576 |
* @param Pointer to the type::Decimal to fill
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
577 |
*/
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
578 |
void to_decimal(type::Decimal *to) const; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
579 |
|
892.2.10
by Monty Taylor
More raping of Jay's code. |
580 |
friend class Date; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
581 |
friend class DateTime; |
582 |
};
|
|
583 |
||
584 |
/**
|
|
585 |
* Class representing temporal components in a valid
|
|
586 |
* SQL datetime range, including a time component
|
|
587 |
*/
|
|
588 |
class DateTime: public Date |
|
589 |
{
|
|
590 |
public: |
|
873.1.9
by Jay Pipes
This patch fixes the following functions to properly error out |
591 |
DateTime() :Date() {} |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
592 |
|
873.1.4
by Jay Pipes
Solaris integer truncation fixes - Thanks to MontyT for the warning output.. :) |
593 |
friend class TemporalInterval; |
594 |
||
892.2.8
by Monty Taylor
Whitespace fixes. |
595 |
/** Returns whether the DateTime (or subclass) instance
|
596 |
* is in the Unix Epoch.
|
|
597 |
*/
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
598 |
bool in_unix_epoch() const; |
599 |
/** Returns whether the temporal value is valid datetime. */
|
|
600 |
virtual bool is_valid() const; |
|
601 |
||
602 |
/**
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
603 |
* It's not possible to convert to and from a DateTime and
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
604 |
* a 4-byte integer, so let us know if we try and do it!
|
605 |
*/
|
|
873.1.6
by Jay Pipes
More shadowing fixes. Good buddy Solaris is fixing improper virtuality in subclasses. Nice. :) |
606 |
void to_int32_t(int32_t *) const {assert(0);} |
607 |
bool from_int32_t(int32_t) {assert(0); return false;} |
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
608 |
|
609 |
/**
|
|
610 |
* Fills a supplied char string with a
|
|
611 |
* string representation of the DateTime
|
|
612 |
* value.
|
|
613 |
*
|
|
1079.3.1
by Stewart Smith
Change temporal to_string routines to use snprintf instead of sprintf. |
614 |
* @param C-String to fill
|
615 |
* @param Length of to C-String
|
|
616 |
* @returns length of string written (not including trailing '\0').
|
|
617 |
* If output was truncated, returns length that would have
|
|
618 |
* been outputted.
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
619 |
*/
|
1079.3.1
by Stewart Smith
Change temporal to_string routines to use snprintf instead of sprintf. |
620 |
virtual int to_string(char *to, size_t to_len) const; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
621 |
|
622 |
/**
|
|
1079.3.2
by Stewart Smith
Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types. |
623 |
* Maximum length of C-String needed to represent type
|
624 |
* (including '\0').
|
|
625 |
*/
|
|
626 |
static const int MAX_STRING_LENGTH= 27; |
|
627 |
||
628 |
/**
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
629 |
* Attempts to populate the DateTime instance based
|
630 |
* on the contents of a supplied string.
|
|
631 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
632 |
* Returns whether the conversion was
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
633 |
* successful.
|
634 |
*
|
|
635 |
* @param String to convert from
|
|
636 |
* @param Length of supplied string
|
|
637 |
*/
|
|
873.1.6
by Jay Pipes
More shadowing fixes. Good buddy Solaris is fixing improper virtuality in subclasses. Nice. :) |
638 |
bool from_string(const char *from, size_t from_len); |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
639 |
|
640 |
/**
|
|
641 |
* Fills a supplied 8-byte integer pointer with an
|
|
642 |
* integer representation of the DateTime
|
|
643 |
* value.
|
|
644 |
*
|
|
645 |
* @param Integer to fill.
|
|
646 |
*/
|
|
873.1.6
by Jay Pipes
More shadowing fixes. Good buddy Solaris is fixing improper virtuality in subclasses. Nice. :) |
647 |
void to_int64_t(int64_t *to) const; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
648 |
|
649 |
/**
|
|
650 |
* Attempts to populate the DateTime instance based
|
|
651 |
* on the contents of a supplied time_t
|
|
652 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
653 |
* Returns whether the conversion was
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
654 |
* successful.
|
655 |
*
|
|
656 |
* @param time_t to convert from
|
|
657 |
*/
|
|
873.1.6
by Jay Pipes
More shadowing fixes. Good buddy Solaris is fixing improper virtuality in subclasses. Nice. :) |
658 |
bool from_time_t(const time_t from); |
2046.2.3
by Brian Aker
Add basic tests for microtime. |
659 |
bool from_timeval(struct timeval &_timeval); |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
660 |
|
661 |
/**
|
|
662 |
* Attempts to populate the DateTime instance based
|
|
663 |
* on the contents of a supplied 8-byte integer.
|
|
664 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
665 |
* Returns whether the conversion was
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
666 |
* successful.
|
667 |
*
|
|
668 |
* @param Integer to convert from
|
|
1079.3.2
by Stewart Smith
Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types. |
669 |
* @param convert if conversion to canonical representation
|
670 |
* should be attempted
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
671 |
*/
|
1079.3.2
by Stewart Smith
Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types. |
672 |
bool from_int64_t(const int64_t from, bool convert); |
673 |
||
674 |
bool from_int64_t(const int64_t from) { |
|
675 |
return from_int64_t(from, true); |
|
676 |
}
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
677 |
|
678 |
/**
|
|
679 |
* Fills a supplied tm pointer with an
|
|
680 |
* representation of the DateTime
|
|
681 |
* value.
|
|
682 |
*
|
|
683 |
* @param tm to fill.
|
|
684 |
*/
|
|
873.1.6
by Jay Pipes
More shadowing fixes. Good buddy Solaris is fixing improper virtuality in subclasses. Nice. :) |
685 |
void to_tm(struct tm *to) const; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
686 |
|
687 |
/**
|
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
688 |
* Fills a supplied type::Decimal with a representation of
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
689 |
* the DateTime value.
|
690 |
*
|
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
691 |
* @param Pointer to the type::Decimal to fill
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
692 |
*/
|
2030.1.4
by Brian Aker
Change my_decimal to Decimal |
693 |
void to_decimal(type::Decimal *to) const; |
910.2.10
by Monty Taylor
Merged in jay's patch again. |
694 |
|
695 |
friend class Timestamp; |
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
696 |
};
|
697 |
||
698 |
/**
|
|
699 |
* Class representing temporal components in the UNIX epoch
|
|
700 |
*/
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
701 |
class Timestamp: public DateTime |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
702 |
{
|
703 |
public: |
|
873.1.9
by Jay Pipes
This patch fixes the following functions to properly error out |
704 |
Timestamp() :DateTime() {} |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
705 |
|
907.1.7
by Jay Pipes
Merged in remove-timezone work |
706 |
/**
|
707 |
* Comparison operator overloads to compare this against
|
|
910.2.10
by Monty Taylor
Merged in jay's patch again. |
708 |
* a Date value.
|
709 |
*
|
|
710 |
* @param Timestamp to compare against.
|
|
711 |
*/
|
|
712 |
bool operator==(const Date &rhs); |
|
713 |
bool operator!=(const Date &rhs); |
|
714 |
bool operator>(const Date &rhs); |
|
715 |
bool operator>=(const Date &rhs); |
|
716 |
bool operator<(const Date &rhs); |
|
717 |
bool operator<=(const Date &rhs); |
|
718 |
||
719 |
/**
|
|
720 |
* Comparison operator overloads to compare this against
|
|
721 |
* a DateTime value.
|
|
722 |
*
|
|
723 |
* @param DateTime to compare against.
|
|
724 |
*/
|
|
725 |
bool operator==(const DateTime &rhs); |
|
726 |
bool operator!=(const DateTime &rhs); |
|
727 |
bool operator>(const DateTime &rhs); |
|
728 |
bool operator>=(const DateTime &rhs); |
|
729 |
bool operator<(const DateTime &rhs); |
|
730 |
bool operator<=(const DateTime &rhs); |
|
731 |
||
732 |
/**
|
|
733 |
* Comparison operator overloads to compare this against
|
|
907.1.7
by Jay Pipes
Merged in remove-timezone work |
734 |
* another Timestamp value.
|
735 |
*
|
|
736 |
* @param Timestamp to compare against.
|
|
737 |
*/
|
|
738 |
bool operator==(const Timestamp &rhs); |
|
739 |
bool operator!=(const Timestamp &rhs); |
|
740 |
bool operator>(const Timestamp &rhs); |
|
741 |
bool operator>=(const Timestamp &rhs); |
|
742 |
bool operator<(const Timestamp &rhs); |
|
743 |
bool operator<=(const Timestamp &rhs); |
|
744 |
||
873.1.6
by Jay Pipes
More shadowing fixes. Good buddy Solaris is fixing improper virtuality in subclasses. Nice. :) |
745 |
bool is_valid_timestamp() const {return is_valid();} |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
746 |
/** Returns whether the temporal value is valid timestamp. */
|
747 |
virtual bool is_valid() const; |
|
748 |
||
749 |
/**
|
|
750 |
* Attempts to convert the Timestamp value into
|
|
751 |
* a supplied time_t.
|
|
752 |
*
|
|
753 |
* @param Pointer to a time_t to convert to
|
|
754 |
*/
|
|
2016.1.7
by Brian Aker
Remove MyISAM flip bit, and make sure that we only pass in a good time_t to |
755 |
void to_time_t(time_t &to) const; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
756 |
};
|
757 |
||
758 |
/**
|
|
907.1.7
by Jay Pipes
Merged in remove-timezone work |
759 |
* Operator overload to an output stream for a Timestamp.
|
760 |
*/
|
|
761 |
std::ostream& operator<<(std::ostream& os, const Timestamp& subject); |
|
762 |
||
763 |
/**
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
764 |
* Class representing temporal components in the UNIX epoch
|
765 |
* with an additional microsecond component.
|
|
766 |
*/
|
|
767 |
class MicroTimestamp: public Timestamp |
|
768 |
{
|
|
769 |
public: |
|
873.1.9
by Jay Pipes
This patch fixes the following functions to properly error out |
770 |
MicroTimestamp() :Timestamp() {} |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
771 |
/** Returns whether the temporal value is valid micro-timestamp. */
|
772 |
bool is_valid() const; |
|
773 |
||
774 |
/**
|
|
775 |
* Fills a supplied char string with a
|
|
776 |
* string representation of the MicroTimestamp
|
|
777 |
* value.
|
|
778 |
*
|
|
1079.3.1
by Stewart Smith
Change temporal to_string routines to use snprintf instead of sprintf. |
779 |
* @param C-String to fill
|
780 |
* @param Length of to C-String
|
|
781 |
* @returns length of string written (not including trailing '\0').
|
|
782 |
* If output was truncated, returns length that would have
|
|
783 |
* been outputted.
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
784 |
*/
|
1079.3.1
by Stewart Smith
Change temporal to_string routines to use snprintf instead of sprintf. |
785 |
int to_string(char *to, size_t to_len) const; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
786 |
|
787 |
/**
|
|
1079.3.2
by Stewart Smith
Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types. |
788 |
* Maximum length of C-String needed to represent type
|
789 |
* (including '\0').
|
|
790 |
*/
|
|
2057.2.2
by Brian Aker
Merge in fixes for microtimestamp, |
791 |
static const int MAX_STRING_LENGTH= 27; |
1079.3.2
by Stewart Smith
Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types. |
792 |
|
793 |
/**
|
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
794 |
* Fills a supplied timeval pointer with an
|
795 |
* representation of the MicroTimestamp
|
|
796 |
* value.
|
|
797 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
798 |
* Returns whether the conversion was
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
799 |
* successful.
|
800 |
*
|
|
801 |
* @param timeval to fill.
|
|
802 |
*/
|
|
2046.2.3
by Brian Aker
Add basic tests for microtime. |
803 |
void to_timeval(struct timeval &to) const; |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
804 |
};
|
805 |
||
806 |
/**
|
|
807 |
* Class representing temporal components in the UNIX epoch
|
|
808 |
* with an additional nanosecond component.
|
|
809 |
*/
|
|
810 |
class NanoTimestamp: public Timestamp |
|
811 |
{
|
|
812 |
public: |
|
873.1.9
by Jay Pipes
This patch fixes the following functions to properly error out |
813 |
NanoTimestamp() :Timestamp() {} |
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
814 |
/** Returns whether the temporal value is valid nano-timestamp. */
|
815 |
bool is_valid() const; |
|
816 |
||
817 |
/**
|
|
818 |
* Fills a supplied timespec pointer with an
|
|
819 |
* representation of the NanoTimestamp
|
|
820 |
* value.
|
|
821 |
*
|
|
892.2.8
by Monty Taylor
Whitespace fixes. |
822 |
* Returns whether the conversion was
|
813.1.2
by Jay Pipes
First function cleanup for temporal handling: YEAR() |
823 |
* successful.
|
824 |
*
|
|
825 |
* @param timespec to fill.
|
|
826 |
*/
|
|
827 |
void to_timespec(struct timespec *to) const; |
|
828 |
};
|
|
829 |
||
830 |
} /* end namespace drizzled */ |
|
831 |