File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ async function LogTable({ logs }: Props) {
1818 < th > Rating</ th >
1919 < th className = "hidden sm:table-cell" > elapsed</ th >
2020 < th className = "hidden sm:table-cell" > scheduled</ th >
21+ < th className = "hidden sm:table-cell" > duration</ th >
2122 </ tr >
2223 </ thead >
2324 < tbody >
@@ -29,6 +30,7 @@ async function LogTable({ logs }: Props) {
2930 < td > { log . grade } </ td >
3031 < td className = "hidden sm:table-cell" > { log . elapsed_days } </ td >
3132 < td className = "hidden sm:table-cell" > { log . scheduled_days } </ td >
33+ < td className = "hidden sm:table-cell" > { log . duration > 0 ? durationFormat ( log . duration ) : '/' } </ td >
3234 </ tr >
3335 ) ) }
3436 </ tbody >
@@ -38,3 +40,30 @@ async function LogTable({ logs }: Props) {
3840}
3941
4042export default LogTable ;
43+
44+
45+ function durationFormat ( duration : number ) {
46+ const division = [ 60 , 60 , 24 ]
47+ const char = [ 's' , 'm' , 'h' , 'd' ]
48+ if ( duration <= 0 ) {
49+ return '/' ;
50+ }
51+ const split_duration = [ ] ;
52+ for ( let c of division ) {
53+ split_duration . push ( duration % c ) ;
54+ duration = Math . floor ( duration / c ) ;
55+ if ( duration === 0 ) {
56+ break ;
57+ }
58+ }
59+ if ( duration > 0 ) {
60+ split_duration . push ( duration ) ;
61+ }
62+ const res = [ ] ;
63+ for ( let i = split_duration . length - 1 ; i >= 0 ; i -- ) {
64+ if ( split_duration [ i ] > 0 ) {
65+ res . push ( `${ split_duration [ i ] } ${ char [ i ] } ` )
66+ }
67+ }
68+ return res . join ( '' ) ;
69+ }
You can’t perform that action at this time.
0 commit comments