frequi_origin/src/shared/formatters.ts

24 lines
511 B
TypeScript
Raw Normal View History

2020-07-11 15:12:16 +00:00
import * as moment from 'moment';
2020-06-05 09:22:14 +00:00
2020-07-11 15:13:27 +00:00
export function formatPercent(value: number): string {
return value ? `${(value * 100).toFixed(3)}%` : '';
2020-06-02 11:05:16 +00:00
}
2020-07-11 15:13:27 +00:00
export function formatPrice(value: number): string {
return value ? value.toFixed(8) : '';
}
2020-07-13 19:40:05 +00:00
export function timestampms(ts: number | Date): string {
return moment(ts).format('YYYY-MM-DD HH:mm:ss');
2020-06-05 09:22:14 +00:00
}
2020-08-17 19:15:15 +00:00
export function timestampHour(ts: number | Date): number {
return moment(ts).hour();
}
export default {
formatPrice,
formatPercent,
2020-06-05 09:22:14 +00:00
timestampms,
};