Colota - Android GPS Location tracker
fix(history): name exported trips after the local day (#1007)
Max Dietrich6a4a4af48b20
diff --git a/apps/mobile/jest.config.js b/apps/mobile/jest.config.jsindex 74ced66a..bd8a6ebb 100644--- a/apps/mobile/jest.config.js+++ b/apps/mobile/jest.config.js@@ -1,3 +1,6 @@+// UTC+9:30 with no DST: a local midnight read through UTC (toISOString) lands on the previous day on every runner.+process.env.TZ = "Australia/Darwin"+module.exports = {preset: "@react-native/jest-preset",setupFiles: ["./jest.setup.js"]diff --git a/apps/mobile/src/screens/LocationInspectorScreen.tsx b/apps/mobile/src/screens/LocationInspectorScreen.tsxindex 8b6e1efd..20e4f580 100644--- a/apps/mobile/src/screens/LocationInspectorScreen.tsx+++ b/apps/mobile/src/screens/LocationInspectorScreen.tsx@@ -271,7 +271,7 @@ export function LocationHistoryScreen({ navigation, route }: RootScreenProps<"Loasync (format: ExportFormat, tripsToExport: Trip[]) => {if (tripsToExport.length === 0) returntry {- const dateStr = mapDate.toISOString().slice(0, 10)+ const dateStr = dayKey(mapDate)const isSingle = tripsToExport.length === 1const label = isSingle ? t("history.trip", { index: tripsToExport[0].index }) : t("history.tripsLabel")const fileName = `colota_${isSingle ? `trip${tripsToExport[0].index}` : "trips"}_${dateStr}${diff --git a/apps/mobile/src/screens/TripDetailScreen.tsx b/apps/mobile/src/screens/TripDetailScreen.tsxindex 6bf8d716..d663e213 100644--- a/apps/mobile/src/screens/TripDetailScreen.tsx+++ b/apps/mobile/src/screens/TripDetailScreen.tsx@@ -33,6 +33,7 @@ import {} from "../utils/trips"import { formatDate, formatDistance, formatDuration, formatShortDistance, formatSpeed, formatTime } from "../utils/geo"import { EXPORT_FORMATS, type ExportFormat } from "../utils/exportConverters"+import { dayKey } from "../utils/inspectorDay"import { size, space } from "../constants"import { showAlert, showConfirm } from "../services/modalService"import { logger } from "../utils/logger"@@ -183,7 +184,7 @@ export function TripDetailScreen({ route, navigation }: RootScreenProps<"Trip Deconst handleExport = useCallback(async (format: ExportFormat) => {try {- const dateStr = new Date(trip.startTime * 1000).toISOString().slice(0, 10)+ const dateStr = dayKey(new Date(trip.startTime * 1000))const fileName = `colota_trip${trip.index}_${dateStr}${EXPORT_FORMATS[format].extension}`const filePath = await NativeLocationService.exportTripsToFile([{ index: trip.index, color: getTripColor(trip.index), startTs: trip.startTime, endTs: trip.endTime }],diff --git a/apps/mobile/src/screens/__tests__/LocationInspectorScreen.test.tsx b/apps/mobile/src/screens/__tests__/LocationInspectorScreen.test.tsxindex 6fd774c8..7c4ed450 100644--- a/apps/mobile/src/screens/__tests__/LocationInspectorScreen.test.tsx+++ b/apps/mobile/src/screens/__tests__/LocationInspectorScreen.test.tsx@@ -516,6 +516,21 @@ describe("export", () => {expect(queryByTestId("ExportFormatDialog")).toBeNull()})+ // Stepping, the calendar and Summary all hold a day as its local midnight, which at UTC+9:30 is the previous day in UTC.+ it("names the file after the local day shown", async () => {+ withDay()+ const props = createProps({ initialDate: new Date(2026, 9, 27).getTime() })+ const { getByTestId } = render(<LocationHistoryScreen {...props} />)+ await settled(getByTestId)++ fireEvent.press(headerRight(props).getByLabelText("Export day"))+ await act(async () => getByTestId("ExportFormatDialog").props.onSelect("gpx"))++ await waitFor(() => expect(NativeLocationService.shareFile).toHaveBeenCalled())+ expect((NativeLocationService.exportTripsToFile as jest.Mock).mock.calls[0][2]).toBe("colota_trips_2026-10-27.gpx")+ expect((NativeLocationService.shareFile as jest.Mock).mock.calls[0][2]).toContain("2026-10-27")+ })+it("exports nothing when the chooser is dismissed", async () => {withDay()const props = createProps()diff --git a/apps/mobile/src/screens/__tests__/TripDetailScreen.test.tsx b/apps/mobile/src/screens/__tests__/TripDetailScreen.test.tsxindex 177f855b..e23ab806 100644--- a/apps/mobile/src/screens/__tests__/TripDetailScreen.test.tsx+++ b/apps/mobile/src/screens/__tests__/TripDetailScreen.test.tsx@@ -373,6 +373,20 @@ describe("TripDetailScreen - header and stepper", () => {expect(queryByTestId("ExportFormatDialog")).toBeNull()})+ // jest runs at UTC+9:30: a trip starting at 01:45 there began on the previous day in UTC.+ it("names the exported file after the local day the trip started", async () => {+ const trip = { ...makeTrip(3), startTime: new Date(2026, 9, 28, 1, 45).getTime() / 1000 }+ const props = makeProps(trip)+ const { getByTestId } = render(<TripDetailScreen {...props} />)+ await act(async () => {})++ fireEvent.press(headerRight(props).getByLabelText("Export trip"))+ await act(async () => getByTestId("ExportFormatDialog").props.onSelect("gpx"))++ await waitFor(() => expect(NativeLocationService.exportTripsToFile).toHaveBeenCalled())+ expect((NativeLocationService.exportTripsToFile as jest.Mock).mock.calls[0][2]).toBe("colota_trip1_2026-10-28.gpx")+ })+it("keeps Delete in the app bar beside Export", async () => {const props = makeProps(makeTrip(3))render(<TripDetailScreen {...props} />)diff --git a/fastlane/metadata/android/en-US/changelogs/54.txt b/fastlane/metadata/android/en-US/changelogs/54.txtindex 06de0878..deec4d20 100644--- a/fastlane/metadata/android/en-US/changelogs/54.txt+++ b/fastlane/metadata/android/en-US/changelogs/54.txt@@ -1,3 +1,4 @@- Fixed text showing only its top edge on Samsung DeX and other external displays- Fixed the Bearer token label showing as asterisks in Chinese- Fixed the theme not following the system after switching dark mode while Colota was closed and tracking kept running+- Fixed exported trips being named after the previous day in time zones ahead of UTC