You are here

function _support_pm_first_day in Support Ticketing System 7

Same name and namespace in other branches
  1. 6 support_pm/support_pm.module \_support_pm_first_day()

TODO: Proper timezone support

7 calls to _support_pm_first_day()
support_pm_admin_reports in support_pm/support_pm.admin.inc
support_pm_day_load in support_pm/support_pm.module
support_pm_plan_overview_weekly in support_pm/support_pm.module
support_pm_user_week_submit in support_pm/support_pm.module
Save user's week plan.
theme_support_pm_pager in support_pm/support_pm.module
Helper function to show previous and next weeks.

... See full list

File

support_pm/support_pm.module, line 938
Support Project Management. @author Jeremy Andrews <jeremy@tag1consulting.com> @package Support

Code

function _support_pm_first_day($time = 0) {

  // Use Drupal core's configurable first day of the week.
  $date_first_day = variable_get('date_first_day', 0);
  if (!$time) {
    $time = time();
  }

  // Determine what day of the week $time is
  $day = date('w', $time);

  // Now calculate a timestamp for the first day of this week,
  // respecting the configured first day of the week.
  if ($day >= $date_first_day) {
    $days = $day - $date_first_day;
  }
  else {
    $days = $day + 7 - $date_first_day;
  }
  return strtotime(date('M d, Y 12:00', $time - 86400 * $days));
}