You are here

function _ad_report_get_date_from_path in Advertisement 5.2

Same name and namespace in other branches
  1. 6.3 report/ad_report.module \_ad_report_get_date_from_path()
  2. 6.2 report/ad_report.module \_ad_report_get_date_from_path()
  3. 7 report/ad_report.module \_ad_report_get_date_from_path()

Helper function to extract date from URL.

4 calls to _ad_report_get_date_from_path()
ad_report_admin_ad_table in report/ad_report.module
ad_report_bargraph in report/ad_report.module
Page to display ad with bargraph.
ad_report_group_table in report/ad_report.module
Display table with per-group statistics.
ad_report_menu in report/ad_report.module
Implementation of hook_menu().

File

report/ad_report.module, line 493
Provides comprehensive charts and reports about advertising statistics.

Code

function _ad_report_get_date_from_path($path) {
  if ($path) {
    $year = substr($path, 0, 4);
    $month = substr($path, 4, 2);
    $day = substr($path, 6, 2);
    $hour = substr($path, 8, 2);
    if (strlen($path) == 12) {
      $minute = substr($path, 10, 2);
    }
    else {
      $minute = 0;
    }
    $date = strtotime("{$month}/{$day}/{$year} {$hour}:{$minute}");
    if ($date > 0) {
      return $date;
    }
    drupal_set_message(t('Invalid date specified in range.'), 'error');
  }
}