~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/temporal.h

  • Committer: Joe Daly
  • Date: 2010-05-21 02:16:56 UTC
  • mto: This revision was merged to the branch mainline in revision 1555.
  • Revision ID: skinny.moey@gmail.com-20100521021656-bx6piitfh77jnl28
add statistics_variables.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008-2009 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
43
43
#define DRIZZLED_TEMPORAL_H
44
44
 
45
45
#define DRIZZLE_MAX_SECONDS 59
46
 
#define DRIZZLE_MAX_SECONDS_WITH_LEAP 61
47
46
#define DRIZZLE_MAX_MINUTES 59
48
47
#define DRIZZLE_MAX_HOURS 23
49
48
#define DRIZZLE_MAX_DAYS 31
67
66
 
68
67
#define DRIZZLE_YY_PART_YEAR  70
69
68
 
70
 
#include <drizzled/calendar.h>
 
69
#include "drizzled/calendar.h"
71
70
 
72
71
#include <cassert>
73
72
#include <ostream>
74
73
 
75
74
/* Outside forward declarations */
76
 
namespace type {
77
 
class Decimal;
78
 
}
 
75
class my_decimal;
79
76
 
80
77
namespace drizzled
81
78
{
288
285
 
289
286
 
290
287
  /**
 
288
   * Operator overload for adding/subtracting a TemporalInterval
 
289
   * instance to this temporal.
 
290
   *
 
291
   * @param TemporalInterval instance to add/subtract to/from
 
292
   */
 
293
  Date& operator+=(const TemporalIntervalYear &rhs);
 
294
  Date& operator+=(const TemporalIntervalDayOrLess &rhs);
 
295
  Date& operator+=(const TemporalIntervalDayOrWeek &rhs);
 
296
  Date& operator+=(const TemporalIntervalYearMonth &rhs);
 
297
  Date& operator-=(const TemporalIntervalYear &rhs);
 
298
  Date& operator-=(const TemporalIntervalDayOrLess &rhs);
 
299
  Date& operator-=(const TemporalIntervalDayOrWeek &rhs);
 
300
  Date& operator-=(const TemporalIntervalYearMonth &rhs);
 
301
 
 
302
 
 
303
  /**
291
304
   * Operator overload for when a DateTime instance is
292
305
   * assigned to a Date.  We do a copy of the DateTime's
293
306
   * date-related components.
316
329
   *
317
330
   * @param C-String to fill.
318
331
   * @param Length of to C-String
319
 
   * @returns length of string written (including trailing '\0').
 
332
   * @returns length of string written (not including trailing '\0').
320
333
   *          If output was truncated, returns length that would have
321
334
   *          been outputted.
322
335
   */
336
349
   * successful.
337
350
   *
338
351
   * @param String to convert from
339
 
   * @param Length of supplied string (not including trailing '\0').
 
352
   * @param Length of supplied string
340
353
   */
341
354
  virtual bool from_string(const char *from, size_t from_len);
342
355
 
422
435
   *
423
436
   * @param Pointer to a time_t to convert to
424
437
   */
425
 
  virtual void to_time_t(time_t &to) const;
 
438
  virtual void to_time_t(time_t *to) const;
426
439
 
427
440
  /**
428
441
   * Attempts to populate the Date instance based
436
449
  virtual bool from_time_t(const time_t from);
437
450
 
438
451
  /**
439
 
   * Fills a supplied type::Decimal with a representation of
 
452
   * Fills a supplied my_decimal with a representation of
440
453
   * the Date value.
441
454
   *
442
 
   * @param Pointer to the type::Decimal to fill
 
455
   * @param Pointer to the my_decimal to fill
443
456
   */
444
 
  virtual void to_decimal(type::Decimal *to) const;
 
457
  virtual void to_decimal(my_decimal *to) const;
445
458
 
446
459
  friend class TemporalInterval;
447
460
  friend class Timestamp;
488
501
  bool is_valid_datetime() const {return false;}
489
502
  bool is_valid_time() const {return is_valid();}
490
503
  bool is_valid_timestamp() const {return false;}
491
 
 
492
504
  /** Returns whether the temporal value is valid date. */
493
505
  bool is_valid() const;
494
 
  bool is_fuzzy_valid() const;
495
506
 
496
507
  /**
497
508
   * Fills a supplied char string with a
535
546
  void to_int32_t(int32_t *to) const;
536
547
 
537
548
  /**
538
 
   * Fills a supplied 8-byte integer pointer with an
539
 
   * integer representation of the Time
540
 
   * value. It is assume seconds past unix epoch
541
 
   *
542
 
   * @param Integer to fill.
543
 
   */
544
 
  void to_uint64_t(uint64_t &to) const;
545
 
 
546
 
  /**
547
549
   * Attempts to populate the Time instance based
548
550
   * on the contents of a supplied 4-byte integer.
549
551
   *
571
573
  bool from_time_t(const time_t from);
572
574
 
573
575
  /**
574
 
   * Fills a supplied type::Decimal with a representation of
 
576
   * Fills a supplied my_decimal with a representation of
575
577
   * the Time value.
576
578
   *
577
 
   * @param Pointer to the type::Decimal to fill
 
579
   * @param Pointer to the my_decimal to fill
578
580
   */
579
 
  void to_decimal(type::Decimal *to) const;
 
581
  void to_decimal(my_decimal *to) const;
580
582
 
581
583
  friend class Date;
582
584
  friend class DateTime;
657
659
   * @param time_t to convert from
658
660
   */
659
661
  bool from_time_t(const time_t from);
660
 
  bool from_timeval(struct timeval &_timeval);
661
662
 
662
663
  /**
663
664
   * Attempts to populate the DateTime instance based
686
687
  void to_tm(struct tm *to) const;
687
688
 
688
689
  /**
689
 
   * Fills a supplied type::Decimal with a representation of
 
690
   * Fills a supplied my_decimal with a representation of
690
691
   * the DateTime value.
691
692
   *
692
 
   * @param Pointer to the type::Decimal to fill
 
693
   * @param Pointer to the my_decimal to fill
693
694
   */
694
 
  void to_decimal(type::Decimal *to) const;
 
695
  void to_decimal(my_decimal *to) const;
695
696
 
696
697
  friend class Timestamp;
697
698
};
753
754
   *
754
755
   * @param Pointer to a time_t to convert to
755
756
   */
756
 
  void to_time_t(time_t &to) const;
 
757
  void to_time_t(time_t *to) const;
757
758
};
758
759
 
759
760
/**
801
802
   *
802
803
   * @param timeval to fill.
803
804
   */
804
 
  void to_timeval(struct timeval &to) const;
 
805
  void to_timeval(struct timeval *to) const;
805
806
};
806
807
 
807
808
/**