Commit 7b824b3b authored by John Voskuilen's avatar John Voskuilen
Browse files

Issue #1925272 by super_romeo, hswong3i: Timezone: Add hook_alter to handle User timezones

parent 0377859f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -25,6 +25,14 @@ function hook_office_hours_current_time_alter(int &$time, EntityInterface $entit
  // Add user timezone to time.
  // Assume that all owned entities (for example, offices) should
  // depend on user timezone.

  // Use case is a website as bulletin board.
  // Multiple accounts (clients) with different cities and timezones.
  // 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.

  if ($entity instanceof \Drupal\user\EntityOwnerInterface
    && ($account = $entity->getOwner())
    && ($account->isAuthenticated())