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