Skip to content

feat: impl DisplayUnixTimeStampExt for Option<Duration>#10

Merged
drmingdrmer merged 2 commits intodatabendlabs:mainfrom
drmingdrmer:011-display-braces
Feb 17, 2026
Merged

feat: impl DisplayUnixTimeStampExt for Option<Duration>#10
drmingdrmer merged 2 commits intodatabendlabs:mainfrom
drmingdrmer:011-display-braces

Conversation

@drmingdrmer
Copy link
Member

Changelog

feat: impl DisplayUnixTimeStampExt for Option<Duration>

Timestamps are often optional (e.g., "last seen at"), so accepting
Option<Duration> directly avoids callers needing to unwrap before
formatting. None renders as the literal string "None", matching the
convention used by DisplayOption.

Internally, DisplayUnixTimeStamp::duration is now Option<Duration>;
the Display impl early-returns "None" for None.

Example:

let ts: Option<Duration> = None;
assert_eq!(ts.display_unix_timestamp().to_string(), "None");

let ts = Some(Duration::from_millis(1723102819023));
assert_eq!(ts.display_unix_timestamp_short().to_string(), "2024-08-08T07:40:19.023");
chore: Bump ver: 0.2.5

Timestamps are often optional (e.g., "last seen at"), so accepting
`Option<Duration>` directly avoids callers needing to unwrap before
formatting. `None` renders as the literal string `"None"`, matching the
convention used by `DisplayOption`.

Internally, `DisplayUnixTimeStamp::duration` is now `Option<Duration>`;
the `Display` impl early-returns `"None"` for `None`.

Example:

    let ts: Option<Duration> = None;
    assert_eq!(ts.display_unix_timestamp().to_string(), "None");

    let ts = Some(Duration::from_millis(1723102819023));
    assert_eq!(ts.display_unix_timestamp_short().to_string(), "2024-08-08T07:40:19.023");
Copy link

@xp-trumpet xp-trumpet left a comment

Choose a reason for hiding this comment

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

@xp-trumpet reviewed 2 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on drmingdrmer).

@drmingdrmer drmingdrmer merged commit 9b84437 into databendlabs:main Feb 17, 2026
1 check passed
@drmingdrmer drmingdrmer deleted the 011-display-braces branch February 17, 2026 12:53
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.

2 participants