Skip to content

Commit

Permalink
style(date): Avoid use of ternary expressions for optional args
Browse files Browse the repository at this point in the history
  • Loading branch information
Droogans committed Oct 10, 2018
1 parent 816b658 commit 4e08455
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions lib/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ var _Date = function (faker) {
* @param {date} refDate
*/
self.past = function (years, refDate) {
var date = (refDate) ? new Date(Date.parse(refDate)) : new Date();
var date = new Date();
if (refDate !== undefined) {
date = new Date(Date.parse(refDate));
}

var range = {
min: 1000,
max: (years || 1) * 365 * 24 * 3600 * 1000
Expand All @@ -33,7 +37,11 @@ var _Date = function (faker) {
* @param {date} refDate
*/
self.future = function (years, refDate) {
var date = (refDate) ? new Date(Date.parse(refDate)) : new Date();
var date = new Date();
if (refDate !== undefined) {
date = new Date(Date.parse(refDate));
}

var range = {
min: 1000,
max: (years || 1) * 365 * 24 * 3600 * 1000
Expand Down Expand Up @@ -70,7 +78,11 @@ var _Date = function (faker) {
* @param {date} refDate
*/
self.recent = function (days, refDate) {
var date = (refDate) ? new Date(Date.parse(refDate)) : new Date();
var date = new Date();
if (refDate !== undefined) {
date = new Date(Date.parse(refDate));
}

var range = {
min: 1000,
max: (days || 1) * 24 * 3600 * 1000
Expand All @@ -91,7 +103,11 @@ var _Date = function (faker) {
* @param {date} refDate
*/
self.soon = function (days, refDate) {
var date = (refDate) ? new Date(Date.parse(refDate)) : new Date();
var date = new Date();
if (refDate !== undefined) {
date = new Date(Date.parse(refDate));
}

var range = {
min: 1000,
max: (days || 1) * 24 * 3600 * 1000
Expand Down

0 comments on commit 4e08455

Please sign in to comment.