You are here

public static function SmartDateTrait::isAllDay in Smart Date 8.2

Same name and namespace in other branches
  1. 3.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::isAllDay()
  2. 3.0.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::isAllDay()
  3. 3.1.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::isAllDay()
  4. 3.2.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::isAllDay()
  5. 3.3.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::isAllDay()
  6. 3.4.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::isAllDay()

Evaluates whether or not a provided range is "all day".

Parameters

object $start_ts: A timestamp.

object $end_ts: A timestamp.

string|null $timezone: An optional timezone override.

Return value

boolean Whether or not the timestamps are considered all day by Smart Date.

3 calls to SmartDateTrait::isAllDay()
SmartDateProcessor::updateEntry in src/Plugin/FullcalendarViewProcessor/SmartDateProcessor.php
Helper function to update the FCV-created data arrary.
SmartDateRule::getTextRule in modules/smart_date_recur/src/Entity/SmartDateRule.php
Use the transformer to get text output of the rule.
SmartDateTrait::formatSmartDate in src/SmartDateTrait.php
Creates a formatted date value as a string.

File

src/SmartDateTrait.php, line 433

Class

SmartDateTrait
Provides friendly methods for smart date range.

Namespace

Drupal\smart_date

Code

public static function isAllDay($start_ts, $end_ts, $timezone = NULL) {
  if ($timezone) {

    // Apply a specific timezone provided.
    $default_tz = date_default_timezone_get();
    date_default_timezone_set($timezone);
  }

  // Format timestamps to predictable format for comparison.
  $temp_start = date('H:i', $start_ts);
  $temp_end = date('H:i', $end_ts);
  if ($timezone) {

    // Revert to previous timezone.
    date_default_timezone_set($default_tz);
  }
  if ($temp_start == '00:00' && $temp_end == '23:59') {
    return TRUE;
  }
  return FALSE;
}