Skip to content

Commit

Permalink
Make codeclimate happy
Browse files Browse the repository at this point in the history
Not sure this really helps readability or complexity though...
  • Loading branch information
jcaron23 committed Jul 1, 2019
1 parent 9b3ed93 commit 7a713cb
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/utils/format-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ import {
formatUTCDateAsUTC
} from './index'

function formatLocalDate(args = [], outputType) {
if (outputType == 'utc') {
return formatLocalDateAsUTC(args, outputType)
}
return formatLocalDateAsLocal(args, outputType)
}

function formatUTCDate(args = [], outputType) {
if (outputType == 'utc') {
return formatUTCDateAsUTC(args, outputType)
}
return formatUTCDateAsLocal(args, outputType)
}

export default function formatDate(args = [], outputType = 'utc', inputType = 'local') {
const [year, month, date, hours, minutes, seconds] = args

Expand All @@ -14,15 +28,9 @@ export default function formatDate(args = [], outputType = 'utc', inputType = 'l
}

if (inputType === 'local') {
if (outputType == 'utc') {
return formatLocalDateAsUTC([year, month, date, hours, minutes, seconds || 0])
}
return formatLocalDateAsLocal([year, month, date, hours, minutes, seconds || 0])
return formatLocalDate([year, month, date, hours, minutes, seconds || 0], outputType);
}

// type === 'utc'
if (outputType == 'utc') {
return formatUTCDateAsUTC([year, month, date, hours, minutes, seconds || 0])
}
return formatUTCDateAsLocal([year, month, date, hours, minutes, seconds || 0])
return formatUTCDate([year, month, date, hours, minutes, seconds || 0], outputType);
}

0 comments on commit 7a713cb

Please sign in to comment.