Skip to content

Commit 4a8e554

Browse files
[auto-generated] Update plugin files
Check out the commits that caused these changes: moodlehq/moodleapp@beac119...e49f10e
1 parent fd6d3e7 commit 4a8e554

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

tests/behat/behat_app_helper.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -738,25 +738,36 @@ protected function resize_app_window(int $width = 500, int $height = 720) {
738738
* This function is similar to the arg_time_to_string transformation, but it allows the time to be a sub-text of the string.
739739
*
740740
* @param string $text
741-
* @return string Transformed text.
741+
* @return string|string[] Transformed text.
742742
*/
743-
protected function transform_time_to_string(string $text): string {
743+
protected function transform_time_to_string(string $text): string|array {
744744
if (!preg_match('/##(.*)##/', $text, $matches)) {
745745
// No time found, return the original text.
746746
return $text;
747747
}
748748

749749
$timepassed = explode('##', $matches[1]);
750+
$basetime = time();
750751

751752
// If not a valid time string, then just return what was passed.
752-
if ((($timestamp = strtotime($timepassed[0])) === false)) {
753+
if ((($timestamp = strtotime($timepassed[0], $basetime)) === false)) {
753754
return $text;
754755
}
755756

756757
$count = count($timepassed);
757758
if ($count === 2) {
758759
// If timestamp with specified strftime format, then return formatted date string.
759-
return str_replace($matches[0], userdate($timestamp, $timepassed[1]), $text);
760+
$result = [str_replace($matches[0], userdate($timestamp, $timepassed[1]), $text)];
761+
762+
// If it's a relative date, allow a difference of 1 minute for the base time used to calculate the timestampt.
763+
if ($timestamp !== strtotime($timepassed[0], 0)) {
764+
$timestamp = strtotime($timepassed[0], $basetime - 60);
765+
$result[] = str_replace($matches[0], userdate($timestamp, $timepassed[1]), $text);
766+
}
767+
768+
$result = array_unique($result);
769+
770+
return count($result) == 1 ? $result[0] : $result;
760771
} else if ($count === 1) {
761772
return str_replace($matches[0], $timestamp, $text);
762773
} else {

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
defined('MOODLE_INTERNAL') || die;
88

9-
$plugin->version = 2024072500;
9+
$plugin->version = 2024090200;
1010
$plugin->requires = 2016052300;
1111
$plugin->maturity = MATURITY_STABLE;
1212
$plugin->release = '4.5.0';

0 commit comments

Comments
 (0)