Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / views / src / Plugin / views / query / QueryPluginBase.php
index 35453c1172dd991b4ce5d15386e96ef668519ac2..83e0bcfa2403e04581f0937da4f9e462a0df7f7c 100644 (file)
@@ -206,11 +206,17 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
    *
    * @param string $field
    *   The query field that will be used in the expression.
+   * @param bool $string_date
+   *   For certain databases, date format functions vary depending on string or
+   *   numeric storage.
+   * @param bool $calculate_offset
+   *   If set to TRUE, the timezone offset will be included in the returned
+   *   field.
    *
    * @return string
    *   An expression representing a timestamp with time zone.
    */
-  public function getDateField($field) {
+  public function getDateField($field, $string_date = FALSE, $calculate_offset = TRUE) {
     return $field;
   }
 
@@ -346,6 +352,36 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
     return [];
   }
 
+  /**
+   * Applies a timezone offset to the given field.
+   *
+   * @param string &$field
+   *   The date field, in string format.
+   * @param int $offset
+   *   The timezone offset to apply to the field.
+   */
+  public function setFieldTimezoneOffset(&$field, $offset) {
+    // No-op. Timezone offsets are implementation-specific and should implement
+    // this method as needed.
+  }
+
+  /**
+   * Get the timezone offset in seconds.
+   *
+   * @return int
+   *   The offset, in seconds, for the timezone being used.
+   */
+  public function getTimezoneOffset() {
+    $timezone = $this->setupTimezone();
+    $offset = 0;
+    if ($timezone) {
+      $dtz = new \DateTimeZone($timezone);
+      $dt = new \DateTime('now', $dtz);
+      $offset = $dtz->getOffset($dt);
+    }
+    return $offset;
+  }
+
 }
 
 /**