Match Angular duration format + UTC offset + scheduled path time

- formatDuration(locale='ru') now emits 'Xч. Xмин.' (and 'Xд. Xч. Xмин.')
  with trailing dots, matching Angular's DurationPipe + SHARED.SHORT-HOUR
  translations. Every 'В пути', 'До прилета', and 'Время в пути' label on
  the details page now reads identically to Angular.
- FlightSchedule shows the SCHEDULED duration (dep→arr from the timestamps)
  instead of the actual flyingTime the API reports, so the Расписание рейса
  row reads '1ч. 30мин.' for a 15:30→17:00 schedule even after an early
  landing. The Вылет / Прилет columns also surface the 'UTC+HH:MM' offset
  below each time, matching the Angular layout.
This commit is contained in:
2026-04-18 21:11:58 +03:00
parent b6920cbf60
commit f4b4c53816
6 changed files with 56 additions and 24 deletions
+4 -4
View File
@@ -19,12 +19,12 @@ describe("formatDuration", () => {
expect(formatDuration(1572)).toBe("1d 2h 12m");
});
it("formats in Russian locale", () => {
expect(formatDuration(150, "ru")).toBe("2ч 30м");
it("formats in Russian locale (Angular parity: 'Xч. Xмин.')", () => {
expect(formatDuration(150, "ru")).toBe("2ч. 30мин.");
});
it("formats days in Russian locale", () => {
expect(formatDuration(1572, "ru")).toBe("1д 2ч 12м");
it("formats days in Russian locale (Angular parity: 'Xд. Xч. Xмин.')", () => {
expect(formatDuration(1572, "ru")).toBe("1д.. 12мин.");
});
it("returns 'Unknown' for negative values", () => {
+4 -2
View File
@@ -7,9 +7,11 @@
/**
* Format a duration given in total minutes into a human-readable string.
* Russian units mirror Angular's DurationPipe (SHORT-DAY='д.', SHORT-HOUR='ч.',
* SHORT-MIN='мин.') so values read as '1ч. 30мин.' not '1ч 30м'.
*
* @example formatDuration(150) => "2h 30m"
* @example formatDuration(150, "ru") => "2ч 30м"
* @example formatDuration(150, "ru") => "2ч. 30мин."
* @example formatDuration(0) => "0h 0m"
*/
export function formatDuration(
@@ -24,7 +26,7 @@ export function formatDuration(
const units =
locale === "ru"
? { d: "д", h: "ч", m: "м" }
? { d: .", h: .", m: ин." }
: { d: "d", h: "h", m: "m" };
const daysPart = days > 0 ? `${days}${units.d} ` : "";