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