34 if ($instant === null) {
37 return gmdate(
'Y-m-d\TH:i:s\Z', $instant);
54 if (self::$tz_initialized) {
61 if ($timezone !== null) {
62 if (!date_default_timezone_set($timezone)) {
63 throw new \SimpleSAML_Error_Exception(
'Invalid timezone set in the "timezone" option in config.php.');
65 self::$tz_initialized =
true;
71 $serverTimezone = date_default_timezone_get();
75 date_default_timezone_set($serverTimezone);
76 self::$tz_initialized =
true;
95 throw new \InvalidArgumentException(
'Invalid input parameters');
99 $durationRegEx =
'#^(-?)P(?:(?:(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)'.
100 '(?:[.,]\d+)?S)?)?)|(?:(\\d+)W))$#D';
101 if (!preg_match($durationRegEx, $duration, $matches)) {
102 throw new \InvalidArgumentException(
'Invalid ISO 8601 duration: '.$duration);
105 $durYears = (empty($matches[2]) ? 0 : (int) $matches[2]);
106 $durMonths = (empty($matches[3]) ? 0 : (int) $matches[3]);
107 $durDays = (empty($matches[4]) ? 0 : (int) $matches[4]);
108 $durHours = (empty($matches[5]) ? 0 : (int) $matches[5]);
109 $durMinutes = (empty($matches[6]) ? 0 : (int) $matches[6]);
110 $durSeconds = (empty($matches[7]) ? 0 : (int) $matches[7]);
111 $durWeeks = (empty($matches[8]) ? 0 : (int) $matches[8]);
113 if (!empty($matches[1])) {
115 $durYears = -$durYears;
116 $durMonths = -$durMonths;
117 $durDays = -$durDays;
118 $durHours = -$durHours;
119 $durMinutes = -$durMinutes;
120 $durSeconds = -$durSeconds;
121 $durWeeks = -$durWeeks;
128 if ($durYears !== 0 || $durMonths !== 0) {
136 $yearmonth = explode(
':', gmdate(
'Y:n',
$timestamp));
137 $year = (int) ($yearmonth[0]);
138 $month = (int) ($yearmonth[1]);
141 $timestamp -= gmmktime(0, 0, 0, $month, 1, $year);
145 $month += $durMonths;
146 while ($month > 12) {
156 $timestamp += gmmktime(0, 0, 0, $month, 1, $year);
static popErrorMask()
Pop an error mask.
static initTimezone()
Initialize the timezone.
static generateTimestamp($instant=null)
This function generates a timestamp on the form used by the SAML protocols.
static parseDuration($duration, $timestamp=null)
Interpret a ISO8601 duration value relative to a given timestamp.
static maskErrors($mask)
Disable error reporting for the given log levels.
foreach($mandatory_scripts as $file) $timestamp
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.