Skip to content

Commit

Permalink
Assume two-digit year is in the current century.
Browse files Browse the repository at this point in the history
Importing two-digit years e.g. from CSV data already worked fine, but when calculating timezone offsets, DateTime really used the years from the first century A.D.
  • Loading branch information
yunosh committed Aug 31, 2017
1 parent 04df881 commit e4650ad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kronolith/lib/Event.php
Expand Up @@ -1988,6 +1988,9 @@ public function fromHash($hash)
}
if (count($time) == 3 && count($date) == 3 &&
!empty($date[1]) && !empty($date[2])) {
if ($date[0] < 100) {
$date[0] += (date('Y') / 100 | 0) * 100;
}
$this->start = new Horde_Date(
array(
'year' => $date[0],
Expand Down Expand Up @@ -2034,6 +2037,9 @@ public function fromHash($hash)
}
if (count($time) == 3 && count($date) == 3 &&
!empty($date[1]) && !empty($date[2])) {
if ($date[0] < 100) {
$date[0] += (date('Y') / 100 | 0) * 100;
}
$this->end = new Horde_Date(
array(
'year' => $date[0],
Expand Down

0 comments on commit e4650ad

Please sign in to comment.