Rounds the current time up to the nearest $step minute interval.
E.g. if $step=15, time will be rounded up to 15/30/45/00

@param int $step - The interval step to roung to
@return \GDM\Framework\Types\Date
976633
public function roundMinutes($step=15, $direction = null)
    {

        $function = "round";
        if ($direction && preg_match("/.*up.*/i", $direction)) {
            $function = "ceil";
        } else if ($direction && preg_match("/.*down.*/i", $direction)) {
            $function = "floor";
        }
        $stepSeconds    = $step * 60;
        $nowSeconds     = $this->getTimestamp();
        $roundedSeconds = $function($nowSeconds / ($stepSeconds)) * ($stepSeconds);
        $this->setTimestamp($roundedSeconds);
        return $this;
    }
399399
public static function roundTimestampDownToMonth($timestamp)
    {
        $month = date('n', $timestamp);
        $year  = date('Y', $timestamp);
                
        $roundedTimestamp = mktime(0, 0, 0, $month, $day="01", $year);
                
        return $roundedTimestamp;
    }
1152387
public function plusSeconds(int $seconds) : LocalTime
    {
        if ($seconds === 0) {
            return $this;
        }

        $sofd = $this->hour * self::SECONDS_PER_HOUR + $this->minute * self::SECONDS_PER_MINUTE + $this->second;
        $newSofd = (($seconds % self::SECONDS_PER_DAY) + $sofd + self::SECONDS_PER_DAY) % self::SECONDS_PER_DAY;

        if ($sofd === $newSofd) {
            return $this;
        }

        $hour = \intdiv($newSofd, self::SECONDS_PER_HOUR);
        $minute = \intdiv($newSofd, self::SECONDS_PER_MINUTE) % self::MINUTES_PER_HOUR;
        $second = $newSofd % self::SECONDS_PER_MINUTE;

        return new LocalTime($hour, $minute, $second, $this->nano);
    }
990727
public function secondTo(int $second): Date
    {
        return $this->createDateWithNewTime(
                $this->originalDate->hours(),
                $this->originalDate->minutes(),
                $second
        );
    }
1040137
public static function roundTimestampToYear($timestamp)
    {
        $year  = date('Y', $timestamp);
        
        $roundedTimestamp = mktime(0, 0, 0, $month=1, $day=1, $year);
        
        return $roundedTimestamp;
    }
76100
public function setStep(?string $step) : self
    {
        if ($step !== null) {
            $step = Decimal::parse($step);

            if ($step->isNegativeOrZero()) {
                throw new \InvalidArgumentException('The step must be strictly positive.');
            }
        }

        $this->step = $step;

        return $this;
    }
8354
public function addStep(Step $step)
    {
        if (!$this->steps->contains($step)) {
            $step->setOrder($this->steps->count());
            $this->steps->add($step);
            $step->setExercise($this);
        }

        return $this;
    }
343213
public function getStepFormat()
    {
        if ($this->lang == 'en') {
            switch ($this->step) {
                case self::$YEARLY:
                    return 'Y';
                    break;
                case self::$MONTHLY:
                    return 'Y-m';
                    break;
                case self::$DAILY:
                    return 'Y-m-d';
                    break;
                case self::$HOURLY:
                    return 'Y-m-d H:00';
                    break;
            }
        } elseif ($this->lang == 'fr') {
            switch ($this->step) {
                case self::$YEARLY:
                    return 'Y';
                    break;
                case self::$MONTHLY:
                    return 'm/Y';
                    break;
                case self::$DAILY:
                    return 'd/m/Y';
                    break;
                case self::$HOURLY:
                    return 'd/m/Y H:00';
                    break;
            }
        }

        return false;
    }
1091456
protected function setTimestamp($seconds)
	{
		if ( ! is_numeric($seconds) || $seconds < 0)
		{
			throw new \InvalidArgumentException('The seconds value should be a positive integer.');
		}
		
		$this->timestamp = (float) $seconds;
		
		return $this;
	}
91501
public static function get_target_type(step $step) {
        if (!isset(self::$mapping[$step->get_targettype()])) {
            throw new \moodle_exception('Unknown Target type');
        }

        $targettype = self::$mapping[$step->get_targettype()];
        return "\\tool_usertours\\local\\target\\{$targettype}";
    }
922721
public function initStep($step)
    {
        $step_method = 'step_'.$step;
        /** @type H1 $h */
        $h = $this->add('H1');
        if (!$this->hasMethod($step_method)) {
            return $h->set('No such step');
        }
        $h->set('Step '.$this->s_cnt.': '.$this->s_title);
        $page = $this->makePage($step);

        return $this->$step_method($page);
    }
1152783
public function withMinute(int $minute) : ZonedDateTime
    {
        return ZonedDateTime::of($this->localDateTime->withMinute($minute), $this->timeZone);
    }
720105
public function setMinute( int $value = null ) : Time
   {

      if ( \is_null( $value ) )
      {
         $this->properties[ 'minute' ] = static::CurrentMinute();
         return $this;
      }

      $intValue = \intval( $value );

      if ( $intValue < 0 )
      {
         $this->properties[ 'minute' ] = 0;
      }
      else if ( $intValue > 59 )
      {
         $this->properties[ 'minute' ] = $intValue % 60;
      }
      else
      {
         $this->properties[ 'minute' ] = $intValue;
      }

      return $this;

   }
284833
private function nextTime() {
        $time = microtime(true);
        $difference = $time - $this->getLastTime();
        $this->setLastTime($time);
        if(!is_null($difference)) {
            return number_format(round($difference, 3), 3, '.', '');
        }
        return null;
    }
488474
public final function setMinute( int $minute = null )
      : DateTime
   {

      if ( \is_null( $minute ) )
      {
         $minute = static::CurrentMinute();
      }

      return $this->setTimeParts( null, $minute );

   }
72012
protected function stepExist($step)
    {
        return isset($this->steps[$step]) && class_exists($this->steps[$step]);
    }
29116
public function setStep(string $step)
    {
        $this->doSetStep($step);
        $this->getTag()->setAttribute('step', $step);

        return $this;
    }