Skip to content

Use system default date format everywhere#861

Merged
Crustack merged 2 commits into
mainfrom
fix/858
Feb 22, 2026
Merged

Use system default date format everywhere#861
Crustack merged 2 commits into
mainfrom
fix/858

Conversation

@Crustack
Copy link
Copy Markdown
Owner

@Crustack Crustack commented Feb 22, 2026

Fixes #858

Summary by CodeRabbit

  • Refactor
    • Unified date/time formatting across the app: legacy formatter removed and a single default-backed formatter now used.
    • Date displays updated in reminders, notes, settings, alarm logs, and background jobs for more consistent, predictable timestamps shown to users.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 22, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Removed the Date.toText() extension and replaced its call sites with Date.format(). Date.format() now has a default parameter DateFormat.TIMESTAMP_SHORT, and imports across UI, view holders, utilities, fragments/activities, and workers were updated accordingly.

Changes

Cohort / File(s) Summary
Extension Functions
app/src/main/java/com/philkes/notallyx/data/model/ModelExtensions.kt, app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt
Deleted Date.toText() and added a default parameter to Date.format(dateFormat: DateFormat = DateFormat.TIMESTAMP_SHORT).
Fragments & Activities
app/src/main/java/com/philkes/notallyx/presentation/activity/main/fragment/settings/SettingsFragment.kt, app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/RemindersActivity.kt
Replaced toText() usages with format() and updated imports; formatting now uses the default when no argument is provided.
View Holders
app/src/main/java/com/philkes/notallyx/presentation/view/main/BaseNoteVH.kt, app/src/main/java/com/philkes/notallyx/presentation/view/main/reminder/NoteReminderVH.kt, app/src/main/java/com/philkes/notallyx/presentation/view/main/reminder/ReminderVH.kt
Swapped toText()format() for reminder/notification text bindings; only import and call-site updates.
Utilities & Workers
app/src/main/java/com/philkes/notallyx/utils/AlarmExtensions.kt, app/src/main/java/com/philkes/notallyx/utils/AutoRemoveDeletedNotesWorker.kt
Updated log messages and string formatting to use format() instead of removed toText(); imports adjusted.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I nibbled lines of code at dawn,
swapped an old date voice for a new song.
TIMESTAMP_SHORT leads where reminders play,
hopping bytes to brighten the day.
Tiny paws, a joyful sway.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Use system default date format everywhere' clearly and accurately describes the main change: replacing the custom toText() formatting with a system default format() function across all date/time displays.
Linked Issues check ✅ Passed The PR addresses issue #858 by replacing Date.toText() with Date.format(dateFormat = DateFormat.TIMESTAMP_SHORT) across all usages, where TIMESTAMP_SHORT respects the system's locale settings for date/time display.
Out of Scope Changes check ✅ Passed All changes are directly related to the objective of using system default date formats. The modifications consistently replace custom toText() calls with format() that uses locale-aware defaults.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/858

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt (1)

601-616: ⚠️ Potential issue | 🟠 Major

Replace java.text.DateFormat.getDateTimeInstance(SHORT, SHORT) with Android's time format API to honor system 24-hour setting

java.text.DateFormat.getDateTimeInstance(SHORT, SHORT) formats based on locale but does not respect Android's system "Use 24-hour format" setting (Settings → Date & time). This affects all devices: a user in en_US locale with 24-hour format enabled will still see 12-hour time (h:mm a) instead of 24-hour time (HH:mm).

The Android-idiomatic fix is to use android.text.format.DateFormat.getTimeFormat(context) for the time portion, which respects the system setting:

DateFormat.TIMESTAMP_SHORT ->
    android.text.format.DateFormat.getTimeFormat(context).format(this) + " " +
    java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT).format(this)

Alternatively, use android.text.format.DateFormat.getBestDateTimePattern(locale, skeleton) where skeleton is "yMdHm" (24-hour) or "yMdhm" (12-hour), determined by android.text.format.DateFormat.is24HourFormat(context).

Note: This requires passing Context to the Date.format() extension; refactor its signature if needed. The codebase already demonstrates awareness of this pattern in TimePickerFragment.kt.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt` around
lines 601 - 616, The TIMESTAMP_SHORT branch in the Date.format extension uses
java.text.DateFormat.getDateTimeInstance(SHORT, SHORT) which ignores Android’s
system 24-hour setting; change the Date.format signature to accept a Context and
update DateFormat.TIMESTAMP_SHORT to build the string using
android.text.format.DateFormat.getTimeFormat(context).format(this) for the time
portion combined with
java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT).format(this)
for the date portion (or alternatively use
android.text.format.DateFormat.getBestDateTimePattern(locale, skeleton) with
android.text.format.DateFormat.is24HourFormat(context)); update all callers of
Date.format(...) accordingly and use TimePickerFragment.kt as a reference for
the pattern.
🧹 Nitpick comments (1)
app/src/main/java/com/philkes/notallyx/utils/AlarmExtensions.kt (1)

15-15: utils layer importing from presentation layer — optional refactor

format() is defined in com.philkes.notallyx.presentation and is now imported into AlarmExtensions (and AutoRemoveDeletedNotesWorker) for debug log strings only. This introduces a utils → presentation dependency that inverts the typical layer direction.

Consider extracting a thin, context-free formatting helper (e.g., an internal extension in a utils sub-package, or in ModelExtensions) that both the presentation and utils layers can share, keeping the presentation package as a leaf consumer rather than a dependency of utils.

Since these calls are debug log-only, the practical runtime impact is zero, but the layer coupling is worth addressing in a follow-up.

Also applies to: 27-27, 34-34

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/philkes/notallyx/utils/AlarmExtensions.kt` at line 15,
The utils layer is importing presentation.format(), creating an inverted
dependency; move the formatting logic into a shared, context-free extension that
both layers can use (e.g., create an internal extension function named format()
in a utils sub-package or ModelExtensions) and replace imports in
AlarmExtensions and AutoRemoveDeletedNotesWorker to use that new shared helper;
ensure the new helper has the same signature/behavior so calls in
AlarmExtensions.format() references and AutoRemoveDeletedNotesWorker continue to
work without importing com.philkes.notallyx.presentation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@app/src/main/java/com/philkes/notallyx/utils/AutoRemoveDeletedNotesWorker.kt`:
- Around line 42-43: In AutoRemoveDeletedNotesWorker (the log call building the
message with "Removing notes that have been deleted for $days days or more
(since: ${Date(before).format()"), close the unbalanced parenthesis in the log
string by appending a ')' after Date(before).format(), e.g. change the message
to "Removing notes that have been deleted for $days days or more (since:
${Date(before).format()})" so the logged output is well-formed.

---

Outside diff comments:
In `@app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt`:
- Around line 601-616: The TIMESTAMP_SHORT branch in the Date.format extension
uses java.text.DateFormat.getDateTimeInstance(SHORT, SHORT) which ignores
Android’s system 24-hour setting; change the Date.format signature to accept a
Context and update DateFormat.TIMESTAMP_SHORT to build the string using
android.text.format.DateFormat.getTimeFormat(context).format(this) for the time
portion combined with
java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT).format(this)
for the date portion (or alternatively use
android.text.format.DateFormat.getBestDateTimePattern(locale, skeleton) with
android.text.format.DateFormat.is24HourFormat(context)); update all callers of
Date.format(...) accordingly and use TimePickerFragment.kt as a reference for
the pattern.

---

Duplicate comments:
In
`@app/src/main/java/com/philkes/notallyx/utils/AutoRemoveDeletedNotesWorker.kt`:
- Line 12: AutoRemoveDeletedNotesWorker.kt currently imports
com.philkes.notallyx.presentation.format which creates a utils → presentation
layer dependency; remove that import and either (a) move the format function
into a utils-level package (e.g., utils.formatter) and call that from
AutoRemoveDeletedNotesWorker, or (b) add a small formatting helper or use
standard DateTimeFormatter inside AutoRemoveDeletedNotesWorker so it depends
only on utils. Update references to format in AutoRemoveDeletedNotesWorker and
mirror the same refactor applied to AlarmExtensions.kt to keep layering
consistent.

---

Nitpick comments:
In `@app/src/main/java/com/philkes/notallyx/utils/AlarmExtensions.kt`:
- Line 15: The utils layer is importing presentation.format(), creating an
inverted dependency; move the formatting logic into a shared, context-free
extension that both layers can use (e.g., create an internal extension function
named format() in a utils sub-package or ModelExtensions) and replace imports in
AlarmExtensions and AutoRemoveDeletedNotesWorker to use that new shared helper;
ensure the new helper has the same signature/behavior so calls in
AlarmExtensions.format() references and AutoRemoveDeletedNotesWorker continue to
work without importing com.philkes.notallyx.presentation.

Comment thread app/src/main/java/com/philkes/notallyx/utils/AutoRemoveDeletedNotesWorker.kt Outdated
Crustack and others added 2 commits February 22, 2026 13:31
…NotesWorker.kt

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use default datetime format for reminders

1 participant