parent
3dd3c80b54
commit
d7df946c2b
@ -0,0 +1,20 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
||||
import RelativeDateCell from './RelativeDateCell';
|
||||
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
createUISettingsSelector(),
|
||||
(uiSettings) => {
|
||||
return {
|
||||
showRelativeDates: uiSettings.showRelativeDates,
|
||||
shortDateFormat: uiSettings.shortDateFormat,
|
||||
longDateFormat: uiSettings.longDateFormat,
|
||||
timeFormat: uiSettings.timeFormat
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(createMapStateToProps, null)(RelativeDateCell);
|
@ -0,0 +1,19 @@
|
||||
export default function abbreviateNumber(num, decimalPlaces) {
|
||||
if (num === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (num === 0) {
|
||||
return '0';
|
||||
}
|
||||
|
||||
decimalPlaces = (!decimalPlaces || decimalPlaces < 0) ? 0 : decimalPlaces;
|
||||
|
||||
const b = (num).toPrecision(2).split('e');
|
||||
const k = b.length === 1 ? 0 : Math.floor(Math.min(b[1].slice(1), 14) / 3);
|
||||
const c = k < 1 ? num.toFixed(0 + decimalPlaces) : (num / Math.pow(10, k * 3) ).toFixed(1 + decimalPlaces);
|
||||
const d = c < 0 ? c : Math.abs(c);
|
||||
const e = d + ['', 'K', 'M', 'B', 'T'][k];
|
||||
|
||||
return e;
|
||||
}
|
Loading…
Reference in new issue