Commit b0eafd7d authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Correction de bug sur la gestion des dates

parent 41d91f7d
<?php
$bdd = $oa->getBdd();
$oa->exec('UnicaenTbl build-procedures');
\ No newline at end of file
......@@ -67,7 +67,7 @@ class Driver implements DriverInterface
throw $this->sendException($error);
}
$this->exec('ALTER SESSION SET NLS_DATE_FORMAT = \'yyyy-mm-dd\'');
$this->exec('ALTER SESSION SET NLS_DATE_FORMAT = \'yyyy-mm-dd hh24:mi:ss\'');
$this->exec('ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT = \'yyyy-mm-dd"T"hh24:mi:ss\'');
$this->exec('ALTER SESSION SET NLS_NUMERIC_CHARACTERS=". "');
......@@ -335,10 +335,8 @@ class Driver implements DriverInterface
case Bdd::TYPE_STRING:
return (string)$variable;
case Bdd::TYPE_DATE:
$date = \DateTime::createFromFormat('Y-m-d', $variable);
$date = \DateTime::createFromFormat('Y-m-d H:i:s', $variable);
if ($date instanceof \DateTime) {
$date->setTime(0, 0, 0);
return $date;
} else {
return $variable;
......
......@@ -455,8 +455,8 @@ class Table
foreach ($old as $c => $ov) {
$newc = isset($new[$c]) ? $new[$c] : null;
$oldc = isset($old[$c]) ? $old[$c] : null;
if ($newc instanceof \DateTime) $newc = $newc->format('Y-m-d');
if ($oldc instanceof \DateTime) $oldc = $oldc->format('Y-m-d');
if ($newc instanceof \DateTime) $newc = $newc->format('Y-m-d H:i:s');
if ($oldc instanceof \DateTime) $oldc = $oldc->format('Y-m-d H:i:s');
if ($newc != $oldc && array_key_exists($c, $new) && $c != 'ID') {
$ok = empty($options['update-cols']); // OK par défaut si une liste n'a pas été établie manuellement
......@@ -507,7 +507,7 @@ class Table
foreach ($keyArray as $v) {
if ($keyVal != '') $keyVal .= '_';
if ($v instanceof \DateTime) {
$keyVal .= $v->format('Y-m-d');
$keyVal .= $v->format('Y-m-d-H-i-s');
} else {
$keyVal .= (string)$v;
}
......
......@@ -450,7 +450,7 @@ class DataGen
foreach ($data as $i => $line) {
foreach ($line as $col => $val) {
if (isset($ddl['columns'][$col]) && $ddl['columns'][$col]['type'] == \BddAdmin\Bdd::TYPE_DATE && !empty($val) && is_string($val)) {
$data[$i][$col] = \DateTime::createFromFormat('Y-m-d', $val);
$data[$i][$col] = \DateTime::createFromFormat('Y-m-d H:i:s', $val);
}
}
......@@ -492,8 +492,8 @@ class DataGen
{
$annees = [];
for ($a = 1950; $a < 2100; $a++) {
$dateDebut = \DateTime::createFromFormat('Y-m-d:H:i:s', $a . '-09-01:00:00:00');
$dateFin = \DateTime::createFromFormat('Y-m-d:H:i:s', ($a + 1) . '-08-31:00:00:00');
$dateDebut = \DateTime::createFromFormat('Y-m-d H:i:s', $a . '-09-01 00:00:00');
$dateFin = \DateTime::createFromFormat('Y-m-d H:i:s', ($a + 1) . '-08-31 00:00:00');
$anneeRef = $this->getAnneeCourante();
$active = ($a >= $anneeRef && $a < $anneeRef + 3);
......
......@@ -9,8 +9,8 @@ return [
]],
'materialized-view' => ['includes' => [
]],
], 'excludes' => ['MV_EXT_SERVICE']],
'view' => ['includes' => [
]],
......@@ -22,8 +22,5 @@ return [
]],
'sequence' => ['includes' => [
]],
'materialized-view' => ['includes' => [
]],
];
\ No newline at end of file
......@@ -483,14 +483,14 @@ return [
[
'ID' => 1,
'VALEUR' => 40.91,
'HISTO_CREATION' => '2010-07-01',
'HISTO_MODIFICATION' => '2014-06-25',
'HISTO_CREATION' => '2010-07-01 00:00:00',
'HISTO_MODIFICATION' => '2014-06-25 00:00:00',
],
[
'ID' => 2,
'VALEUR' => 41.41,
'HISTO_CREATION' => '2017-04-28',
'HISTO_MODIFICATION' => '2017-04-28',
'HISTO_CREATION' => '2017-04-28 00:00:00',
'HISTO_MODIFICATION' => '2017-04-28 00:00:00',
],
],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment