Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Durationformatter: Feature proposal #444

Closed
rowa-audil opened this issue Jan 16, 2020 · 4 comments · Fixed by #460
Closed

Durationformatter: Feature proposal #444

rowa-audil opened this issue Jan 16, 2020 · 4 comments · Fixed by #460
Assignees
Labels

Comments

@rowa-audil
Copy link
Contributor

rowa-audil commented Jan 16, 2020

Durationformatter Feature proposal

Feature proposal

The DtDurationFormatter converts an input duration to an output duration. Both
the input and output units are configurable. Additionally, it has support for
precision/mode concerning how the output is displayed.

Precisionmodes

  • DEFAULT || undefined: Default mode
  • PRECISE: Precise
  • 1 - n: Amount of units to display

Pipesyntax:

{{ <input /> || dtDuration: '<formattingMethod>':'<outputUnit>':'<inputUnit>' }}

The duration formatter pipe will cover the use cases below:

Default mode:

It will only display two units from the biggest unit that has a value.
InputUnit is set to milliseconds by default

  • outputUnit not specified ('DEFAULT':undefined:undefined):

    • input (milliseconds): 61 001
    • output: 1 min 1 s 1 ms
    • precisionMode: "DEFAULT" OR undefined
  • outputUnit not specified ('DEFAULT':undefined:undefined):

    • input(milliseconds): 3 661 001
    • ouput: 1 h 1 min 1 s
    • precisionMode: "DEFAULT" OR undefined
  • outputUnit specified ('DEFAULT' :'s': undefined):

    • input (milliseconds): 1 500
    • output (seconds): 1 s
    • precisionMode: "DEFAULT" OR undefined
  • outputUnit specified ('DEFAULT' :'s': undefined):

    • input (milliseconds): 500
    • output (seconds): < 1 s
    • precisionMode: "DEFAULT" OR undefined
  • outputUnit specified AND inputUnit specified ('DEFAULT':'s':'h'):

    • input (hour): 3
    • output (seconds): 10800 s
    • precisionMode: "DEFAULT" OR undefined

Precise mode:

  • outputUnit not specified:

    • input (milliseconds): 1500
    • output: 1500 ms
    • precisionMode: "PRECISE"
  • outputUnit is seconds:

    • input (milliseconds): 1 500
    • output (seconds): 1.5 s
    • precisionMode: "PRECISE"

Custom amount of displayed units

  • Precision set to 2:

    • input(milliseconds): 90 061 001
    • output: 1 d 1 h
    • precisionMode: 2
  • Precision set to 5:

    • input(milliseconds): 90 061 001
    • output: 1 d 1 h 1 min 1 s 1 ms
    • precisionMode: 5
@ghost
Copy link

ghost commented Jan 16, 2020

What should happen if the input is smaller than the output unit?
E.g.:

  • Input: 1 (ms)
  • outputUnit: seconds
  • Output: ?
    I'd suggest displaying '< 1 {Unit}', but this should be at least defined.

And to double-check: What happens if the input is zero?
Will it display '0 {Unit}'?

@jsjsat
Copy link
Contributor

jsjsat commented Jan 17, 2020

Will this also work for rate units?
E.g.: CPU time -> 10 s/min

@ghost
Copy link

ghost commented Jan 20, 2020

Will this also work for rate units?
E.g.: CPU time -> 10 s/min

Good point.
IMO it should be compatible with the dtRate formatter.

@rowa-audil
Copy link
Contributor Author

rowa-audil commented Jan 20, 2020

@dlaubi-dt Good morning, first I want to apologize for the late response. I couldn't come to the office on Friday.
There are two outputs possible by giving the pipe another attribute which sets the formation mode:

DEFAULT || undefined

  • Input: 1ms
  • outputUnit: seconds
  • Output: < 1s

PRECISE

  • Output: 0.001s

@jsjsat (&& @dlaubi-dt) Good morning, can you elaborate on the rate s/min? I'm not quite sure what that means tbh ^^
But since Angular supports chaining pipes, I think that with a little string formatting magic, it should work. (Will test this out and keep you up to date if you want)

@rowa-audil rowa-audil added has-pr and removed has-pr labels Feb 4, 2020
tomheller pushed a commit that referenced this issue Feb 18, 2020
tomheller pushed a commit that referenced this issue Feb 24, 2020
…onfiguration.

Fixes #444

BREAKING CHANGE: Removed experiementalFormatTime and
DtExperimentalFormatTime in favor of dtDuration pipe.
tomheller pushed a commit that referenced this issue Feb 25, 2020
…onfiguration.

Fixes #444

BREAKING CHANGE: Removed experiementalFormatTime and
DtExperimentalFormatTime in favor of dtDuration pipe.
tomheller pushed a commit that referenced this issue Feb 28, 2020
…onfiguration.

Fixes #444

BREAKING CHANGE: Removed experiementalFormatTime and
DtExperimentalFormatTime in favor of dtDuration pipe.
@github-actions github-actions bot added the no-issue-activity Issue is stale for more than 30 days label Mar 6, 2020
@dynatrace-oss dynatrace-oss deleted a comment from github-actions bot Mar 6, 2020
@tomheller tomheller removed the no-issue-activity Issue is stale for more than 30 days label Mar 6, 2020
rowa-audil added a commit that referenced this issue Mar 12, 2020
…onfiguration.

Fixes #444

BREAKING CHANGE: Removed experiementalFormatTime and
DtExperimentalFormatTime in favor of dtDuration pipe.
rowa-audil added a commit that referenced this issue Mar 12, 2020
…onfiguration.

Fixes #444

BREAKING CHANGE: Removed experiementalFormatTime and
DtExperimentalFormatTime in favor of dtDuration pipe.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants