Skip to content

feat(executiontime): add ISO 8601 duration format#7298

Merged
JanDeDobbeleer merged 1 commit intoJanDeDobbeleer:nextfrom
dohzya:feat/executiontime-iso8601
Mar 15, 2026
Merged

feat(executiontime): add ISO 8601 duration format#7298
JanDeDobbeleer merged 1 commit intoJanDeDobbeleer:nextfrom
dohzya:feat/executiontime-iso8601

Conversation

@dohzya
Copy link
Copy Markdown
Contributor

@dohzya dohzya commented Feb 10, 2026

Prerequisites

  • I have read and understood the contributing guide.
  • The commit message follows the conventional commits guidelines.
  • Tests for the changes have been added (for bug fixes / features).
  • Docs have been added/updated (for bug fixes / features).

Description

Adds two new duration styles for the executiontime segment using the ISO 8601 duration format:

  • iso8601: Displays time with second precision (e.g., PT3M2S)
  • iso8601ms: Displays time with millisecond precision (e.g., PT3M2.1S)

This follows the same pattern as existing formats like galveston and galvestonms.

Format Examples

Duration iso8601 iso8601ms
0.001s PT0S PT0.001S
2.1s PT2S PT2.1S
3m2.1s PT3M2S PT3M2.1S
4h3m2.1s PT4H3M2S PT4H3M2.1S

Test Plan

  • Added unit tests for both formats (24 test cases total)
  • All tests pass (17/17 executiontime tests)
  • Documentation updated with examples

Configuration Example

{
  "type": "executiontime",
  "options": {
    "style": "iso8601",
    "threshold": 500
  }
}

🤖 Generated with Claude Code

@dohzya
Copy link
Copy Markdown
Contributor Author

dohzya commented Feb 11, 2026

Hi @JanDeDobbeleer 👋

Just to be clear: this isn't some random AI-generated contribution—it's a genuine feature I need and wanted to propose instead of just requesting." 🙂

I currently use a custom template to achieve this goal, but I figure I can't be the only one with this need.

Here is my current template:

{{- $ms := .Ms -}}
{{- if le $ms 0 -}}
{{- /* rien */ -}}
{{- else -}}
{{- $sTotal := div $ms 1000 -}}
{{- $h := div $sTotal 3600 -}}
{{- $m := div (mod $sTotal 3600) 60 -}}
{{- $s := mod $sTotal 60 -}}
PT{{- if gt $h 0 -}}{{ $h }}H{{- end -}}
{{- if gt $m 0 -}}{{ $m }}M{{- end -}}
{{- $s -}}S
{{- end -}}

@JanDeDobbeleer
Copy link
Copy Markdown
Owner

@dohzya question though, what's the use-case here for executiontime? Is it really running long enough to have a need for this format?

@dohzya
Copy link
Copy Markdown
Contributor Author

dohzya commented Feb 16, 2026

Oh, I prefer this format whatever the duration, and other formats also support up to hours 🙂

Yes, sessions of vim or claude-code can take hours, even days. For instance, I tend to put my work laptop to hibernation instead of shutting it down during the weekend, without stopping my claude-code sessions first.

I followed what other formats do by sticking to PT<time> (I suppose because longer durations can't be calculated from the milliseconds-based representation, notably due to leap seconds).

@JanDeDobbeleer JanDeDobbeleer force-pushed the main branch 2 times, most recently from 6a67260 to 85091a8 Compare February 18, 2026 15:59
@JanDeDobbeleer JanDeDobbeleer force-pushed the feat/executiontime-iso8601 branch from 5d989ca to 6b77b5d Compare March 15, 2026 09:01
@JanDeDobbeleer JanDeDobbeleer changed the base branch from main to next March 15, 2026 09:02
Add iso8601 and iso8601ms styles for execution time display using
ISO 8601 duration format (PT[n]H[n]M[n]S). The iso8601 style rounds
to nearest second, while iso8601ms preserves milliseconds precision.

Co-authored-by: Claude <noreply@anthropic.com>
@JanDeDobbeleer JanDeDobbeleer force-pushed the feat/executiontime-iso8601 branch from 6b77b5d to 7865b3f Compare March 15, 2026 09:04
@JanDeDobbeleer JanDeDobbeleer enabled auto-merge (rebase) March 15, 2026 09:05
@JanDeDobbeleer JanDeDobbeleer disabled auto-merge March 15, 2026 09:06
@JanDeDobbeleer JanDeDobbeleer merged commit df6d1a0 into JanDeDobbeleer:next Mar 15, 2026
8 checks passed
@JanDeDobbeleer
Copy link
Copy Markdown
Owner

@all-contributors please add @dohzya for code,doc

This is pure magic 🪄! @holopin-bot @dohzya wizard

@holopin-bot
Copy link
Copy Markdown

holopin-bot bot commented Mar 15, 2026

Congratulations @dohzya, the maintainer of this repository has issued you a badge! Here it is: https://holopin.io/claim/cmmrj6rue0001jp04761c0kmf

This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account.
Or if you're new to Holopin, you can simply sign up with GitHub, which will do the trick!

@allcontributors
Copy link
Copy Markdown
Contributor

@JanDeDobbeleer

I've put up a pull request to add @dohzya! 🎉

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