Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Class for normalising the date data.
  19   *
  20   * @package   core_calendar
  21   * @copyright 2017 Andrew Nicols <andrew@nicols.co.uk>
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace core_calendar\external;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  use core\external\exporter;
  30  use renderer_base;
  31  use moodle_url;
  32  
  33  /**
  34   * Class for normalising the date data.
  35   *
  36   * @package   core_calendar
  37   * @copyright 2017 Andrew Nicols <andrew@nicols.co.uk>
  38   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  39   */
  40  class date_exporter extends exporter {
  41  
  42      /**
  43       * Constructor for date_exporter.
  44       *
  45       * @param array $data
  46       * @param array $related The related information
  47       */
  48      public function __construct($data, $related = []) {
  49          $data['timestamp'] = $data[0];
  50          unset($data[0]);
  51  
  52          parent::__construct($data, $related);
  53      }
  54  
  55      protected static function define_properties() {
  56          return [
  57              'seconds' => [
  58                  'type' => PARAM_INT,
  59              ],
  60              'minutes' => [
  61                  'type' => PARAM_INT,
  62              ],
  63              'hours' => [
  64                  'type' => PARAM_INT,
  65              ],
  66              'mday' => [
  67                  'type' => PARAM_INT,
  68              ],
  69              'wday' => [
  70                  'type' => PARAM_INT,
  71              ],
  72              'mon' => [
  73                  'type' => PARAM_INT,
  74              ],
  75              'year' => [
  76                  'type' => PARAM_INT,
  77              ],
  78              'yday' => [
  79                  'type' => PARAM_INT,
  80              ],
  81              'weekday' => [
  82                  'type' => PARAM_RAW,
  83              ],
  84              'month' => [
  85                  'type' => PARAM_RAW,
  86              ],
  87              'timestamp' => [
  88                  'type' => PARAM_INT,
  89              ],
  90          ];
  91      }
  92  }