~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/temporal.cc

  • Committer: Brian Aker
  • Date: 2011-01-05 17:21:13 UTC
  • mto: (2057.2.1 clean)
  • mto: This revision was merged to the branch mainline in revision 2064.
  • Revision ID: brian@tangent.org-20110105172113-s7mng3puod6o9n3y
Add basic tests for microtime.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1332
1332
    return false;
1333
1333
}
1334
1334
 
 
1335
bool DateTime::from_timeval(struct timeval &timeval_arg)
 
1336
{
 
1337
  struct tm broken_time;
 
1338
  struct tm *result;
 
1339
 
 
1340
  result= gmtime_r(&timeval_arg.tv_sec, &broken_time);
 
1341
  if (result != NULL)
 
1342
  {
 
1343
    _years= 1900 + broken_time.tm_year;
 
1344
    _months= 1 + broken_time.tm_mon; /* Month is NOT ordinal for struct tm! */
 
1345
    _days= broken_time.tm_mday; /* Day IS ordinal for struct tm */
 
1346
    _hours= broken_time.tm_hour;
 
1347
    _minutes= broken_time.tm_min;
 
1348
    _seconds= broken_time.tm_sec;
 
1349
    _epoch_seconds= timeval_arg.tv_sec;
 
1350
    /* Set hires precision to zero */
 
1351
    _useconds= timeval_arg.tv_usec;
 
1352
    _nseconds= 0;
 
1353
    return is_valid();
 
1354
  }
 
1355
  else 
 
1356
  {
 
1357
    return false;
 
1358
  }
 
1359
}
 
1360
 
1335
1361
bool DateTime::from_time_t(const time_t from)
1336
1362
{
1337
1363
  struct tm broken_time;
1353
1379
    return is_valid();
1354
1380
  }
1355
1381
  else 
 
1382
  {
1356
1383
    return false;
 
1384
  }
1357
1385
}
1358
1386
 
1359
1387
void Date::to_time_t(time_t &to) const
1373
1401
  to= _epoch_seconds;
1374
1402
}
1375
1403
 
1376
 
void MicroTimestamp::to_timeval(struct timeval *to) const
 
1404
void MicroTimestamp::to_timeval(struct timeval &to) const
1377
1405
{
1378
 
  to->tv_sec= _epoch_seconds;
1379
 
  to->tv_usec= _useconds;
 
1406
  to.tv_sec= _epoch_seconds;
 
1407
  to.tv_usec= _useconds;
1380
1408
}
1381
1409
 
1382
1410
void NanoTimestamp::to_timespec(struct timespec *to) const