fix: emit export pickup times as clock readings without an offset
This commit is contained in:
1 parent
6c700ea18b
commit
ede8fd840a
6 files changed
+136
-27
No files matched your search
@@ -193,6 +193,10 @@ class ProductExportBuilder
|
||||
* getPickups() resolves both zeit shapes and rolls a bare time past midnight onto the
|
||||
* next day. Entries with id 0 are kept: the consumer drops them itself.
|
||||
*
|
||||
* `datetime` is BusPro's clock reading, without an offset. Resolving in Europe/Berlin
|
||||
* would move a bare 02:45 on the spring-forward night to 03:45, so the dates are
|
||||
* resolved in UTC, where no time is skipped or repeated.
|
||||
*
|
||||
* @param array<int|string, Pickup> $masterData
|
||||
* @param array<int, true> $pickupsWithoutMasterData
|
||||
*
|
||||
@@ -201,8 +205,9 @@ class ProductExportBuilder
|
||||
private function buildPickups(Crawler $dateNode, \DateTimeImmutable $dateFrom, array $masterData, array &$pickupsWithoutMasterData): array
|
||||
{
|
||||
$resolved = [];
|
||||
$clockDate = new \DateTimeImmutable($dateFrom->format('Y-m-d'), new \DateTimeZone('UTC'));
|
||||
|
||||
foreach ($this->travelParser->getPickups($this->productExportParser->children($dateNode, 'zustiege/zustieg'), $dateFrom, true) as $pickup) {
|
||||
foreach ($this->travelParser->getPickups($this->productExportParser->children($dateNode, 'zustiege/zustieg'), $clockDate, true) as $pickup) {
|
||||
$pickupId = (int) $pickup->id;
|
||||
$details = $masterData[$pickupId] ?? null;
|
||||
|
||||
@@ -216,7 +221,7 @@ class ProductExportBuilder
|
||||
'city' => $details?->city,
|
||||
'street' => $details?->street,
|
||||
'price' => $pickup->price,
|
||||
'datetime' => $pickup->time?->format('c'),
|
||||
'datetime' => $pickup->time?->format('Y-m-d\TH:i:s'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -144,8 +144,15 @@ class TravelExportBuilder
|
||||
// getPickups() is what buys stringToDateTimeFuzzy() for both zeit shapes and
|
||||
// adjustOvernightTimes(), which rolls an 02:15 listed after a 23:59 onto the next
|
||||
// calendar day. Resolved once per travel date, then shared by its hotel rows.
|
||||
//
|
||||
// Resolved in UTC: the times are BusPro's clock readings, and in Europe/Berlin a
|
||||
// bare 02:45 on the spring-forward night would move to 03:45.
|
||||
$pickups = $this->buildPickups(
|
||||
$this->travelParser->getPickups($node->filterXPath('.//zustiege/zustieg'), $dateFrom, true),
|
||||
$this->travelParser->getPickups(
|
||||
$node->filterXPath('.//zustiege/zustieg'),
|
||||
new \DateTimeImmutable($dateFrom->format('Y-m-d'), new \DateTimeZone('UTC')),
|
||||
true,
|
||||
),
|
||||
$pickupMasterData,
|
||||
$pickupsWithoutMasterData,
|
||||
);
|
||||
@@ -234,8 +241,9 @@ class TravelExportBuilder
|
||||
'street' => $details?->street,
|
||||
'time' => $pickup->time?->format('H:i'),
|
||||
// Emitted for time-only sources too: adjustOvernightTimes() has already
|
||||
// worked out the real day, and a null here would throw that away.
|
||||
'datetime' => $pickup->time?->format('c'),
|
||||
// worked out the real day, and a null here would throw that away. A clock
|
||||
// reading without an offset, like `time`.
|
||||
'datetime' => $pickup->time?->format('Y-m-d\TH:i:s'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user