File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ function humanizeDurationSegments(duration: number): string[] {
4040
4141 if ( remainder >= WEEK ) {
4242 const weeks = Math . floor ( remainder / WEEK ) ;
43- result . push ( weeks + ( weeks === 1 ? " years " : " weeks" ) ) ;
43+ result . push ( weeks + ( weeks === 1 ? " week " : " weeks" ) ) ;
4444 remainder %= WEEK ;
4545 }
4646
@@ -49,33 +49,34 @@ function humanizeDurationSegments(duration: number): string[] {
4949
5050 if ( remainder >= DAY ) {
5151 const days = Math . floor ( remainder / DAY ) ;
52- result . push ( days + " days") ;
52+ result . push ( days + ( days === 1 ? " day" : " days") ) ;
5353 remainder %= DAY ;
5454 }
5555
5656 if ( duration >= WEEK )
5757 return result ;
5858
59- // TODO: looks like I forgot something
60-
6159 if ( remainder >= HOUR ) {
62- result . push ( Math . floor ( remainder / HOUR ) + " hours" ) ;
60+ const hours = Math . floor ( remainder / HOUR ) ;
61+ result . push ( hours + ( hours === 1 ? " hour" : " hours" ) ) ;
6362 remainder %= HOUR ;
6463 }
6564
6665 if ( duration >= DAY )
6766 return result ;
6867
6968 if ( remainder >= MINUTE ) {
70- result . push ( Math . floor ( remainder / MINUTE ) + " minutes" ) ;
69+ const minutes = Math . floor ( remainder / MINUTE ) ;
70+ result . push ( minutes + ( minutes === 1 ? " minute" : " minutes" ) ) ;
7171 remainder %= MINUTE ;
7272 }
7373
7474 if ( duration >= HOUR )
7575 return result ;
7676
7777 if ( remainder >= SECOND ) {
78- result . push ( Math . floor ( remainder / SECOND ) + " seconds" ) ;
78+ const seconds = Math . floor ( remainder / SECOND ) ;
79+ result . push ( seconds + ( seconds === 1 ? " second" : " seconds" ) ) ;
7980 remainder %= SECOND ;
8081 }
8182
You can’t perform that action at this time.
0 commit comments