function date_views_browser_period_start_stamp in Date 5
Find the timestamp for the beginning of the period of the analyzed date arg
3 calls to date_views_browser_period_start_stamp()
- date_views_browser_navigation in ./
date_views.inc - Navigation links for the full view
- date_views_browser_period_arg in ./
date_views.inc - Format an argument for the date range
- date_views_browser_period_label in ./
date_views.inc - Return label for current date range
File
- ./
date_views.inc, line 716
Code
function date_views_browser_period_start_stamp($arg = NULL, $period = 'month') {
include_once drupal_get_path('module', 'date_api') . '/date.inc';
// get the range of dates
$range = date_views_date_range($arg);
$stamp = date_iso2unix($range[0]);
// if a date range has already been determined, return the beginning of that range
if ($arg) {
return $stamp;
}
// if no range is yet set, find the beginning of the appropriate period
switch ($period) {
case 'week':
$dow = date_gmdate('w', $stamp);
if ($dow >= 6) {
$adj = 86400 * 7;
}
$start = intval($stamp - intval($dow * 86400) + $adj);
// if site preference is to start week on other than a Sunday, go back a week and move up to correct day
if (variable_get('date_first_day', 0)) {
$start += intval(variable_get('date_first_day', 0) * 86400);
}
break;
case 'year':
$year = date_gmdate('Y', $stamp);
$start = date_gmmktime(array(
'year' => $year,
'mon' => 1,
'mday' => 1,
));
break;
case 'day':
$year = date_gmdate('Y', $stamp);
$month = date_gmdate('n', $stamp);
$day = date_gmdate('j', $stamp);
$start = date_gmmktime(array(
'year' => $year,
'mon' => $month,
'mday' => $day,
'hours' => 1,
));
break;
case 'hour':
$year = date_gmdate('Y', $stamp);
$month = date_gmdate('n', $stamp);
$day = date_gmdate('j', $stamp);
$hour = date_gmdate('H', $stamp);
$start = date_gmmktime(array(
'year' => $year,
'mon' => $month,
'mday' => $day,
'hours' => $hour,
'minutes' => 1,
));
break;
default:
$year = date_gmdate('Y', $stamp);
$month = date_gmdate('n', $stamp);
$start = date_gmmktime(array(
'year' => $year,
'mon' => $month,
'mday' => 1,
));
break;
}
return $start;
}