From 85b7b83a6a303e8ce2d4fb3dfd7e9ed02a443894 Mon Sep 17 00:00:00 2001 From: Jack Greenlee Date: Wed, 25 Sep 2024 02:10:58 -0400 Subject: [PATCH] rename util -> datetimeUtil --- www/__tests__/{util.ts => datetimeUtil.test.ts} | 2 +- www/js/TimelineContext.ts | 2 +- www/js/config/useImperialConfig.ts | 2 +- www/js/{util.ts => datetimeUtil.ts} | 0 www/js/diary/diaryHelper.ts | 2 +- www/js/diary/list/DateSelect.tsx | 2 +- www/js/diary/list/TimelineScrollList.tsx | 2 +- www/js/diary/useDerivedProperties.tsx | 2 +- www/js/metrics/MetricsTab.tsx | 2 +- www/js/metrics/SummaryCard.tsx | 2 +- www/js/metrics/footprint/FootprintComparisonCard.tsx | 2 +- www/js/metrics/footprint/FootprintSection.tsx | 2 +- www/js/metrics/footprint/WeeklyFootprintCard.tsx | 2 +- www/js/metrics/metricsHelper.ts | 7 ++++++- www/js/metrics/movement/WeeklyActiveMinutesCard.tsx | 2 +- www/js/survey/enketo/AddedNotesList.tsx | 2 +- 16 files changed, 20 insertions(+), 15 deletions(-) rename www/__tests__/{util.ts => datetimeUtil.test.ts} (94%) rename www/js/{util.ts => datetimeUtil.ts} (100%) diff --git a/www/__tests__/util.ts b/www/__tests__/datetimeUtil.test.ts similarity index 94% rename from www/__tests__/util.ts rename to www/__tests__/datetimeUtil.test.ts index 0a8678a34..6d3fab6f2 100644 --- a/www/__tests__/util.ts +++ b/www/__tests__/datetimeUtil.test.ts @@ -1,4 +1,4 @@ -import { formatForDisplay } from '../js/util'; +import { formatForDisplay } from '../js/datetimeUtil'; describe('util.ts', () => { describe('formatForDisplay', () => { diff --git a/www/js/TimelineContext.ts b/www/js/TimelineContext.ts index 2a94d2b0b..9b53d2a27 100644 --- a/www/js/TimelineContext.ts +++ b/www/js/TimelineContext.ts @@ -22,7 +22,7 @@ import { getNotDeletedCandidates, mapInputsToTimelineEntries } from './survey/in import { EnketoUserInputEntry } from './survey/enketo/enketoHelper'; import { primarySectionForTrip } from './diary/diaryHelper'; import useAppStateChange from './useAppStateChange'; -import { isoDateRangeToTsRange, isoDateWithOffset } from './util'; +import { isoDateRangeToTsRange, isoDateWithOffset } from './datetimeUtil'; import { base_modes } from 'e-mission-common'; const TODAY_DATE = DateTime.now().toISODate(); diff --git a/www/js/config/useImperialConfig.ts b/www/js/config/useImperialConfig.ts index 900c9854e..ba32ccec2 100644 --- a/www/js/config/useImperialConfig.ts +++ b/www/js/config/useImperialConfig.ts @@ -1,6 +1,6 @@ import React, { useMemo } from 'react'; import useAppConfig from '../useAppConfig'; -import { formatForDisplay } from '../util'; +import { formatForDisplay } from '../datetimeUtil'; export type ImperialConfig = { distanceSuffix: string; diff --git a/www/js/util.ts b/www/js/datetimeUtil.ts similarity index 100% rename from www/js/util.ts rename to www/js/datetimeUtil.ts diff --git a/www/js/diary/diaryHelper.ts b/www/js/diary/diaryHelper.ts index e182835c4..b6510f288 100644 --- a/www/js/diary/diaryHelper.ts +++ b/www/js/diary/diaryHelper.ts @@ -4,7 +4,7 @@ import { LabelOptions } from '../types/labelTypes'; import { LocalDt } from '../types/serverData'; import { ImperialConfig } from '../config/useImperialConfig'; import { base_modes } from 'e-mission-common'; -import { humanizeIsoRange } from '../util'; +import { humanizeIsoRange } from '../datetimeUtil'; export type BaseModeKey = string; // TODO figure out how to get keyof typeof base_modes.BASE_MODES diff --git a/www/js/diary/list/DateSelect.tsx b/www/js/diary/list/DateSelect.tsx index 2f629b3d1..52cebe63e 100644 --- a/www/js/diary/list/DateSelect.tsx +++ b/www/js/diary/list/DateSelect.tsx @@ -19,7 +19,7 @@ import { Text, useTheme } from 'react-native-paper'; import i18next from 'i18next'; import { useTranslation } from 'react-i18next'; import { NavBarButton } from '../../components/NavBar'; -import { formatIsoNoYear, isoDateRangeToTsRange } from '../../util'; +import { formatIsoNoYear, isoDateRangeToTsRange } from '../../datetimeUtil'; // formats as e.g. 'Aug 1' const MONTH_DAY_SHORT: Intl.DateTimeFormatOptions = { diff --git a/www/js/diary/list/TimelineScrollList.tsx b/www/js/diary/list/TimelineScrollList.tsx index 98f12d139..e640b2b11 100644 --- a/www/js/diary/list/TimelineScrollList.tsx +++ b/www/js/diary/list/TimelineScrollList.tsx @@ -7,7 +7,7 @@ import { ActivityIndicator, Banner, Button, Icon, Text } from 'react-native-pape import LoadMoreButton from './LoadMoreButton'; import { useTranslation } from 'react-i18next'; import TimelineContext from '../../TimelineContext'; -import { isoDateRangeToTsRange, isoDateWithOffset } from '../../util'; +import { isoDateRangeToTsRange, isoDateWithOffset } from '../../datetimeUtil'; import { DateTime } from 'luxon'; function renderCard({ item: listEntry, index }) { diff --git a/www/js/diary/useDerivedProperties.tsx b/www/js/diary/useDerivedProperties.tsx index fb9cf5c88..3a46f7cca 100644 --- a/www/js/diary/useDerivedProperties.tsx +++ b/www/js/diary/useDerivedProperties.tsx @@ -7,7 +7,7 @@ import { primarySectionForTrip, } from './diaryHelper'; import TimelineContext from '../TimelineContext'; -import { formatIsoNoYear, formatIsoWeekday, humanizeIsoRange, isoDatesDifference } from '../util'; +import { formatIsoNoYear, formatIsoWeekday, humanizeIsoRange } from '../datetimeUtil'; const useDerivedProperties = (tlEntry) => { const imperialConfig = useImperialConfig(); diff --git a/www/js/metrics/MetricsTab.tsx b/www/js/metrics/MetricsTab.tsx index d4fdddc35..65a0bb847 100644 --- a/www/js/metrics/MetricsTab.tsx +++ b/www/js/metrics/MetricsTab.tsx @@ -14,7 +14,7 @@ import { metrics_summaries } from 'e-mission-common'; import MetricsScreen from './MetricsScreen'; import { LabelOptions } from '../types/labelTypes'; import { useAppTheme } from '../appTheme'; -import { isoDatesDifference } from '../util'; +import { isoDatesDifference } from '../datetimeUtil'; const N_DAYS_TO_LOAD = 14; // 2 weeks export const DEFAULT_METRIC_LIST: MetricList = { diff --git a/www/js/metrics/SummaryCard.tsx b/www/js/metrics/SummaryCard.tsx index 753674e35..577f2ee97 100644 --- a/www/js/metrics/SummaryCard.tsx +++ b/www/js/metrics/SummaryCard.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { View, StyleSheet } from 'react-native'; import { Card, Text } from 'react-native-paper'; -import { formatForDisplay } from '../util'; +import { formatForDisplay } from '../datetimeUtil'; import { colors } from '../appTheme'; import { t } from 'i18next'; import { FootprintGoal } from '../types/appConfigTypes'; diff --git a/www/js/metrics/footprint/FootprintComparisonCard.tsx b/www/js/metrics/footprint/FootprintComparisonCard.tsx index 344a94164..0dfd4bc42 100644 --- a/www/js/metrics/footprint/FootprintComparisonCard.tsx +++ b/www/js/metrics/footprint/FootprintComparisonCard.tsx @@ -5,7 +5,7 @@ import BarChart from '../../components/BarChart'; import { useTranslation } from 'react-i18next'; import { ChartRecord } from '../../components/Chart'; import TimelineContext from '../../TimelineContext'; -import { formatIsoNoYear } from '../../util'; +import { formatIsoNoYear } from '../../datetimeUtil'; const FootprintComparisonCard = ({ type, diff --git a/www/js/metrics/footprint/FootprintSection.tsx b/www/js/metrics/footprint/FootprintSection.tsx index 111ec0b30..ce97c99e5 100644 --- a/www/js/metrics/footprint/FootprintSection.tsx +++ b/www/js/metrics/footprint/FootprintSection.tsx @@ -6,7 +6,7 @@ import SummaryCard from '../SummaryCard'; import { useTranslation } from 'react-i18next'; import { sumMetricEntries } from '../metricsHelper'; import TimelineContext from '../../TimelineContext'; -import { formatIso, isoDatesDifference } from '../../util'; +import { formatIso, isoDatesDifference } from '../../datetimeUtil'; import WeeklyFootprintCard from './WeeklyFootprintCard'; import useAppConfig from '../../useAppConfig'; import { getFootprintGoals } from './footprintHelper'; diff --git a/www/js/metrics/footprint/WeeklyFootprintCard.tsx b/www/js/metrics/footprint/WeeklyFootprintCard.tsx index 5f4968f1a..d3005362d 100644 --- a/www/js/metrics/footprint/WeeklyFootprintCard.tsx +++ b/www/js/metrics/footprint/WeeklyFootprintCard.tsx @@ -10,7 +10,7 @@ import { sumMetricEntries, trimGroupingPrefix, } from '../metricsHelper'; -import { formatIsoNoYear, isoDateWithOffset } from '../../util'; +import { formatIsoNoYear, isoDateWithOffset } from '../../datetimeUtil'; import { useTranslation } from 'react-i18next'; import BarChart from '../../components/BarChart'; import { ChartRecord } from '../../components/Chart'; diff --git a/www/js/metrics/metricsHelper.ts b/www/js/metrics/metricsHelper.ts index f0cc458c5..fc759f320 100644 --- a/www/js/metrics/metricsHelper.ts +++ b/www/js/metrics/metricsHelper.ts @@ -6,7 +6,12 @@ import { MetricName, groupingFields } from '../types/appConfigTypes'; import { ImperialConfig } from '../config/useImperialConfig'; import i18next from 'i18next'; import { base_modes, metrics_summaries } from 'e-mission-common'; -import { formatForDisplay, formatIsoNoYear, isoDatesDifference, isoDateWithOffset } from '../util'; +import { + formatForDisplay, + formatIsoNoYear, + isoDatesDifference, + isoDateWithOffset, +} from '../datetimeUtil'; import { LabelOptions, RichMode } from '../types/labelTypes'; import { labelOptions, textToLabelKey } from '../survey/multilabel/confirmHelper'; import { UNCERTAIN_OPACITY } from '../components/charting'; diff --git a/www/js/metrics/movement/WeeklyActiveMinutesCard.tsx b/www/js/metrics/movement/WeeklyActiveMinutesCard.tsx index 3fcdade74..bce6db844 100644 --- a/www/js/metrics/movement/WeeklyActiveMinutesCard.tsx +++ b/www/js/metrics/movement/WeeklyActiveMinutesCard.tsx @@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next'; import BarChart from '../../components/BarChart'; import { labelKeyToText } from '../../survey/multilabel/confirmHelper'; import TimelineContext from '../../TimelineContext'; -import { formatIsoNoYear, isoDateWithOffset } from '../../util'; +import { formatIsoNoYear, isoDateWithOffset } from '../../datetimeUtil'; type Props = { userMetrics?: MetricsData; activeModes: string[] }; const WeeklyActiveMinutesCard = ({ userMetrics, activeModes }: Props) => { diff --git a/www/js/survey/enketo/AddedNotesList.tsx b/www/js/survey/enketo/AddedNotesList.tsx index caf53e89c..49e883cf5 100644 --- a/www/js/survey/enketo/AddedNotesList.tsx +++ b/www/js/survey/enketo/AddedNotesList.tsx @@ -11,7 +11,7 @@ import EnketoModal from './EnketoModal'; import { useTranslation } from 'react-i18next'; import { EnketoUserInputEntry } from './enketoHelper'; import { displayErrorMsg, logDebug } from '../../plugin/logger'; -import { formatIsoNoYear, isoDatesDifference } from '../../util'; +import { formatIsoNoYear, isoDatesDifference } from '../../datetimeUtil'; type Props = { timelineEntry: any;