~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/temporal.cc

  • Committer: Brian Aker
  • Date: 2010-12-26 00:07:57 UTC
  • Revision ID: brian@tangent.org-20101226000757-ysntnltqywxoe1em
MErge in the include changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
  TemporalFormat *current_format;
154
154
  std::vector<TemporalFormat *>::iterator current= known_date_formats.begin();
155
155
 
156
 
  _useconds= 0; // We may not match on it, so we need to make sure we zero it out.
157
156
  while (current != known_date_formats.end())
158
157
  {
159
158
    current_format= *current;
1070
1069
int MicroTimestamp::to_string(char *to, size_t to_len) const
1071
1070
{
1072
1071
  return snprintf(to, to_len,
1073
 
                  "%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32
1074
 
                  " %02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%06" PRIu32,
1075
 
                  _years, _months, _days,
1076
 
                  _hours, _minutes, _seconds, _useconds);
 
1072
                  "%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32
 
1073
                      " %02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%06" PRIu32,
 
1074
                  _years, _months, _days,
 
1075
                  _hours, _minutes, _seconds, _useconds);
1077
1076
}
1078
1077
 
1079
1078
void Time::to_decimal(type::Decimal *to) const
1333
1332
    return false;
1334
1333
}
1335
1334
 
1336
 
bool DateTime::from_timeval(struct timeval &timeval_arg)
1337
 
{
1338
 
  struct tm broken_time;
1339
 
  struct tm *result;
1340
 
 
1341
 
  result= gmtime_r(&timeval_arg.tv_sec, &broken_time);
1342
 
  if (result != NULL)
1343
 
  {
1344
 
    _years= 1900 + broken_time.tm_year;
1345
 
    _months= 1 + broken_time.tm_mon; /* Month is NOT ordinal for struct tm! */
1346
 
    _days= broken_time.tm_mday; /* Day IS ordinal for struct tm */
1347
 
    _hours= broken_time.tm_hour;
1348
 
    _minutes= broken_time.tm_min;
1349
 
    _seconds= broken_time.tm_sec;
1350
 
    _epoch_seconds= timeval_arg.tv_sec;
1351
 
    /* Set hires precision to zero */
1352
 
    _useconds= timeval_arg.tv_usec;
1353
 
    _nseconds= 0;
1354
 
    return is_valid();
1355
 
  }
1356
 
  else 
1357
 
  {
1358
 
    return false;
1359
 
  }
1360
 
}
1361
 
 
1362
1335
bool DateTime::from_time_t(const time_t from)
1363
1336
{
1364
1337
  struct tm broken_time;
1380
1353
    return is_valid();
1381
1354
  }
1382
1355
  else 
1383
 
  {
1384
1356
    return false;
1385
 
  }
1386
1357
}
1387
1358
 
1388
1359
void Date::to_time_t(time_t &to) const
1402
1373
  to= _epoch_seconds;
1403
1374
}
1404
1375
 
1405
 
void MicroTimestamp::to_timeval(struct timeval &to) const
 
1376
void MicroTimestamp::to_timeval(struct timeval *to) const
1406
1377
{
1407
 
  to.tv_sec= _epoch_seconds;
1408
 
  to.tv_usec= _useconds;
 
1378
  to->tv_sec= _epoch_seconds;
 
1379
  to->tv_usec= _useconds;
1409
1380
}
1410
1381
 
1411
1382
void NanoTimestamp::to_timespec(struct timespec *to) const