Skip to content

Commit

Permalink
refactor: format spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkaradachki committed Jul 5, 2019
1 parent 4f39196 commit e5d08e7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/dates/parse-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const numberRegExp = {
const numberRegex = /\d+/;
const PLACEHOLDER = "{0}";

const leadingSpacesRegex = /^ +/;
const trailingSpacesRegex = / +$/;
const leadingSpacesRegex = /^ */;
const trailingSpacesRegex = / *$/;

const standardDateFormats = [
"yyyy/MM/dd HH:mm:ss",
Expand Down Expand Up @@ -460,8 +460,8 @@ function createDate(state) {
}

function addFormatSpaces(value, format) {
const leadingSpaces = (leadingSpacesRegex.exec(format) || [])[0] || '';
const trailingSpaces = (trailingSpacesRegex.exec(format) || [])[0] || '';
const leadingSpaces = leadingSpacesRegex.exec(format)[0];
const trailingSpaces = trailingSpacesRegex.exec(format);

return `${ leadingSpaces }${ value }${ trailingSpaces }`;
}
Expand Down

0 comments on commit e5d08e7

Please sign in to comment.