-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
WIP: Add Sec2TrackedTime time format template helper #25213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
3007f78
Add Sec2TrackedTime time-format-func
6543 3c4ab6c
use in templates
6543 201e227
Also apply it for sidebar in issue/pull view for single users
6543 645fe79
add
6543 4690b36
also use it for timeline comments
6543 885d41b
Merge branch 'main' into up_format_tracked-time
6543 1f2bd71
Merge branch 'main' into up_format_tracked-time
6543 9f7da35
Merge branch 'main' into up_format_tracked-time
6543 7d41418
frontend: rm dep "pretty-ms"
6543 82bb7dd
use Sec2TrackedTime for stowpatch init too
6543 99a50f1
port util.Sec2TrackedTime to javaScript
6543 4bbfa26
create time.js in utils and use it
6543 acb7c3f
fix
6543 868ae80
ignore ms
6543 6477807
use old format for API
6543 848c0dd
store timestamp instead of string for CommentTypeStopTracking & Comme…
6543 95caebf
store and use seconds for timeline time comments
6543 4df03a3
store and use seconds for timeline time comments
6543 c0e96f3
next
6543 5e0e77c
need helper until we convert time in frontend
6543 3b4a0b8
...
6543 b2cc1ee
non breaking API
6543 99fbd23
code format
6543 81ba06a
adjust test
6543 d20a89d
Merge branch 'main' into up_format_tracked-time
6543 7e429ff
Merge branch 'refactor_store_seconds-not-string' into up_format_track…
6543 a960c2e
Merge branch 'main' into up_format_tracked-time
6543 e61e1eb
clean
6543 358cb5e
wip
6543 919b9d6
Merge branch 'main' into up_format_tracked-time
6543 a22d5ff
Merge branch 'main' into up_format_tracked-time
6543 9dcfd38
Merge branch 'main' into up_format_tracked-time
6543 1ad09f9
Merge branch 'main' into up_format_tracked-time
6543 bbdd894
Update filters.tmpl
6543 cc14191
Update list.tmpl
6543 311ac33
Update milestone_issues.tmpl
6543 2c5af52
Merge branch 'main' into up_format_tracked-time
6543 0953506
Merge branch 'main' into up_format_tracked-time
6543 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export function formatTrackedTime(durationSec) { | ||
let formattedTime = ''; | ||
|
||
const duration = Math.floor(durationSec / 1); | ||
const hours = Math.floor(duration / 3600); | ||
const minutes = Math.floor((duration / 60) % 60); | ||
const seconds = duration % 60; | ||
|
||
if (hours > 0) { | ||
formattedTime = formatTime(hours, 'hour', formattedTime); | ||
formattedTime = formatTime(minutes, 'minute', formattedTime); | ||
} else { | ||
formattedTime = formatTime(minutes, 'minute', formattedTime); | ||
formattedTime = formatTime(seconds, 'second', formattedTime); | ||
} | ||
|
||
formattedTime = formattedTime.trimEnd(); | ||
return formattedTime; | ||
} | ||
|
||
function formatTime(value, name, formattedTime) { | ||
if (value === 1) { | ||
formattedTime = `${formattedTime}1 ${name} `; | ||
} else if (value > 1) { | ||
formattedTime = `${formattedTime}${value} ${name}s `; | ||
} | ||
return formattedTime; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {test, expect} from 'vitest'; | ||
import {formatTrackedTime} from './time.js'; | ||
|
||
test('formatTrackedTime', () => { | ||
expect(formatTrackedTime('')).toEqual(''); | ||
expect(formatTrackedTime('0')).toEqual(''); | ||
expect(formatTrackedTime('66')).toEqual('1 minute 6 seconds'); | ||
expect(formatTrackedTime('52410')).toEqual('14 hours 33 minutes'); | ||
expect(formatTrackedTime('563418')).toEqual('156 hours 30 minutes'); | ||
expect(formatTrackedTime('1563418')).toEqual('434 hours 16 minutes'); | ||
expect(formatTrackedTime('3937125')).toEqual('1093 hours 38 minutes'); | ||
expect(formatTrackedTime('45677465')).toEqual('12688 hours 11 minutes'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. handle |
||
expect(formatTrackedTime(1.333)).toEqual('1 second'); | ||
expect(formatTrackedTime(1.999)).toEqual('1 second'); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIP: make units set via user config