Commit d1a3375
committed
feature symfony#58946 [Console] Add support of millisecondes for
This PR was squashed before being merged into the 7.3 branch.
Discussion
----------
[Console] Add support of millisecondes for `formatTime`
| Q | A
| ------------- | ---
| Branch? | 7.3
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| License | MIT
## Description
This pull request introduces support for formatting time durations down to milliseconds in the `Helper::formatTime()` method. Previously, the method only supported seconds and larger units (minutes, hours, days). The new implementation adds:
1. Support for milliseconds when the input is a fractional value (e.g., 1.456 → 1 sec, 456 ms).
2. Accurate rounding for milliseconds.
3. Respect for the precision parameter, limiting the number of time components displayed in the output.
## Examples
```php
Helper::formatTime(0.001); // "1 ms"
Helper::formatTime(1.456); // "1 s, 456 ms"
Helper::formatTime(125.789, 2); // "2 min, 5 s"
Helper::formatTime(172799.999, 4); // "1 d, 23 h, 59 min, 59 s"
Helper::formatTime(0.0005); // "< 1 ms"
```
Commits
-------
eac7d49 [Console] Add support of millisecondes for `formatTime`formatTime (SebLevDev)File tree
2 files changed
+41
-36
lines changed- src/Symfony/Component/Console
- Helper
- Tests/Helper
2 files changed
+41
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | | - | |
93 | | - | |
| 93 | + | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
105 | | - | |
| 107 | + | |
106 | 108 | | |
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
111 | | - | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
115 | | - | |
116 | | - | |
| 117 | + | |
| 118 | + | |
117 | 119 | | |
118 | | - | |
| 120 | + | |
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
122 | | - | |
| 124 | + | |
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
| |||
Lines changed: 27 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| |||
0 commit comments