tg-core-components 6.1.1-verify.0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/widgets/CashierAccordion/Payment/CashierResult/index.js +8 -4
- package/es/widgets/HistoryWidget/index.js +65 -1
- package/es/widgets/VerifyAccordionWidget/index.js +1 -1
- package/lib/widgets/CashierAccordion/Payment/CashierResult/index.js +8 -4
- package/lib/widgets/HistoryWidget/index.js +70 -7
- package/lib/widgets/VerifyAccordionWidget/index.js +3 -3
- package/package.json +2 -2
- package/es/lib/utils/selectUnit.js +0 -64
- package/lib/lib/utils/selectUnit.js +0 -69
|
@@ -21,7 +21,13 @@ var CashierResult = function CashierResult(_ref) {
|
|
|
21
21
|
|
|
22
22
|
if (status === 'success' || status === 'pending') {
|
|
23
23
|
var intl = useIntl();
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
var messageKey = 'message.' + (cashierType ? 'deposit' : 'withdrawal') + '.' + status;
|
|
26
|
+
|
|
27
|
+
if (providerType && intl.messages[messageKey + '.' + providerType]) {
|
|
28
|
+
messageKey = messageKey + '.' + providerType;
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
return React.createElement(
|
|
26
32
|
'div',
|
|
27
33
|
{ className: 'cashier-accordion' },
|
|
@@ -31,9 +37,7 @@ var CashierResult = function CashierResult(_ref) {
|
|
|
31
37
|
React.createElement(Notice, {
|
|
32
38
|
level: 'success',
|
|
33
39
|
icon: React.createElement(Icon, { icon: 'check' }),
|
|
34
|
-
header: React.createElement(Translate, {
|
|
35
|
-
id: getKey(intl, messageKey)
|
|
36
|
-
})
|
|
40
|
+
header: React.createElement(Translate, { id: messageKey })
|
|
37
41
|
}),
|
|
38
42
|
successMessage && React.createElement(
|
|
39
43
|
'div',
|
|
@@ -17,7 +17,71 @@ import { SkeletonLine } from '../../components/Skeleton';
|
|
|
17
17
|
import getByPath from 'lodash/get';
|
|
18
18
|
import Translate from '../../components/Translate';
|
|
19
19
|
import { getMessage } from './message';
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
var MILISECONDS = {
|
|
22
|
+
IN_A_SECOND: 1000,
|
|
23
|
+
IN_A_MINUTE: 60000,
|
|
24
|
+
IN_AN_HOUR: 3600000,
|
|
25
|
+
IN_A_DAY: 86400000,
|
|
26
|
+
IN_A_WEEK: 604800000,
|
|
27
|
+
IN_A_MONTH: 2628000000,
|
|
28
|
+
IN_A_YEAR: 31536000000
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
var selectUnit = function selectUnit(from) {
|
|
32
|
+
var now = Date.now();
|
|
33
|
+
var ms = now - from;
|
|
34
|
+
|
|
35
|
+
switch (true) {
|
|
36
|
+
case MILISECONDS.IN_A_SECOND < ms && ms < MILISECONDS.IN_A_MINUTE:
|
|
37
|
+
return {
|
|
38
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_A_SECOND),
|
|
39
|
+
unit: 'second',
|
|
40
|
+
updateIntervalInSeconds: 1
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
case MILISECONDS.IN_A_MINUTE < ms && ms < MILISECONDS.IN_AN_HOUR:
|
|
44
|
+
return {
|
|
45
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_A_MINUTE),
|
|
46
|
+
unit: 'minute'
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
case MILISECONDS.IN_AN_HOUR < ms && ms < MILISECONDS.IN_A_DAY:
|
|
50
|
+
return {
|
|
51
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_AN_HOUR),
|
|
52
|
+
unit: 'hour'
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
case MILISECONDS.IN_A_DAY < ms && ms < MILISECONDS.IN_A_WEEK:
|
|
56
|
+
return {
|
|
57
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_A_DAY),
|
|
58
|
+
unit: 'day'
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
case MILISECONDS.IN_A_WEEK < ms && ms < MILISECONDS.IN_A_MONTH:
|
|
62
|
+
return {
|
|
63
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_A_WEEK),
|
|
64
|
+
unit: 'week'
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
case MILISECONDS.IN_A_MONTH < ms && ms < MILISECONDS.IN_A_YEAR:
|
|
68
|
+
return {
|
|
69
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_A_MONTH),
|
|
70
|
+
unit: 'month'
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
case MILISECONDS.IN_A_YEAR < ms:
|
|
74
|
+
return {
|
|
75
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_A_YEAR),
|
|
76
|
+
unit: 'year'
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
default:
|
|
80
|
+
return {
|
|
81
|
+
value: 0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
21
85
|
|
|
22
86
|
var HistoryWidgetList = function (_React$Component) {
|
|
23
87
|
_inherits(HistoryWidgetList, _React$Component);
|
|
@@ -19,10 +19,10 @@ import { FormattedRelativeTime } from 'react-intl';
|
|
|
19
19
|
import getByPath from 'lodash/get';
|
|
20
20
|
import PropTypes from 'prop-types';
|
|
21
21
|
import Translate from '../../components/Translate';
|
|
22
|
+
import { selectUnit } from '@formatjs/intl-utils';
|
|
22
23
|
import { getKycType } from '../Verify/types';
|
|
23
24
|
import { getKycReason } from '../Verify/reasons';
|
|
24
25
|
import { getKycStatus } from '../Verify/status';
|
|
25
|
-
import { selectUnit } from '../../lib/utils/selectUnit';
|
|
26
26
|
|
|
27
27
|
var UploadForm = function UploadForm(_ref) {
|
|
28
28
|
var type = _ref.type,
|
|
@@ -45,7 +45,13 @@ var CashierResult = function CashierResult(_ref) {
|
|
|
45
45
|
|
|
46
46
|
if (status === 'success' || status === 'pending') {
|
|
47
47
|
var intl = (0, _reactIntl.useIntl)();
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
var messageKey = 'message.' + (cashierType ? 'deposit' : 'withdrawal') + '.' + status;
|
|
50
|
+
|
|
51
|
+
if (providerType && intl.messages[messageKey + '.' + providerType]) {
|
|
52
|
+
messageKey = messageKey + '.' + providerType;
|
|
53
|
+
}
|
|
54
|
+
|
|
49
55
|
return _react2.default.createElement(
|
|
50
56
|
'div',
|
|
51
57
|
{ className: 'cashier-accordion' },
|
|
@@ -55,9 +61,7 @@ var CashierResult = function CashierResult(_ref) {
|
|
|
55
61
|
_react2.default.createElement(_Notice2.default, {
|
|
56
62
|
level: 'success',
|
|
57
63
|
icon: _react2.default.createElement(_Icon2.default, { icon: 'check' }),
|
|
58
|
-
header: _react2.default.createElement(_Translate2.default, {
|
|
59
|
-
id: (0, _Alert.getKey)(intl, messageKey)
|
|
60
|
-
})
|
|
64
|
+
header: _react2.default.createElement(_Translate2.default, { id: messageKey })
|
|
61
65
|
}),
|
|
62
66
|
successMessage && _react2.default.createElement(
|
|
63
67
|
'div',
|
|
@@ -44,8 +44,6 @@ var _Translate2 = _interopRequireDefault(_Translate);
|
|
|
44
44
|
|
|
45
45
|
var _message = require('./message');
|
|
46
46
|
|
|
47
|
-
var _selectUnit = require('../../lib/utils/selectUnit');
|
|
48
|
-
|
|
49
47
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
50
48
|
|
|
51
49
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -54,6 +52,71 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
|
|
|
54
52
|
|
|
55
53
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
56
54
|
|
|
55
|
+
var MILISECONDS = {
|
|
56
|
+
IN_A_SECOND: 1000,
|
|
57
|
+
IN_A_MINUTE: 60000,
|
|
58
|
+
IN_AN_HOUR: 3600000,
|
|
59
|
+
IN_A_DAY: 86400000,
|
|
60
|
+
IN_A_WEEK: 604800000,
|
|
61
|
+
IN_A_MONTH: 2628000000,
|
|
62
|
+
IN_A_YEAR: 31536000000
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
var selectUnit = function selectUnit(from) {
|
|
66
|
+
var now = Date.now();
|
|
67
|
+
var ms = now - from;
|
|
68
|
+
|
|
69
|
+
switch (true) {
|
|
70
|
+
case MILISECONDS.IN_A_SECOND < ms && ms < MILISECONDS.IN_A_MINUTE:
|
|
71
|
+
return {
|
|
72
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_A_SECOND),
|
|
73
|
+
unit: 'second',
|
|
74
|
+
updateIntervalInSeconds: 1
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
case MILISECONDS.IN_A_MINUTE < ms && ms < MILISECONDS.IN_AN_HOUR:
|
|
78
|
+
return {
|
|
79
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_A_MINUTE),
|
|
80
|
+
unit: 'minute'
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
case MILISECONDS.IN_AN_HOUR < ms && ms < MILISECONDS.IN_A_DAY:
|
|
84
|
+
return {
|
|
85
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_AN_HOUR),
|
|
86
|
+
unit: 'hour'
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
case MILISECONDS.IN_A_DAY < ms && ms < MILISECONDS.IN_A_WEEK:
|
|
90
|
+
return {
|
|
91
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_A_DAY),
|
|
92
|
+
unit: 'day'
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
case MILISECONDS.IN_A_WEEK < ms && ms < MILISECONDS.IN_A_MONTH:
|
|
96
|
+
return {
|
|
97
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_A_WEEK),
|
|
98
|
+
unit: 'week'
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
case MILISECONDS.IN_A_MONTH < ms && ms < MILISECONDS.IN_A_YEAR:
|
|
102
|
+
return {
|
|
103
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_A_MONTH),
|
|
104
|
+
unit: 'month'
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
case MILISECONDS.IN_A_YEAR < ms:
|
|
108
|
+
return {
|
|
109
|
+
value: -1 * Math.floor(ms / MILISECONDS.IN_A_YEAR),
|
|
110
|
+
unit: 'year'
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
default:
|
|
114
|
+
return {
|
|
115
|
+
value: 0
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
57
120
|
var HistoryWidgetList = function (_React$Component) {
|
|
58
121
|
_inherits(HistoryWidgetList, _React$Component);
|
|
59
122
|
|
|
@@ -92,7 +155,7 @@ var HistoryWidgetList = function (_React$Component) {
|
|
|
92
155
|
'div',
|
|
93
156
|
null,
|
|
94
157
|
(0, _message.getMessage)((0, _get2.default)(item, 'Transactions[0].Status'))
|
|
95
|
-
)], [_react2.default.createElement(_Money2.default, { value: item.Win - item.Bet, currency: currency }), _react2.default.createElement(_reactIntl.FormattedRelativeTime,
|
|
158
|
+
)], [_react2.default.createElement(_Money2.default, { value: item.Win - item.Bet, currency: currency }), _react2.default.createElement(_reactIntl.FormattedRelativeTime, selectUnit(new Date(item.StartTime + '+00:00')))]];
|
|
96
159
|
} else if (product === 'sportsbook') {
|
|
97
160
|
var selection = item.Transactions[0].Description;
|
|
98
161
|
var odds = item.Transactions[0].Odds;
|
|
@@ -108,7 +171,7 @@ var HistoryWidgetList = function (_React$Component) {
|
|
|
108
171
|
'div',
|
|
109
172
|
null,
|
|
110
173
|
(0, _message.getMessage)(item.Settled ? 'settled' : 'pendling')
|
|
111
|
-
)], [_react2.default.createElement(_Money2.default, { value: item.TotalWin - item.TotalWager, currency: currency }), _react2.default.createElement(_reactIntl.FormattedRelativeTime,
|
|
174
|
+
)], [_react2.default.createElement(_Money2.default, { value: item.TotalWin - item.TotalWager, currency: currency }), _react2.default.createElement(_reactIntl.FormattedRelativeTime, selectUnit(new Date(item.Created + '+00:00')))]];
|
|
112
175
|
} else if (product === 'bingo') {
|
|
113
176
|
return [[_react2.default.createElement(_Translate2.default, {
|
|
114
177
|
tag: 'div'
|
|
@@ -121,7 +184,7 @@ var HistoryWidgetList = function (_React$Component) {
|
|
|
121
184
|
)], [_react2.default.createElement(_Money2.default, {
|
|
122
185
|
value: (0, _get2.default)(item, 'Transactions[0].Amount'),
|
|
123
186
|
currency: currency
|
|
124
|
-
}), _react2.default.createElement(_reactIntl.FormattedRelativeTime,
|
|
187
|
+
}), _react2.default.createElement(_reactIntl.FormattedRelativeTime, selectUnit(new Date(item.Created + '+00:00')))]];
|
|
125
188
|
} else if (product === 'fantasy') {
|
|
126
189
|
return [[_react2.default.createElement(
|
|
127
190
|
'div',
|
|
@@ -136,7 +199,7 @@ var HistoryWidgetList = function (_React$Component) {
|
|
|
136
199
|
)], [_react2.default.createElement(_Money2.default, {
|
|
137
200
|
value: item.Win - (item.Bet + item.Rake),
|
|
138
201
|
currency: currency
|
|
139
|
-
}), _react2.default.createElement(_reactIntl.FormattedRelativeTime,
|
|
202
|
+
}), _react2.default.createElement(_reactIntl.FormattedRelativeTime, selectUnit(new Date(item.Created + '+00:00')))]];
|
|
140
203
|
}
|
|
141
204
|
|
|
142
205
|
return [[_react2.default.createElement(
|
|
@@ -150,7 +213,7 @@ var HistoryWidgetList = function (_React$Component) {
|
|
|
150
213
|
)], [_react2.default.createElement(_Money2.default, {
|
|
151
214
|
value: item.TransactionType === 'Withdraw' ? -item.Amount : item.Amount,
|
|
152
215
|
currency: currency
|
|
153
|
-
}), _react2.default.createElement(_reactIntl.FormattedRelativeTime,
|
|
216
|
+
}), _react2.default.createElement(_reactIntl.FormattedRelativeTime, selectUnit(new Date(item.Started + '+00:00')))]];
|
|
154
217
|
}, _this.createListDetail = function (item, product, currency) {
|
|
155
218
|
if (product === 'casino') {
|
|
156
219
|
return [[_react2.default.createElement(
|
|
@@ -44,14 +44,14 @@ var _Translate = require('../../components/Translate');
|
|
|
44
44
|
|
|
45
45
|
var _Translate2 = _interopRequireDefault(_Translate);
|
|
46
46
|
|
|
47
|
+
var _intlUtils = require('@formatjs/intl-utils');
|
|
48
|
+
|
|
47
49
|
var _types = require('../Verify/types');
|
|
48
50
|
|
|
49
51
|
var _reasons = require('../Verify/reasons');
|
|
50
52
|
|
|
51
53
|
var _status = require('../Verify/status');
|
|
52
54
|
|
|
53
|
-
var _selectUnit = require('../../lib/utils/selectUnit');
|
|
54
|
-
|
|
55
55
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
56
56
|
|
|
57
57
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -119,7 +119,7 @@ var KYCList = function KYCList(_ref2) {
|
|
|
119
119
|
'div',
|
|
120
120
|
{ className: 'bold' },
|
|
121
121
|
(0, _types.getKycType)(item.Type)
|
|
122
|
-
), (0, _status.getKycStatus)(item.Status)], [_react2.default.createElement('div', { className: 'space' }), _react2.default.createElement(_reactIntl.FormattedRelativeTime, (0,
|
|
122
|
+
), (0, _status.getKycStatus)(item.Status)], [_react2.default.createElement('div', { className: 'space' }), _react2.default.createElement(_reactIntl.FormattedRelativeTime, (0, _intlUtils.selectUnit)(new Date(item.Added + '+00:00')))]],
|
|
123
123
|
detail: [[_react2.default.createElement(_Translate2.default, { id: 'label.comment', defaultMessage: 'Comment' }), _react2.default.createElement(_Translate2.default, { id: 'label.reasons', defaultMessage: 'Reasons' })], [item.Comment ? _react2.default.createElement(
|
|
124
124
|
'span',
|
|
125
125
|
null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tg-core-components",
|
|
3
|
-
"version": "6.1.1
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"description": "tg-core-components",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"webpack": "^3.0.0",
|
|
77
77
|
"webpack-blocks": "^1.0.0"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "747e8f43202add17f5cf667c5d4cfa9834c70bdf"
|
|
80
80
|
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
var MILISECONDS = {
|
|
2
|
-
IN_A_SECOND: 1000,
|
|
3
|
-
IN_A_MINUTE: 60000,
|
|
4
|
-
IN_AN_HOUR: 3600000,
|
|
5
|
-
IN_A_DAY: 86400000,
|
|
6
|
-
IN_A_WEEK: 604800000,
|
|
7
|
-
IN_A_MONTH: 2628000000,
|
|
8
|
-
IN_A_YEAR: 31536000000
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export var selectUnit = function selectUnit(from) {
|
|
12
|
-
var now = Date.now();
|
|
13
|
-
var ms = now - from;
|
|
14
|
-
|
|
15
|
-
switch (true) {
|
|
16
|
-
case MILISECONDS.IN_A_SECOND < ms && ms < MILISECONDS.IN_A_MINUTE:
|
|
17
|
-
return {
|
|
18
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_A_SECOND),
|
|
19
|
-
unit: 'second',
|
|
20
|
-
updateIntervalInSeconds: 1
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
case MILISECONDS.IN_A_MINUTE < ms && ms < MILISECONDS.IN_AN_HOUR:
|
|
24
|
-
return {
|
|
25
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_A_MINUTE),
|
|
26
|
-
unit: 'minute'
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
case MILISECONDS.IN_AN_HOUR < ms && ms < MILISECONDS.IN_A_DAY:
|
|
30
|
-
return {
|
|
31
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_AN_HOUR),
|
|
32
|
-
unit: 'hour'
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
case MILISECONDS.IN_A_DAY < ms && ms < MILISECONDS.IN_A_WEEK:
|
|
36
|
-
return {
|
|
37
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_A_DAY),
|
|
38
|
-
unit: 'day'
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
case MILISECONDS.IN_A_WEEK < ms && ms < MILISECONDS.IN_A_MONTH:
|
|
42
|
-
return {
|
|
43
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_A_WEEK),
|
|
44
|
-
unit: 'week'
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
case MILISECONDS.IN_A_MONTH < ms && ms < MILISECONDS.IN_A_YEAR:
|
|
48
|
-
return {
|
|
49
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_A_MONTH),
|
|
50
|
-
unit: 'month'
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
case MILISECONDS.IN_A_YEAR < ms:
|
|
54
|
-
return {
|
|
55
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_A_YEAR),
|
|
56
|
-
unit: 'year'
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
default:
|
|
60
|
-
return {
|
|
61
|
-
value: 0
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var MILISECONDS = {
|
|
7
|
-
IN_A_SECOND: 1000,
|
|
8
|
-
IN_A_MINUTE: 60000,
|
|
9
|
-
IN_AN_HOUR: 3600000,
|
|
10
|
-
IN_A_DAY: 86400000,
|
|
11
|
-
IN_A_WEEK: 604800000,
|
|
12
|
-
IN_A_MONTH: 2628000000,
|
|
13
|
-
IN_A_YEAR: 31536000000
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
var selectUnit = exports.selectUnit = function selectUnit(from) {
|
|
17
|
-
var now = Date.now();
|
|
18
|
-
var ms = now - from;
|
|
19
|
-
|
|
20
|
-
switch (true) {
|
|
21
|
-
case MILISECONDS.IN_A_SECOND < ms && ms < MILISECONDS.IN_A_MINUTE:
|
|
22
|
-
return {
|
|
23
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_A_SECOND),
|
|
24
|
-
unit: 'second',
|
|
25
|
-
updateIntervalInSeconds: 1
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
case MILISECONDS.IN_A_MINUTE < ms && ms < MILISECONDS.IN_AN_HOUR:
|
|
29
|
-
return {
|
|
30
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_A_MINUTE),
|
|
31
|
-
unit: 'minute'
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
case MILISECONDS.IN_AN_HOUR < ms && ms < MILISECONDS.IN_A_DAY:
|
|
35
|
-
return {
|
|
36
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_AN_HOUR),
|
|
37
|
-
unit: 'hour'
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
case MILISECONDS.IN_A_DAY < ms && ms < MILISECONDS.IN_A_WEEK:
|
|
41
|
-
return {
|
|
42
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_A_DAY),
|
|
43
|
-
unit: 'day'
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
case MILISECONDS.IN_A_WEEK < ms && ms < MILISECONDS.IN_A_MONTH:
|
|
47
|
-
return {
|
|
48
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_A_WEEK),
|
|
49
|
-
unit: 'week'
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
case MILISECONDS.IN_A_MONTH < ms && ms < MILISECONDS.IN_A_YEAR:
|
|
53
|
-
return {
|
|
54
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_A_MONTH),
|
|
55
|
-
unit: 'month'
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
case MILISECONDS.IN_A_YEAR < ms:
|
|
59
|
-
return {
|
|
60
|
-
value: -1 * Math.floor(ms / MILISECONDS.IN_A_YEAR),
|
|
61
|
-
unit: 'year'
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
default:
|
|
65
|
-
return {
|
|
66
|
-
value: 0
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
};
|