~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/temporal.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 * their single parameter.
35
35
 */
36
36
 
37
 
#include <config.h>
 
37
#include "config.h"
38
38
 
39
 
#include <drizzled/charset_info.h>
40
 
#include <drizzled/type/decimal.h>
41
 
#include <drizzled/calendar.h>
42
 
#include <drizzled/temporal.h>
43
 
#include <drizzled/temporal_format.h>
44
 
#include <drizzled/time_functions.h>
 
39
#include "drizzled/charset_info.h"
 
40
#include "drizzled/type/decimal.h"
 
41
#include "drizzled/calendar.h"
 
42
#include "drizzled/temporal.h"
 
43
#include "drizzled/temporal_format.h"
 
44
#include "drizzled/time_functions.h"
45
45
#include "time.h"
46
46
 
47
47
#include <drizzled/util/gmtime.h>
1418
1418
bool Date::is_valid() const
1419
1419
{
1420
1420
  return (_years >= DRIZZLE_MIN_YEARS_SQL && _years <= DRIZZLE_MAX_YEARS_SQL)
1421
 
      && (_months >= 1 && _months <= DRIZZLE_MAX_MONTHS)
 
1421
      && (_months >= 1 && _months <= 12)
1422
1422
      && (_days >= 1 && _days <= days_in_gregorian_year_month(_years, _months));
1423
1423
}
1424
1424
 
1427
1427
  return (_years == 0)
1428
1428
      && (_months == 0)
1429
1429
      && (_days == 0)
1430
 
      && (_hours <= DRIZZLE_MAX_HOURS)
1431
 
      && (_minutes <= DRIZZLE_MAX_MINUTES)
1432
 
      && (_seconds <= DRIZZLE_MAX_SECONDS); /* No Leap second... TIME is for elapsed time... */
 
1430
      && (_hours <= 23)
 
1431
      && (_minutes <= 59)
 
1432
      && (_seconds <= 59); /* No Leap second... TIME is for elapsed time... */
1433
1433
}
1434
1434
 
1435
1435
bool Time::is_fuzzy_valid() const
1438
1438
    return true;
1439
1439
 
1440
1440
  return (_years >= DRIZZLE_MIN_YEARS_SQL && _years <= DRIZZLE_MAX_YEARS_SQL)
1441
 
      && (_months >= 1 && _months <= DRIZZLE_MAX_MONTHS)
 
1441
      && (_months >= 1 && _months <= 12)
1442
1442
      && (_days >= 1 && _days <= days_in_gregorian_year_month(_years, _months))
1443
 
      && (_hours <= DRIZZLE_MAX_HOURS)
1444
 
      && (_minutes <= DRIZZLE_MAX_MINUTES)
1445
 
      && (_seconds <= DRIZZLE_MAX_SECONDS); /* No Leap second... TIME is for elapsed time... */
 
1443
      && (_hours <= 23)
 
1444
      && (_minutes <= 59)
 
1445
      && (_seconds <= 59); /* No Leap second... TIME is for elapsed time... */
1446
1446
}
1447
1447
 
1448
1448
bool DateTime::is_valid() const
1449
1449
{
1450
1450
  return (_years >= DRIZZLE_MIN_YEARS_SQL && _years <= DRIZZLE_MAX_YEARS_SQL)
1451
 
      && (_months >= 1 && _months <= DRIZZLE_MAX_MONTHS)
 
1451
      && (_months >= 1 && _months <= 12)
1452
1452
      && (_days >= 1 && _days <= days_in_gregorian_year_month(_years, _months))
1453
 
      && (_hours <= DRIZZLE_MAX_HOURS)
1454
 
      && (_minutes <= DRIZZLE_MAX_MINUTES)
1455
 
      && (_seconds <= DRIZZLE_MAX_SECONDS_WITH_LEAP); /* Leap second... */
 
1453
      && (_hours <= 23)
 
1454
      && (_minutes <= 59)
 
1455
      && (_seconds <= 61); /* Leap second... */
1456
1456
}
1457
1457
 
1458
1458
bool Timestamp::is_valid() const
1459
1459
{
1460
 
  return DateTime::is_valid()
 
1460
  return DateTime::is_valid() 
1461
1461
      && in_unix_epoch_range(_years, _months, _days, _hours, _minutes, _seconds)
1462
 
      && (_seconds <= DRIZZLE_MAX_SECONDS);
 
1462
      && (_seconds <= 59);
1463
1463
}
1464
1464
 
1465
1465
bool MicroTimestamp::is_valid() const