Commit de79990b authored by John Voskuilen's avatar John Voskuilen
Browse files

Issue #1925272: Timezone: Add hook_alter to handle User timezones

parent 35694db5
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ use Drupal\Core\Entity\EntityInterface;
 * @see issue [#1925272] Handle timezone.
 */
function hook_office_hours_current_time_alter(int &$time, EntityInterface $entity) {
  // Add user timezone to time.
  // Update the 'current time' to calculate current, open,  office hours.
  // Assume that all owned entities (for example, offices) should
  // depend on user timezone.

@@ -31,8 +31,12 @@ function hook_office_hours_current_time_alter(int &$time, EntityInterface $entit
  // Client sets his timezone in his account data.
  // His articles (offices) have office hours with current status (open\closed).
  // Client sets it to e.g., 8:00-20:00.
  // Visitor chooses his city and wants to see if offices in this city are open.

  // Visitor has not maintained a timezone.
  // Visitor chooses his city (in a Views' filter)
  // and wants to see if offices in this city are open.
  // Each city has a timezone attached.
  //
  // Adjust content time to content owner's timezone.
  if ($entity instanceof \Drupal\user\EntityOwnerInterface
    && ($account = $entity->getOwner())
    && ($account->isAuthenticated())