33 if ($instant === null) {
36 return gmdate(
'Y-m-d\TH:i:s\Z', $instant);
53 if (self::$tz_initialized) {
60 if ($timezone !== null) {
61 if (!date_default_timezone_set($timezone)) {
62 throw new \SimpleSAML_Error_Exception(
'Invalid timezone set in the "timezone" option in config.php.');
64 self::$tz_initialized =
true;
70 $serverTimezone = date_default_timezone_get();
74 date_default_timezone_set($serverTimezone);
75 self::$tz_initialized =
true;
94 throw new \InvalidArgumentException(
'Invalid input parameters');
98 $durationRegEx =
'#^(-?)P(?:(?:(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)'.
99 '(?:[.,]\d+)?S)?)?)|(?:(\\d+)W))$#D';
100 if (!preg_match($durationRegEx, $duration, $matches)) {
101 throw new \InvalidArgumentException(
'Invalid ISO 8601 duration: '.$duration);
104 $durYears = (empty($matches[2]) ? 0 : (int) $matches[2]);
105 $durMonths = (empty($matches[3]) ? 0 : (int) $matches[3]);
106 $durDays = (empty($matches[4]) ? 0 : (int) $matches[4]);
107 $durHours = (empty($matches[5]) ? 0 : (int) $matches[5]);
108 $durMinutes = (empty($matches[6]) ? 0 : (int) $matches[6]);
109 $durSeconds = (empty($matches[7]) ? 0 : (int) $matches[7]);
110 $durWeeks = (empty($matches[8]) ? 0 : (int) $matches[8]);
112 if (!empty($matches[1])) {
114 $durYears = -$durYears;
115 $durMonths = -$durMonths;
116 $durDays = -$durDays;
117 $durHours = -$durHours;
118 $durMinutes = -$durMinutes;
119 $durSeconds = -$durSeconds;
120 $durWeeks = -$durWeeks;
127 if ($durYears !== 0 || $durMonths !== 0) {
135 $yearmonth = explode(
':', gmdate(
'Y:n',
$timestamp));
136 $year = (int) ($yearmonth[0]);
137 $month = (int) ($yearmonth[1]);
140 $timestamp -= gmmktime(0, 0, 0, $month, 1, $year);
144 $month += $durMonths;
145 while ($month > 12) {
155 $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
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.