[Pkg-owncloud-commits] [php-sabre-vobject] 244/341: Fix CS.
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 13:35:53 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabre-vobject.
commit 8999f61dc47852ce12ad25a49c768cc3263f8966
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date: Wed Jan 28 13:42:15 2015 +0100
Fix CS.
---
lib/DateTimeParser.php | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/lib/DateTimeParser.php b/lib/DateTimeParser.php
index fd59d71..bf920d7 100644
--- a/lib/DateTimeParser.php
+++ b/lib/DateTimeParser.php
@@ -94,12 +94,13 @@ class DateTimeParser {
}
if (!$asString) {
+
$invert = false;
+
if ($matches['plusminus']==='-') {
$invert = true;
}
-
$parts = [
'week',
'day',
@@ -107,47 +108,56 @@ class DateTimeParser {
'minute',
'second',
];
+
foreach($parts as $part) {
$matches[$part] = isset($matches[$part])&&$matches[$part]?(int)$matches[$part]:0;
}
-
// We need to re-construct the $duration string, because weeks and
// days are not supported by DateInterval in the same string.
$duration = 'P';
$days = $matches['day'];
+
if ($matches['week']) {
$days+=$matches['week']*7;
}
- if ($days)
+
+ if ($days) {
$duration.=$days . 'D';
+ }
if ($matches['minute'] || $matches['second'] || $matches['hour']) {
+
$duration.='T';
- if ($matches['hour'])
+ if ($matches['hour']) {
$duration.=$matches['hour'].'H';
+ }
- if ($matches['minute'])
+ if ($matches['minute']) {
$duration.=$matches['minute'].'M';
+ }
- if ($matches['second'])
+ if ($matches['second']) {
$duration.=$matches['second'].'S';
+ }
}
if ($duration==='P') {
$duration = 'PT0S';
}
+
$iv = new DateInterval($duration);
- if ($invert) $iv->invert = true;
+
+ if ($invert) {
+ $iv->invert = true;
+ }
return $iv;
}
-
-
$parts = [
'week',
'day',
@@ -157,6 +167,7 @@ class DateTimeParser {
];
$newDur = '';
+
foreach($parts as $part) {
if (isset($matches[$part]) && $matches[$part]) {
$newDur.=' '.$matches[$part] . ' ' . $part . 's';
@@ -164,9 +175,11 @@ class DateTimeParser {
}
$newDur = ($matches['plusminus']==='-'?'-':'+') . trim($newDur);
+
if ($newDur === '+') {
$newDur = '+0 seconds';
};
+
return $newDur;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git
More information about the Pkg-owncloud-commits
mailing list