1
0
Fork 0

Enforce UTC on all datetime instances, set lock release date to datetime always, refs #923

pull/1349/merge
Jordi Boggiano 2012-11-20 14:36:33 +01:00
parent 18973ed0b9
commit 326fcbcab7
5 changed files with 6 additions and 5 deletions

View File

@ -76,7 +76,7 @@ class ValidatingArrayLoader implements LoaderInterface
$this->validateString('time'); $this->validateString('time');
if (!empty($this->config['time'])) { if (!empty($this->config['time'])) {
try { try {
$date = new \DateTime($this->config['time']); $date = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
} catch (\Exception $e) { } catch (\Exception $e) {
$this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage(); $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
unset($this->config['time']); unset($this->config['time']);

View File

@ -292,7 +292,8 @@ class Locker
$sourceRef = $package->getSourceReference() ?: $package->getDistReference(); $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
$process = new ProcessExecutor(); $process = new ProcessExecutor();
if (0 === $process->execute('git log -n1 --pretty=%ct '.escapeshellarg($sourceRef), $output, $path)) { if (0 === $process->execute('git log -n1 --pretty=%ct '.escapeshellarg($sourceRef), $output, $path)) {
$spec['time'] = trim($output); $datetime = new \DateTime('@'.$output, new \DateTimeZone('UTC'));
$spec['time'] = $datetime->format('Y-m-d H:i:s');
} }
} }
} }

View File

@ -140,7 +140,7 @@ class GitDriver extends VcsDriver
if (!isset($composer['time'])) { if (!isset($composer['time'])) {
$this->process->execute(sprintf('git log -1 --format=%%at %s', escapeshellarg($identifier)), $output, $this->repoDir); $this->process->execute(sprintf('git log -1 --format=%%at %s', escapeshellarg($identifier)), $output, $this->repoDir);
$date = new \DateTime('@'.trim($output)); $date = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
$composer['time'] = $date->format('Y-m-d H:i:s'); $composer['time'] = $date->format('Y-m-d H:i:s');
} }
$this->infoCache[$identifier] = $composer; $this->infoCache[$identifier] = $composer;

View File

@ -127,7 +127,7 @@ class HgDriver extends VcsDriver
if (!isset($composer['time'])) { if (!isset($composer['time'])) {
$this->process->execute(sprintf('hg log --template "{date|rfc822date}" -r %s', escapeshellarg($identifier)), $output, $this->repoDir); $this->process->execute(sprintf('hg log --template "{date|rfc822date}" -r %s', escapeshellarg($identifier)), $output, $this->repoDir);
$date = new \DateTime(trim($output)); $date = new \DateTime(trim($output), new \DateTimeZone('UTC'));
$composer['time'] = $date->format('Y-m-d H:i:s'); $composer['time'] = $date->format('Y-m-d H:i:s');
} }
$this->infoCache[$identifier] = $composer; $this->infoCache[$identifier] = $composer;

View File

@ -138,7 +138,7 @@ class SvnDriver extends VcsDriver
$output = $this->execute('svn info', $this->baseUrl . $path . $rev); $output = $this->execute('svn info', $this->baseUrl . $path . $rev);
foreach ($this->process->splitLines($output) as $line) { foreach ($this->process->splitLines($output) as $line) {
if ($line && preg_match('{^Last Changed Date: ([^(]+)}', $line, $match)) { if ($line && preg_match('{^Last Changed Date: ([^(]+)}', $line, $match)) {
$date = new \DateTime($match[1]); $date = new \DateTime($match[1], new \DateTimeZone('UTC'));
$composer['time'] = $date->format('Y-m-d H:i:s'); $composer['time'] = $date->format('Y-m-d H:i:s');
break; break;
} }