~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/temporal.cc

  • Committer: Brian Aker
  • Date: 2010-12-22 19:01:50 UTC
  • Revision ID: brian@tangent.org-20101222190150-axj8ykxq9zv3x982
This takes time and turns it into a fuzzy type so that we can do
conversions. We ignore the other parts of it or other operations.

EXTRACT should be fixed so that this is not required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1025
1025
    current++;
1026
1026
  }
1027
1027
 
1028
 
  _years= 0;
1029
 
  _months= 0;
1030
 
  _days= 0;
1031
 
 
1032
1028
  if (not matched)
1033
1029
    return false;
1034
1030
 
1035
 
  return is_valid();
 
1031
  return is_fuzzy_valid();
1036
1032
}
1037
1033
 
1038
1034
int Time::to_string(char *to, size_t to_len) const
1406
1402
      && (_seconds <= 59); /* No Leap second... TIME is for elapsed time... */
1407
1403
}
1408
1404
 
 
1405
bool Time::is_fuzzy_valid() const
 
1406
{
 
1407
  if (is_valid())
 
1408
    return true;
 
1409
 
 
1410
  return (_years >= DRIZZLE_MIN_YEARS_SQL && _years <= DRIZZLE_MAX_YEARS_SQL)
 
1411
      && (_months >= 1 && _months <= 12)
 
1412
      && (_days >= 1 && _days <= days_in_gregorian_year_month(_years, _months))
 
1413
      && (_hours <= 23)
 
1414
      && (_minutes <= 59)
 
1415
      && (_seconds <= 59); /* No Leap second... TIME is for elapsed time... */
 
1416
}
 
1417
 
1409
1418
bool DateTime::is_valid() const
1410
1419
{
1411
1420
  return (_years >= DRIZZLE_MIN_YEARS_SQL && _years <= DRIZZLE_MAX_YEARS_SQL)