Skip to content

Commit

Permalink
refactor: rename prop
Browse files Browse the repository at this point in the history
  • Loading branch information
joaofsl committed Jun 8, 2022
1 parent 1625376 commit d4c2e9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions js/time.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const dateString = (
timestamp = null,
separator = "/",
{ year = true, month = true, day = true, reverse = false } = {}
{ year = true, month = true, day = true, reverseDate = false } = {}
) => {
timestamp = timestamp === null ? new Date() / 1000 : timestamp;
let buffer = [];
Expand All @@ -13,14 +13,14 @@ export const dateString = (
if (day) buffer.push(dayV);
if (month) buffer.push(monthV);
if (year) buffer.push(yearV);
if (reverse) buffer = buffer.reverse();
if (reverseDate) buffer = buffer.reverse();
return buffer.join(separator);
};

export const dateStringUTC = (
timestamp = null,
separator = "/",
{ year = true, month = true, day = true, reverse = false } = {}
{ year = true, month = true, day = true, reverseDate = false } = {}
) => {
timestamp = timestamp === null ? new Date() / 1000 : timestamp;
let buffer = [];
Expand All @@ -32,7 +32,7 @@ export const dateStringUTC = (
if (day) buffer.push(dayV);
if (month) buffer.push(monthV);
if (year) buffer.push(yearV);
if (reverse) buffer = buffer.reverse();
if (reverseDate) buffer = buffer.reverse();
return buffer.join(separator);
};

Expand Down Expand Up @@ -79,7 +79,7 @@ export const dateTimeString = (
year = true,
month = true,
day = true,
reverse = false,
reverseDate = false,
hours = true,
minutes = true,
seconds = true
Expand All @@ -89,7 +89,7 @@ export const dateTimeString = (
year: year,
month: month,
day: day,
reverse: reverse
reverseDate: reverseDate
});
const timeS = timeString(timestamp, timeSeparator, {
hours: hours,
Expand Down
6 changes: 3 additions & 3 deletions test/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("Time", function() {

it("should format simple date strings and reverse the output", () => {
const result = ripeCommons.dateString(new Date("10/12/2020") / 1000, "-", {
reverse: true
reverseDate: true
});
assert.deepStrictEqual(result, "2020-10-12");
});
Expand All @@ -29,7 +29,7 @@ describe("Time", function() {

it("should format simple date strings and reverse the output", () => {
const result = ripeCommons.dateStringUTC(new Date("10/12/2020") / 1000, "-", {
reverse: true
reverseDate: true
});
assert.deepStrictEqual(result, "2020-10-12");
});
Expand Down Expand Up @@ -76,7 +76,7 @@ describe("Time", function() {
" ",
"/",
":",
{ reverse: true }
{ reverseDate: true }
);
assert.deepStrictEqual(result, "2020/10/12 00:00:00");
});
Expand Down

0 comments on commit d4c2e9f

Please sign in to comment.