File size: 447 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { translate } from 'i18n-calypso';

export const formatMsValue = ( msValue: number ): React.ReactElement | string | number => {
	if ( msValue < 1000 ) {
		return translate( '%(value)sms', {
			comment: 'value to be displayed in milliseconds',
			args: { value: Math.floor( msValue ) },
		} );
	}

	return translate( '%(value)ss', {
		comment: 'value to be displayed in seconds',
		args: { value: ( msValue / 1000 ).toFixed( 2 ) },
	} );
};