diff --git a/src/frontend/lib/utils.js b/src/frontend/lib/utils.js index f34b73d1a..e480feb6b 100644 --- a/src/frontend/lib/utils.js +++ b/src/frontend/lib/utils.js @@ -50,3 +50,14 @@ export function matchPreset( if (!categoryId) return; return presets.get(categoryId); } + +export function formatDate(dateString: string): string { + const date = new Date(dateString); + const options = { + weekday: "short", + year: "numeric", + month: "short", + day: "numeric" + }; + return date.toLocaleString(options); +} diff --git a/src/frontend/screens/Observation/ObservationView.js b/src/frontend/screens/Observation/ObservationView.js index 1464b7ba2..400e6ce8c 100644 --- a/src/frontend/screens/Observation/ObservationView.js +++ b/src/frontend/screens/Observation/ObservationView.js @@ -9,6 +9,7 @@ import { EditIcon, CategoryIcon } from "../../sharedComponents/icons"; +import { formatDate } from "../../lib/utils"; import type { PresetWithFields } from "../../context/PresetsContext"; import type { Observation } from "../../context/ObservationsContext"; @@ -45,7 +46,7 @@ const ObservationView = ({ observation, preset = {} }: ODVProps) => { )} - {observation.created_at} + {formatDate(observation.created_at)} {observation.value.tags.notes} diff --git a/src/frontend/screens/ObservationsList/ObservationsListView.js b/src/frontend/screens/ObservationsList/ObservationsListView.js index fba350da6..5893b7688 100644 --- a/src/frontend/screens/ObservationsList/ObservationsListView.js +++ b/src/frontend/screens/ObservationsList/ObservationsListView.js @@ -4,6 +4,7 @@ import { View, FlatList, Dimensions, StyleSheet } from "react-native"; import memoize from "memoize-one"; import ObservationListItem from "./ObservationListItem"; +import { formatDate } from "../../lib/utils"; import type { Observation, ObservationsMap @@ -67,7 +68,7 @@ const ObservationsListView = ({ style={styles.listItem} title={name} iconId={icon} - subtitle={created_at} + subtitle={formatDate(created_at)} onPress={onPressObservation} /> );