original_string: public static function update_event_start_day($eventid, $daytimestamp) {
          global $USER, $PAGE;
  
          // Parameter validation.
          $params = self::validate_parameters(self::update_event_start_day_parameters(), [
              'eventid' => $eventid,
              'daytimestamp' => $daytimestamp,
          ]);
  
          $vault = event_container::get_event_vault();
          $mapper = event_container::get_event_mapper();
          $event = $vault->get_event_by_id($eventid);
  
          if (!$event) {
              throw new \moodle_exception('Unable to find event with id ' . $eventid);
          }
  
          $legacyevent = $mapper->from_event_to_legacy_event($event);
  
          if (!calendar_edit_event_allowed($legacyevent, true)) {
              print_error('nopermissiontoupdatecalendar');
          }
  
          self::validate_context($legacyevent->context);
  
          $newdate = usergetdate($daytimestamp);
          $startdatestring = implode('-', [$newdate['year'], $newdate['mon'], $newdate['mday']]);
          $startdate = new DateTimeImmutable($startdatestring);
          $event = local_api::update_event_start_day($event, $startdate);
          $cache = new events_related_objects_cache([$event]);
          $relatedobjects = [
              'context' => $cache->get_context($event),
              'course' => $cache->get_course($event),
          ];
          $exporter = new event_exporter($event, $relatedobjects);
          $renderer = $PAGE->get_renderer('core_calendar');
  
          return array('event' => $exporter->export($renderer));
      }
code: public static function update_event_start_day($eventid, $daytimestamp) {
          global $USER, $PAGE;
  
          // Parameter validation.
          $params = self::validate_parameters(self::update_event_start_day_parameters(), [
              'eventid' => $eventid,
              'daytimestamp' => $daytimestamp,
          ]);
  
          $vault = event_container::get_event_vault();
          $mapper = event_container::get_event_mapper();
          $event = $vault->get_event_by_id($eventid);
  
          if (!$event) {
              throw new \moodle_exception('Unable to find event with id ' . $eventid);
          }
  
          $legacyevent = $mapper->from_event_to_legacy_event($event);
  
          if (!calendar_edit_event_allowed($legacyevent, true)) {
              print_error('nopermissiontoupdatecalendar');
          }
  
          self::validate_context($legacyevent->context);
  
          $newdate = usergetdate($daytimestamp);
          $startdatestring = implode('-', [$newdate['year'], $newdate['mon'], $newdate['mday']]);
          $startdate = new DateTimeImmutable($startdatestring);
          $event = local_api::update_event_start_day($event, $startdate);
          $cache = new events_related_objects_cache([$event]);
          $relatedobjects = [
              'context' => $cache->get_context($event),
              'course' => $cache->get_course($event),
          ];
          $exporter = new event_exporter($event, $relatedobjects);
          $renderer = $PAGE->get_renderer('core_calendar');
  
          return array('event' => $exporter->export($renderer));
      }
code_tokens: public static function update_event_start_day ( $ eventid , $ daytimestamp ) { global $ USER , $ PAGE ; // Parameter validation. $ params = self :: validate_parameters ( self :: update_event_start_day_parameters ( ) , [ 'eventid' => $ eventid , 'daytimestamp' => $ daytimestamp , ] ) ; $ vault = event_container :: get_event_vault ( ) ; $ mapper = event_container :: get_event_mapper ( ) ; $ event = $ vault -> get_event_by_id ( $ eventid ) ; if ( ! $ event ) { throw new \ moodle_exception ( 'Unable to find event with id ' . $ eventid ) ; } $ legacyevent = $ mapper -> from_event_to_legacy_event ( $ event ) ; if ( ! calendar_edit_event_allowed ( $ legacyevent , true ) ) { print_error ( 'nopermissiontoupdatecalendar' ) ; } self :: validate_context ( $ legacyevent -> context ) ; $ newdate = usergetdate ( $ daytimestamp ) ; $ startdatestring = implode ( '-' , [ $ newdate [ 'year' ] , $ newdate [ 'mon' ] , $ newdate [ 'mday' ] ] ) ; $ startdate = new DateTimeImmutable ( $ startdatestring ) ; $ event = local_api :: update_event_start_day ( $ event , $ startdate ) ; $ cache = new events_related_objects_cache ( [ $ event ] ) ; $ relatedobjects = [ 'context' => $ cache -> get_context ( $ event ) , 'course' => $ cache -> get_course ( $ event ) , ] ; $ exporter = new event_exporter ( $ event , $ relatedobjects ) ; $ renderer = $ PAGE -> get_renderer ( 'core_calendar' ) ; return array ( 'event' => $ exporter -> export ( $ renderer ) ) ; }
docstring: Change the start day for the given calendar event to the day that
  corresponds with the provided timestamp.
  
  The timestamp only needs to be anytime within the desired day as only
  the date data is extracted from it.
  
  The event's original time of day is maintained, only the date is shifted.
  
  @param int $eventid Id of event to be updated
  @param int $daytimestamp Timestamp for the new start day
  @return  array
docstring_tokens: Change the start day for the given calendar event to the day that corresponds with the provided timestamp .