Skip to content

fix: use system time format in channel details - #1123

Open
guzino wants to merge 4 commits into
synonymdev:masterfrom
guzino:fix/channel-details-time-format
Open

fix: use system time format in channel details#1123
guzino wants to merge 4 commits into
synonymdev:masterfrom
guzino:fix/channel-details-time-format

Conversation

@guzino

@guzino guzino commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #1110

This PR routes the Lightning connection timestamps through the shared uiDateText entry point, so they follow the device's 12/24-hour setting.

Description

ChannelDetailScreen built its own DateTimeFormatter from DatePattern.CHANNEL_DETAILS, the hardcoded 24-hour pattern MMM d, yyyy, HH:mm. A connection created at 8:58 PM therefore read 20:58 on a device set to a 12-hour clock, while the activity list one screen away read 8:58 PM. #1111 added uiDateText and left this screen for a follow-up.

The date shape is kept exactly as it was. iOS renders this screen from MMM d, yyyy - HH:mm in LightningConnectionDetailView.swift, so the abbreviated month is the design, and only the fixed clock is the defect. That hardcoded HH:mm is present on iOS too, which this PR does not address.

  • Replaces formatDate and formatUnixTimestamp with uiDateText, so Created on, Order expiry, Opened on and Closed on all read the clock format from LocalIs24HourFormat.
  • Adds UiDateStyle.DATE_TIME_YEAR_SHORT for the MMM d, yyyy date this screen shares with iOS, leaving the four existing styles untouched.
  • Adds String.toEpochSecondsOrNull() in ext/DateTime.kt for the ISO-8601 strings Blocktank returns, keeping the previous behaviour of falling back to the raw string when it cannot be parsed.
  • Passes Opened on straight through as the ULong it already is. It previously went ULongLongInstant to rebuild the same value.
  • Drops DatePattern.CHANNEL_DETAILS and the screen's five date imports, all unused now.

Preview

compare-12h compare-clock-formats

QA Notes

Manual Tests

  • 1. Device on 12-hour time → Settings ▸ Advanced ▸ Lightning Connections ▸ Connection 1: Created on and Opened on both read Jul 31, 2026, 7:28 PM, matching the status bar.
  • 2. Device on 24-hour time → the same two rows read Jul 31, 2026, 19:28. The date keeps the Jul 31, 2026 shape in both.
  • 3. Open a closed connection: Closed on follows the same setting, and Order expiry does too on a pending order.
  • 4. regression: a connection whose order timestamp is malformed still renders the raw value instead of an empty row.

Automated Checks

  • Unit tests added in DateTimeExtTest.kt: toEpochSecondsOrNull over the plain and millisecond ISO-8601 forms, unparseable and empty input, the new style in both clock formats, and its month name under Locale.GERMANY.
  • Verified on an emulator against a regtest channel opened through Blocktank staging, in both clock settings.
  • Local: just compile, just test, just lint all pass, no new detekt findings.

@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown

Greptile Summary

Routes Lightning connection timestamps through the shared system-aware date formatter.

  • Adds a short-month date-time style supporting the device’s 12/24-hour preference.
  • Parses Blocktank ISO-8601 timestamps into epoch seconds while preserving malformed values as raw text.
  • Updates created, expiry, opened, and closed timestamps in channel details.
  • Adds date parsing, clock-format, and locale regression tests.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
app/src/main/java/to/bitkit/ext/DateTime.kt Adds ISO-8601 epoch parsing and a localized short-month date-time style.
app/src/main/java/to/bitkit/ui/settings/lightning/ChannelDetailScreen.kt Replaces fixed 24-hour timestamp formatting with the shared system-aware formatter while retaining malformed-string fallback.
app/src/test/java/to/bitkit/ext/DateTimeExtTest.kt Covers timestamp parsing, malformed input, both clock preferences, and localized month names.
changelog.d/next/1123.fixed.md Documents that Lightning connection timestamps now follow the device clock preference.

Sequence Diagram

sequenceDiagram
    participant Data as Channel / Blocktank data
    participant Screen as ChannelDetailScreen
    participant Parser as toEpochSecondsOrNull
    participant Formatter as uiDateText
    participant Setting as LocalIs24HourFormat
    Data->>Screen: ISO-8601 string or epoch seconds
    Screen->>Parser: Parse ISO-8601 strings
    alt Valid timestamp
        Parser-->>Screen: Epoch seconds
        Screen->>Formatter: DATE_TIME_YEAR_SHORT
        Setting-->>Formatter: 12-hour or 24-hour preference
        Formatter-->>Screen: Localized date and time
    else Malformed string
        Parser-->>Screen: null
        Screen-->>Screen: Display original value
    end
Loading

Reviews (2): Last reviewed commit: "Merge remote-tracking branch 'origin/mas..." | Re-trigger Greptile

@jvsena42 jvsena42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please, fix the conflict

@jvsena42
jvsena42 marked this pull request as draft August 10, 2026 14:58
…-time-format

Co-authored-by: Cursor <cursoragent@cursor.com>
@guzino

guzino commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Merged master in 9301c217c. DateTimeExtTest keeps both the channel-details tests and the locale tests from #1124. just compile, just test, and just lint pass locally; no new detekt findings in the touched files.

@guzino
guzino marked this pull request as ready for review August 21, 2026 11:44
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.

Channel details time uses different time format to system

2 participants