Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19,658 changes: 9,709 additions & 9,949 deletions src/AbraFlexi/Actions.php

Large diffs are not rendered by default.

25 changes: 18 additions & 7 deletions src/AbraFlexi/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DateTime extends \DateTime
/**
* Default output format.
*/
public static string $format = 'Y-m-d\TH:i:s.u+P';
public static string $format = 'Y-m-d\TH:i:s.uP';

/**
* AbraFlexi dateTime to PHP DateTime conversion.
Expand All @@ -44,18 +44,29 @@ class DateTime extends \DateTime
public function __construct(string $flexidatetime = 'NOW')
{
$this->isNull = empty($flexidatetime);
$format = '';
if ($this->isNull) {
parent::__construct();
$this->isNull = true;
return;
}

$format = '';
if (strstr($flexidatetime, '.')) { // NewFormat
$format = self::$format;
} elseif (!empty($flexidatetime) && ($flexidatetime !== 'NOW')) { // Old format
$format = 'Y-m-d\TH:i:s+P';
} elseif ($flexidatetime !== 'NOW') { // Old format
$format = 'Y-m-d\TH:i:sP';
}

if (empty($format)) {
parent::__construct();
parent::__construct($flexidatetime);
} else {
parent::__construct(\DateTime::createFromFormat($format, $flexidatetime)->format(\DateTimeInterface::ATOM));
$sourceObject = \DateTime::createFromFormat($format, $flexidatetime);
if ($sourceObject) {
// Use a format that preserves microseconds for the parent constructor
parent::__construct($sourceObject->format('Y-m-d H:i:s.u'), $sourceObject->getTimezone());
} else {
parent::__construct($flexidatetime); // Fallback
}
}
}

Expand Down Expand Up @@ -122,4 +133,4 @@ public function toDateTime(): \DateTime

return $dateTime;
}
}
}
6,125 changes: 3,063 additions & 3,062 deletions src/AbraFlexi/EvidenceList.php

Large diffs are not rendered by default.

Loading