Skip to content

Commit a94fbbb

Browse files
committed
Fixes #697
1 parent 0ea58de commit a94fbbb

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

module/Administration/view/administration/op-sups/index.phtml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ $formatterHour = \IntlDateFormatter::create(
1111
'HH:mm'
1212
);
1313

14+
$formatterHourLoc = \IntlDateFormatter::create(
15+
\Locale::getDefault(),
16+
\IntlDateFormatter::FULL,
17+
\IntlDateFormatter::FULL,
18+
new \DateTimeZone('Europe/Paris'),
19+
\IntlDateFormatter::GREGORIAN,
20+
'HH:mm'
21+
);
22+
23+
1424
?>
1525

1626
<div class="container-fluid">
@@ -100,7 +110,7 @@ $formatterHour = \IntlDateFormatter::create(
100110
<th>Id</th>
101111
<th data-sort="string" data-autosort="true">Type</th>
102112
<th data-sort="string">Zone qualif.</th>
103-
<th>Heure</th>
113+
<th>Heure locale</th>
104114
<th><a class="btn btn-xs btn-primary" href="#shifthour-container" data-toggle="modal" id="add-shifthour">Ajouter</a></th>
105115
</tr>
106116
</thead>
@@ -111,7 +121,7 @@ $formatterHour = \IntlDateFormatter::create(
111121
echo '<td>' . $shifthour->getId() . '</td>';
112122
echo '<td>' . $shifthour->getOpsuptype()->getName() . '</td>';
113123
echo '<td>' . ($shifthour->getQualificationzone() == null ? '' : $shifthour->getQualificationzone()->getName()) . '</td>';
114-
echo '<td>' . $formatterHour->format($shifthour->getHour()) . '</td>';
124+
echo '<td>' . $formatterHourLoc->format($shifthour->getHour()) . '</td>';
115125
echo '<td>';
116126
echo "<a
117127
title=\"Modifier\"

module/Application/src/Application/Controller/EventsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,15 +2314,15 @@ public function getshifthoursAction() {
23142314
'id' => $shifthour->getId(),
23152315
'name' => $shifthour->getOpSupType()->getName(),
23162316
'zone' => $shifthour->getQualificationZone()->getName(),
2317-
'hour' => $shifthour->getFormattedHour()
2317+
'hour' => $shifthour->getFormattedHourUTC()
23182318
);
23192319
}
23202320
} else {
23212321
$shifthours[] = array(
23222322
'id' => $shifthour->getId(),
23232323
'name' => $shifthour->getOpSupType()->getName(),
23242324
'zone' => '',
2325-
'hour' => $shifthour->getFormattedHour()
2325+
'hour' => $shifthour->getFormattedHourUTC()
23262326
);
23272327
}
23282328
//inutile de vérifier les autres rôles

module/Application/src/Application/Entity/ShiftHour.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class ShiftHour
6666
* @Annotation\Type("Zend\Form\Element\Text") //type=time not supported by Firefox...
6767
* @Annotation\Required(true)
6868
* @Annotation\Options({"label":"Heure", "format" : "H:i"})
69+
* @Annotation\Attributes({"placeholder":"Heure locale Europe/Paris"})
6970
*/
7071
protected $hour;
7172

@@ -96,10 +97,25 @@ public function setQualificationzone($qualificationzone)
9697

9798
public function getHour()
9899
{
99-
return $this->hour;
100+
$datetime = new \DateTime();
101+
$datetime->setTime($this->hour->format('H'), $this->hour->format('i'));
102+
return $datetime;
100103
}
101104

102105
public function getFormattedHour() {
106+
$formatterHour = \IntlDateFormatter::create(
107+
\Locale::getDefault(),
108+
\IntlDateFormatter::FULL,
109+
\IntlDateFormatter::FULL,
110+
new \DateTimeZone('Europe/Paris'),
111+
\IntlDateFormatter::GREGORIAN,
112+
'HH:mm'
113+
);
114+
return $formatterHour->format($this->getHour());
115+
}
116+
117+
public function getFormattedHourUTC() {
118+
error_log(print_r($this->getHour(), true));
103119
$formatterHour = \IntlDateFormatter::create(
104120
\Locale::getDefault(),
105121
\IntlDateFormatter::FULL,
@@ -119,7 +135,7 @@ public function setHour($hour)
119135
/**
120136
* @ORM\PostLoad
121137
*/
122-
public function doCorrectUTC()
138+
/* public function doCorrectUTC()
123139
{
124140
// les dates sont stockées sans information de timezone, on considère par convention qu'elles sont en UTC
125141
// mais à la création php les crée en temps local, il faut donc les corriger
@@ -128,7 +144,7 @@ public function doCorrectUTC()
128144
$this->hour->setTimezone(new \DateTimeZone("UTC"));
129145
$this->hour->add(new \DateInterval("PT" . $offset . "S"));
130146
}
131-
}
147+
}*/
132148

133149
public function getArrayCopy()
134150
{

0 commit comments

Comments
 (0)