summaryrefslogtreecommitdiffstats
path: root/lib/Providers/Time/HttpTimeProvider.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Providers/Time/HttpTimeProvider.php')
-rw-r--r--lib/Providers/Time/HttpTimeProvider.php7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Providers/Time/HttpTimeProvider.php b/lib/Providers/Time/HttpTimeProvider.php
index 27982f1..c761bd9 100644
--- a/lib/Providers/Time/HttpTimeProvider.php
+++ b/lib/Providers/Time/HttpTimeProvider.php
@@ -9,11 +9,12 @@ class HttpTimeProvider implements ITimeProvider
{
public $url;
public $options;
+ public $expectedtimeformat;
- function __construct($url = 'https://google.com', array $options = null)
+ function __construct($url = 'https://google.com', $expectedtimeformat = 'D, d M Y H:i:s O+', array $options = null)
{
$this->url = $url;
-
+ $this->expectedtimeformat = $expectedtimeformat;
$this->options = $options;
if ($this->options === null) {
$this->options = array(
@@ -41,7 +42,7 @@ class HttpTimeProvider implements ITimeProvider
foreach ($headers['wrapper_data'] as $h) {
if (strcasecmp(substr($h, 0, 5), 'Date:') === 0)
- return \DateTime::createFromFormat('D, d M Y H:i:s O+', trim(substr($h,5)))->getTimestamp();
+ return \DateTime::createFromFormat($this->expectedtimeformat, trim(substr($h,5)))->getTimestamp();
}
throw new \TimeException(sprintf('Unable to retrieve time from %s (Invalid or no "Date:" header found)', $this->url));
}