Skip to content

refactor(datetime): Standardize date/time formatting with DateUtils#4164

Merged
jamesarich merged 3 commits into
mainfrom
fix/missing-translations
Jan 8, 2026
Merged

refactor(datetime): Standardize date/time formatting with DateUtils#4164
jamesarich merged 3 commits into
mainfrom
fix/missing-translations

Conversation

@jamesarich

@jamesarich jamesarich commented Jan 8, 2026

Copy link
Copy Markdown
Collaborator

This commit centralizes and refactors date, time, and relative time formatting to use Android's built-in DateUtils and DateFormat utilities. This change ensures consistent, locale-aware formatting across the application and removes custom implementations.

Key changes include:

  • Centralized formatAgo: Moved the formatAgo function from core/model to core/ui/util and rewrote it to use DateUtils.getRelativeTimeSpanString for accurate and translatable relative time spans (e.g., "5 min. ago").
  • Locale-Aware Date/Time Pickers: Updated EditWaypointDialog to use android.text.format.DateFormat.getDateFormat(context) and getTimeFormat(context) instead of SimpleDateFormat. This respects the user's system settings for date and time formatting (e.g., MM/dd/yyyy vs. dd/MM/yyyy, 12/24-hour clock).
  • Standardized Timestamp Formatting: Replaced DateFormat.getDateTimeInstance with DateUtils.formatDateTime in various UI components like PositionLog, TracerouteLog, and MapView to provide a consistent, abbreviated date/time representation.
  • Code Cleanup: Removed now-redundant DateFormat instances and simplified function signatures by removing dateFormat parameters where it's now handled centrally.
  • String Resources: Added new string resources to improve localization.

resolves #4115 by providing a translatable "now" string

This commit centralizes and refactors date, time, and relative time formatting to use Android's built-in `DateUtils` and `DateFormat` utilities. This change ensures consistent, locale-aware formatting across the application and removes custom implementations.

Key changes include:
*   **Centralized `formatAgo`**: Moved the `formatAgo` function from `core/model` to `core/ui/util` and rewrote it to use `DateUtils.getRelativeTimeSpanString` for accurate and translatable relative time spans (e.g., "5 min. ago").
*   **Locale-Aware Date/Time Pickers**: Updated `EditWaypointDialog` to use `android.text.format.DateFormat.getDateFormat(context)` and `getTimeFormat(context)` instead of `SimpleDateFormat`. This respects the user's system settings for date and time formatting (e.g., MM/dd/yyyy vs. dd/MM/yyyy, 12/24-hour clock).
*   **Standardized Timestamp Formatting**: Replaced `DateFormat.getDateTimeInstance` with `DateUtils.formatDateTime` in various UI components like `PositionLog`, `TracerouteLog`, and `MapView` to provide a consistent, abbreviated date/time representation.
*   **Code Cleanup**: Removed now-redundant `DateFormat` instances and simplified function signatures by removing `dateFormat` parameters where it's now handled centrally.
*   **String Resources**: Added new string resources for the debugging screens to improve localization.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@github-actions github-actions Bot added the bugfix PR tag label Jan 8, 2026
@codecov

codecov Bot commented Jan 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (d245246) to head (0b34e2e).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #4164   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files          2       2           
  Lines         19      19           
  Branches       7       7           
=====================================
  Misses        19      19           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Improves the `formatAgo` utility to display "now" for timestamps less than a minute ago.

Previously, `formatAgo` would display "0 min. ago". This change makes the function a Composable to access string resources and adds logic to return "now" for very recent times, providing a more intuitive user experience. A new string resource for "now" has been added.

resolves #4115

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Removes the `@Composable` annotation from the `formatAgo` utility function. This change allows it to be called from non-composable contexts.

The implementation is updated to use a direct `getString` call for string resources instead of the composable `stringResource`.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@jamesarich jamesarich marked this pull request as ready for review January 8, 2026 18:43
@jamesarich jamesarich added this pull request to the merge queue Jan 8, 2026
Merged via the queue into main with commit 02cf1f1 Jan 8, 2026
6 checks passed
@jamesarich jamesarich deleted the fix/missing-translations branch January 8, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: hardcoded english strings : last heard -> now.

1 participant