Skip to content

Commit b9af74e

Browse files
committed
2 parents 000e980 + da5b2fa commit b9af74e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/DateInput.jsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ const updateInputWidth = (element) => {
3232
container.removeChild(span);
3333
};
3434

35+
const removeUnwantedCharacters = str => str
36+
.split('')
37+
// We don't want spaces in dates
38+
.filter(a => a.charCodeAt(0) !== 32)
39+
// Internet Explorer specific
40+
.filter(a => a.charCodeAt(0) !== 8206)
41+
.join('');
42+
3543
const min = (...args) => Math.min(...args.filter(a => typeof a === 'number'));
3644
const max = (...args) => Math.max(...args.filter(a => typeof a === 'number'));
3745

@@ -194,11 +202,7 @@ export default class DateInput extends Component {
194202
const date = new Date(2017, 11, 11);
195203

196204
return (
197-
formatDate(date)
198-
.split('')
199-
// Internet Explorer specific
200-
.filter(a => a.charCodeAt(0) !== 8206)
201-
.join('')
205+
removeUnwantedCharacters(formatDate(date))
202206
.match(/[^0-9]/)[0]
203207
);
204208
}
@@ -216,7 +220,7 @@ export default class DateInput extends Component {
216220
const date = new Date(2017, 11, 11);
217221

218222
return (
219-
formatDate(date)
223+
removeUnwantedCharacters(formatDate(date))
220224
.replace('2017', 'year')
221225
.replace('12', 'month')
222226
.replace('11', 'day')
@@ -391,10 +395,6 @@ export default class DateInput extends Component {
391395

392396
return (
393397
placeholder
394-
.split('')
395-
// Internet Explorer specific
396-
.filter(a => a.charCodeAt(0) !== 8206)
397-
.join('')
398398
.split(divider)
399399
.map((part) => {
400400
switch (part) {

0 commit comments

Comments
 (0)