@zohodesk/i18n 1.0.0-beta.18 → 1.0.0-beta.20
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/README.md +7 -0
- package/es/components/DateTimeDiffFormat.js +4 -2
- package/es/components/I18NProvider.js +9 -2
- package/es/components/UserTimeDiffFormat.js +5 -2
- package/lib/components/DateTimeDiffFormat.js +4 -2
- package/lib/components/I18NProvider.js +10 -2
- package/lib/components/UserTimeDiffFormat.js +5 -2
- package/package.json +2 -2
- package/src/components/DateTimeDiffFormat.js +3 -1
- package/src/components/I18NProvider.js +18 -14
- package/src/components/UserTimeDiffFormat.js +3 -0
package/README.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# i18n
|
|
2
2
|
|
|
3
|
+
# 1.0.0-beta.20
|
|
4
|
+
|
|
5
|
+
- Date field issue fixed in UserTimeDiffFormat component
|
|
6
|
+
|
|
7
|
+
# 1.0.0-beta.19
|
|
8
|
+
|
|
9
|
+
- In this version we have made changes in i18n provider to call user date format function only if the time zone data is available.
|
|
3
10
|
# 1.0.0-beta.18
|
|
4
11
|
|
|
5
12
|
- Localization feature added and incorporated into getI18NValue Method.
|
|
@@ -43,10 +43,11 @@ export default class DateTimeDiffFormat extends React.Component {
|
|
|
43
43
|
isOverdue,
|
|
44
44
|
timeFormat,
|
|
45
45
|
datePattern,
|
|
46
|
-
isEnabledCurrentYear
|
|
46
|
+
isEnabledCurrentYear,
|
|
47
|
+
isDateField
|
|
47
48
|
} = this.props;
|
|
48
49
|
let fromDateObj = datetime.toDate(datetime.tz.utcToTz(from, fromTzData)).getTime();
|
|
49
|
-
let toDateObj = datetime.toDate(datetime.tz.utcToTz(to, toTzData)).getTime();
|
|
50
|
+
let toDateObj = datetime.toDate(isDateField ? to : datetime.tz.utcToTz(to, toTzData)).getTime();
|
|
50
51
|
let diffMin = new Date(to).getTime() - new Date(from).getTime();
|
|
51
52
|
let suffix = this.getSuffix(diffMin);
|
|
52
53
|
let diff = getDiffObj(diffMin);
|
|
@@ -211,6 +212,7 @@ DateTimeDiffFormat.propTypes = {
|
|
|
211
212
|
format: PropTypes.func,
|
|
212
213
|
from: PropTypes.string,
|
|
213
214
|
fromTzData: PropTypes.object,
|
|
215
|
+
isDateField: PropTypes.bool,
|
|
214
216
|
later: PropTypes.string,
|
|
215
217
|
others: PropTypes.func,
|
|
216
218
|
title: PropTypes.string,
|
|
@@ -14,7 +14,10 @@ export default class I18NProvider extends React.Component {
|
|
|
14
14
|
constructor(props, context) {
|
|
15
15
|
super(props, context);
|
|
16
16
|
i18NProviderUtils.getI18NValue = getI18NValue(props.i18n);
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
if (props.tzData) {
|
|
19
|
+
i18NProviderUtils.userDateFormat = userDateFormat(i18NProviderUtils.getI18NValue, props.tzData, props.timeFormat, props.datePattern, props.isEnabledCurrentYear);
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
componentDidUpdate(next) {
|
|
@@ -34,7 +37,11 @@ export default class I18NProvider extends React.Component {
|
|
|
34
37
|
this.reject = rej;
|
|
35
38
|
}).then(() => {
|
|
36
39
|
i18NProviderUtils.getI18NValue = getI18NValue(nextProps.i18n);
|
|
37
|
-
|
|
40
|
+
|
|
41
|
+
if (props.tzData) {
|
|
42
|
+
i18NProviderUtils.userDateFormat = userDateFormat(i18NProviderUtils.getI18NValue, props.tzData, props.timeFormat, props.datePattern, this.props.isEnabledCurrentYear);
|
|
43
|
+
}
|
|
44
|
+
|
|
38
45
|
this.promise = null;
|
|
39
46
|
}, () => {
|
|
40
47
|
this.promise = null;
|
|
@@ -22,7 +22,8 @@ export default class UserTimeDiffFormat extends Component {
|
|
|
22
22
|
className,
|
|
23
23
|
displayType,
|
|
24
24
|
dataId,
|
|
25
|
-
isOverdue
|
|
25
|
+
isOverdue,
|
|
26
|
+
isDateField
|
|
26
27
|
} = this.props;
|
|
27
28
|
let {
|
|
28
29
|
tzData,
|
|
@@ -63,7 +64,8 @@ export default class UserTimeDiffFormat extends Component {
|
|
|
63
64
|
isOverdue: isOverdue,
|
|
64
65
|
timeFormat: timeFormat,
|
|
65
66
|
datePattern: datePattern,
|
|
66
|
-
isEnabledCurrentYear: isEnabledCurrentYear
|
|
67
|
+
isEnabledCurrentYear: isEnabledCurrentYear,
|
|
68
|
+
isDateField: isDateField
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -74,6 +76,7 @@ UserTimeDiffFormat.propTypes = {
|
|
|
74
76
|
dataId: PropTypes.string,
|
|
75
77
|
displayType: PropTypes.oneOf(['date', 'time', 'dateTime']),
|
|
76
78
|
format: PropTypes.func,
|
|
79
|
+
isDateField: PropTypes.bool,
|
|
77
80
|
later: PropTypes.string,
|
|
78
81
|
others: PropTypes.func,
|
|
79
82
|
title: PropTypes.string,
|
|
@@ -93,11 +93,12 @@ var DateTimeDiffFormat = /*#__PURE__*/function (_React$Component) {
|
|
|
93
93
|
isOverdue = _this$props.isOverdue,
|
|
94
94
|
timeFormat = _this$props.timeFormat,
|
|
95
95
|
datePattern = _this$props.datePattern,
|
|
96
|
-
isEnabledCurrentYear = _this$props.isEnabledCurrentYear
|
|
96
|
+
isEnabledCurrentYear = _this$props.isEnabledCurrentYear,
|
|
97
|
+
isDateField = _this$props.isDateField;
|
|
97
98
|
|
|
98
99
|
var fromDateObj = _datetimejs["default"].toDate(_datetimejs["default"].tz.utcToTz(from, fromTzData)).getTime();
|
|
99
100
|
|
|
100
|
-
var toDateObj = _datetimejs["default"].toDate(_datetimejs["default"].tz.utcToTz(to, toTzData)).getTime();
|
|
101
|
+
var toDateObj = _datetimejs["default"].toDate(isDateField ? to : _datetimejs["default"].tz.utcToTz(to, toTzData)).getTime();
|
|
101
102
|
|
|
102
103
|
var diffMin = new Date(to).getTime() - new Date(from).getTime();
|
|
103
104
|
var suffix = this.getSuffix(diffMin);
|
|
@@ -268,6 +269,7 @@ DateTimeDiffFormat.propTypes = {
|
|
|
268
269
|
format: _propTypes["default"].func,
|
|
269
270
|
from: _propTypes["default"].string,
|
|
270
271
|
fromTzData: _propTypes["default"].object,
|
|
272
|
+
isDateField: _propTypes["default"].bool,
|
|
271
273
|
later: _propTypes["default"].string,
|
|
272
274
|
others: _propTypes["default"].func,
|
|
273
275
|
title: _propTypes["default"].string,
|
|
@@ -61,7 +61,11 @@ var I18NProvider = /*#__PURE__*/function (_React$Component) {
|
|
|
61
61
|
|
|
62
62
|
_this = _super.call(this, props, context);
|
|
63
63
|
i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(props.i18n);
|
|
64
|
-
|
|
64
|
+
|
|
65
|
+
if (props.tzData) {
|
|
66
|
+
i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, props.tzData, props.timeFormat, props.datePattern, props.isEnabledCurrentYear);
|
|
67
|
+
}
|
|
68
|
+
|
|
65
69
|
return _this;
|
|
66
70
|
}
|
|
67
71
|
|
|
@@ -85,7 +89,11 @@ var I18NProvider = /*#__PURE__*/function (_React$Component) {
|
|
|
85
89
|
_this2.reject = rej;
|
|
86
90
|
}).then(function () {
|
|
87
91
|
i18NProviderUtils.getI18NValue = (0, _utils.getI18NValue)(nextProps.i18n);
|
|
88
|
-
|
|
92
|
+
|
|
93
|
+
if (props.tzData) {
|
|
94
|
+
i18NProviderUtils.userDateFormat = (0, _utils.userDateFormat)(i18NProviderUtils.getI18NValue, props.tzData, props.timeFormat, props.datePattern, _this2.props.isEnabledCurrentYear);
|
|
95
|
+
}
|
|
96
|
+
|
|
89
97
|
_this2.promise = null;
|
|
90
98
|
}, function () {
|
|
91
99
|
_this2.promise = null;
|
|
@@ -73,7 +73,8 @@ var UserTimeDiffFormat = /*#__PURE__*/function (_Component) {
|
|
|
73
73
|
className = _this$props.className,
|
|
74
74
|
displayType = _this$props.displayType,
|
|
75
75
|
dataId = _this$props.dataId,
|
|
76
|
-
isOverdue = _this$props.isOverdue
|
|
76
|
+
isOverdue = _this$props.isOverdue,
|
|
77
|
+
isDateField = _this$props.isDateField;
|
|
77
78
|
|
|
78
79
|
var _ref = this.context || {},
|
|
79
80
|
tzData = _ref.tzData,
|
|
@@ -111,7 +112,8 @@ var UserTimeDiffFormat = /*#__PURE__*/function (_Component) {
|
|
|
111
112
|
isOverdue: isOverdue,
|
|
112
113
|
timeFormat: timeFormat,
|
|
113
114
|
datePattern: datePattern,
|
|
114
|
-
isEnabledCurrentYear: isEnabledCurrentYear
|
|
115
|
+
isEnabledCurrentYear: isEnabledCurrentYear,
|
|
116
|
+
isDateField: isDateField
|
|
115
117
|
});
|
|
116
118
|
}
|
|
117
119
|
}]);
|
|
@@ -126,6 +128,7 @@ UserTimeDiffFormat.propTypes = {
|
|
|
126
128
|
dataId: _propTypes["default"].string,
|
|
127
129
|
displayType: _propTypes["default"].oneOf(['date', 'time', 'dateTime']),
|
|
128
130
|
format: _propTypes["default"].func,
|
|
131
|
+
isDateField: _propTypes["default"].bool,
|
|
129
132
|
later: _propTypes["default"].string,
|
|
130
133
|
others: _propTypes["default"].func,
|
|
131
134
|
title: _propTypes["default"].string,
|
package/package.json
CHANGED
|
@@ -49,13 +49,14 @@ export default class DateTimeDiffFormat extends React.Component {
|
|
|
49
49
|
timeFormat,
|
|
50
50
|
datePattern,
|
|
51
51
|
isEnabledCurrentYear,
|
|
52
|
+
isDateField
|
|
52
53
|
} = this.props;
|
|
53
54
|
|
|
54
55
|
let fromDateObj = datetime
|
|
55
56
|
.toDate(datetime.tz.utcToTz(from, fromTzData))
|
|
56
57
|
.getTime();
|
|
57
58
|
let toDateObj = datetime
|
|
58
|
-
.toDate(datetime.tz.utcToTz(to, toTzData))
|
|
59
|
+
.toDate(isDateField ? to : datetime.tz.utcToTz(to, toTzData))
|
|
59
60
|
.getTime();
|
|
60
61
|
|
|
61
62
|
let diffMin = new Date(to).getTime() - new Date(from).getTime();
|
|
@@ -231,6 +232,7 @@ DateTimeDiffFormat.propTypes = {
|
|
|
231
232
|
format: PropTypes.func,
|
|
232
233
|
from: PropTypes.string,
|
|
233
234
|
fromTzData: PropTypes.object,
|
|
235
|
+
isDateField: PropTypes.bool,
|
|
234
236
|
later: PropTypes.string,
|
|
235
237
|
others: PropTypes.func,
|
|
236
238
|
title: PropTypes.string,
|
|
@@ -15,13 +15,15 @@ export default class I18NProvider extends React.Component {
|
|
|
15
15
|
constructor(props, context) {
|
|
16
16
|
super(props, context);
|
|
17
17
|
i18NProviderUtils.getI18NValue = getI18NValue(props.i18n);
|
|
18
|
-
|
|
19
|
-
i18NProviderUtils.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
if(props.tzData){
|
|
19
|
+
i18NProviderUtils.userDateFormat = userDateFormat(
|
|
20
|
+
i18NProviderUtils.getI18NValue,
|
|
21
|
+
props.tzData,
|
|
22
|
+
props.timeFormat,
|
|
23
|
+
props.datePattern,
|
|
24
|
+
props.isEnabledCurrentYear
|
|
25
|
+
);
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
componentDidUpdate(next) {
|
|
@@ -48,13 +50,15 @@ export default class I18NProvider extends React.Component {
|
|
|
48
50
|
}).then(
|
|
49
51
|
() => {
|
|
50
52
|
i18NProviderUtils.getI18NValue = getI18NValue(nextProps.i18n);
|
|
51
|
-
|
|
52
|
-
i18NProviderUtils.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
if(props.tzData){
|
|
54
|
+
i18NProviderUtils.userDateFormat = userDateFormat(
|
|
55
|
+
i18NProviderUtils.getI18NValue,
|
|
56
|
+
props.tzData,
|
|
57
|
+
props.timeFormat,
|
|
58
|
+
props.datePattern,
|
|
59
|
+
this.props.isEnabledCurrentYear
|
|
60
|
+
);
|
|
61
|
+
}
|
|
58
62
|
this.promise = null;
|
|
59
63
|
},
|
|
60
64
|
() => {
|
|
@@ -24,6 +24,7 @@ export default class UserTimeDiffFormat extends Component {
|
|
|
24
24
|
displayType,
|
|
25
25
|
dataId,
|
|
26
26
|
isOverdue,
|
|
27
|
+
isDateField
|
|
27
28
|
} = this.props;
|
|
28
29
|
let { tzData, timeFormat, datePattern, isEnabledCurrentYear } =
|
|
29
30
|
this.context || {};
|
|
@@ -61,6 +62,7 @@ export default class UserTimeDiffFormat extends Component {
|
|
|
61
62
|
timeFormat={timeFormat}
|
|
62
63
|
datePattern={datePattern}
|
|
63
64
|
isEnabledCurrentYear={isEnabledCurrentYear}
|
|
65
|
+
isDateField={isDateField}
|
|
64
66
|
/>
|
|
65
67
|
);
|
|
66
68
|
}
|
|
@@ -71,6 +73,7 @@ UserTimeDiffFormat.propTypes = {
|
|
|
71
73
|
dataId: PropTypes.string,
|
|
72
74
|
displayType: PropTypes.oneOf(['date', 'time', 'dateTime']),
|
|
73
75
|
format: PropTypes.func,
|
|
76
|
+
isDateField: PropTypes.bool,
|
|
74
77
|
later: PropTypes.string,
|
|
75
78
|
others: PropTypes.func,
|
|
76
79
|
title: PropTypes.string,
|