You are here

function StatisticsProBaseTestCase::getAddedDate in Statistics Pro 6

Same name and namespace in other branches
  1. 6.2 tests/statspro.test \StatisticsProBaseTestCase::getAddedDate()
2 calls to StatisticsProBaseTestCase::getAddedDate()
StatisticsProBaseTestCase::createInitialData in tests/statspro.test
StatisticsProBaseTestCase::getFormatedAddedDate in tests/statspro.test

File

tests/statspro.test, line 57
Functionality tests for Statistics Pro.

Class

StatisticsProBaseTestCase
Base class for Statistics Pro tests.

Code

function getAddedDate($timestamp, $diff = 0, $diff_unit = 'd') {
  switch ($diff_unit) {
    case 's':
      $delta = $diff;
      break;
    case 'm':
      $delta = 60 * $diff;
      break;
    case 'h':
      $delta = 3600 * $diff;
      break;
    case 'w':
      $delta = 7 * 24 * 3600 * $diff;
      break;
    case 'y':
      $delta = 365 * 24 * 3600 * $diff;
      break;
    default:
      $delta = 24 * 3600 * $diff;
  }
  $timestamp += $delta;
  return $timestamp;
}