Skip to content

Add short ISO date format#907

Merged
Crustack merged 1 commit into
mainfrom
feat/841
Mar 8, 2026
Merged

Add short ISO date format#907
Crustack merged 1 commit into
mainfrom
feat/841

Conversation

@Crustack
Copy link
Copy Markdown
Owner

@Crustack Crustack commented Mar 8, 2026

Closes #841

Summary by CodeRabbit

  • New Features
    • Added a new date format option using ISO-8601 standard format (YYYY-MM-DD), expanding available date display choices for users.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 8, 2026

📝 Walkthrough

Walkthrough

Adds ISO-8601 date formatting (YYYY-MM-DD) support by introducing a new SHORT_ISO enum constant to the DateFormat options and implementing the corresponding formatting logic using SimpleDateFormat with US locale.

Changes

Cohort / File(s) Summary
Date Format Enhancement
app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt, app/src/main/java/com/philkes/notallyx/presentation/viewmodel/preference/Preference.kt
Adds SHORT_ISO date format support: new enum constant in DateFormat, SimpleDateFormat instance for ISO-8601 formatting (yyyy-MM-dd), and Date.format() extension logic to handle SHORT_ISO branch.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Poem

🐰 A date so clean, with dashes bright,
ISO-8601 formatted right!
SHORT_ISO hops into the fold,
YYYY-MM-DD, precise and bold. ✨

🚥 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 'Add short ISO date format' directly and clearly describes the main change: introducing a new ISO-8601 date format option.
Linked Issues check ✅ Passed The pull request successfully implements the requirement from issue #841 by adding SHORT_ISO enum constant and corresponding ISO-8601 formatting logic (yyyy-MM-dd).
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the ISO date format feature requested in issue #841; no unrelated modifications detected.

✏️ 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 feat/841

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.

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)

615-627: ⚠️ Potential issue | 🔴 Critical

Do not share a singleton SimpleDateFormat across threads.

ISO_DATE_FORMAT is a mutable global, and SimpleDateFormat is not thread-safe (per official Java and Android documentation). Since Date.format() is called from both background workers and UI code paths, this creates a real race condition on every SHORT_ISO format call.

💡 Safer fix
-private val ISO_DATE_FORMAT = SimpleDateFormat("yyyy-MM-dd", Locale.US)
+private fun createIsoDateFormat() = SimpleDateFormat("yyyy-MM-dd", Locale.US)

 fun Date.format(dateFormat: DateFormat = DateFormat.TIMESTAMP_SHORT): String {
     return when (dateFormat) {
         DateFormat.NONE -> ""
         DateFormat.RELATIVE -> PrettyTime().format(this)
         DateFormat.ABSOLUTE ->
             java.text.DateFormat.getDateInstance(java.text.DateFormat.FULL).format(this)
         DateFormat.ABSOLUTE_SHORT ->
             java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT).format(this)
-        DateFormat.SHORT_ISO -> {
-            ISO_DATE_FORMAT.format(this)
-        }
+        DateFormat.SHORT_ISO -> createIsoDateFormat().format(this)
🤖 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 615 - 627, The global ISO_DATE_FORMAT singleton is unsafe because
SimpleDateFormat is mutable and used from multiple threads; update Date.format
(handling DateFormat.SHORT_ISO) to stop using the ISO_DATE_FORMAT global—either
create a fresh SimpleDateFormat instance inside the SHORT_ISO branch, use a
ThreadLocal<SimpleDateFormat> for ISO_DATE_FORMAT, or migrate to a thread-safe
java.time formatter (DateTimeFormatter) for SHORT_ISO; ensure the change
references ISO_DATE_FORMAT and the Date.format function so all callers now get a
thread-safe formatter for DateFormat.SHORT_ISO.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt`:
- Around line 615-627: The global ISO_DATE_FORMAT singleton is unsafe because
SimpleDateFormat is mutable and used from multiple threads; update Date.format
(handling DateFormat.SHORT_ISO) to stop using the ISO_DATE_FORMAT global—either
create a fresh SimpleDateFormat instance inside the SHORT_ISO branch, use a
ThreadLocal<SimpleDateFormat> for ISO_DATE_FORMAT, or migrate to a thread-safe
java.time formatter (DateTimeFormatter) for SHORT_ISO; ensure the change
references ISO_DATE_FORMAT and the Date.format function so all callers now get a
thread-safe formatter for DateFormat.SHORT_ISO.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7488f971-c200-4801-96a9-e4ad207e15b1

📥 Commits

Reviewing files that changed from the base of the PR and between dde6d3d and 733b37b.

📒 Files selected for processing (2)
  • app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt
  • app/src/main/java/com/philkes/notallyx/presentation/viewmodel/preference/Preference.kt

@Crustack Crustack merged commit 0a1ce31 into main Mar 8, 2026
1 check passed
@Crustack Crustack deleted the feat/841 branch March 8, 2026 16:09
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.

Date format YYYY-MM-DD

1 participant