Visual Console Refactor: changed a function name

Former-commit-id: 3adfb5fbdebe495fbd88d53d7ce93bbdf5ce0876
This commit is contained in:
Alejandro Gallardo Escobar 2019-04-24 13:07:51 +02:00
parent 4eff6f0cc3
commit 46d7d68585
2 changed files with 19 additions and 19 deletions

View File

@ -2,7 +2,7 @@ import {
parseIntOr,
stringIsEmpty,
notEmptyStringOr,
padLeft,
leftPad,
prefixedCssRules,
decodeBase64,
humanDate,
@ -42,18 +42,18 @@ describe("function notEmptyStringOr", () => {
});
});
describe("function padLeft", () => {
describe("function leftPad", () => {
it("should pad properly", () => {
expect(padLeft(1, 2, 0)).toBe("01");
expect(padLeft(1, 4, 0)).toBe("0001");
expect(padLeft(1, 4, "0")).toBe("0001");
expect(padLeft("1", 4, "0")).toBe("0001");
expect(padLeft(10, 4, 0)).toBe("0010");
expect(padLeft("bar", 6, "foo")).toBe("foobar");
expect(padLeft("bar", 11, "foo")).toBe("foofoofobar");
expect(padLeft("bar", 4, "foo")).toBe("fbar");
expect(padLeft("bar", 2, "foo")).toBe("ar");
expect(padLeft("bar", 3, "foo")).toBe("bar");
expect(leftPad(1, 2, 0)).toBe("01");
expect(leftPad(1, 4, 0)).toBe("0001");
expect(leftPad(1, 4, "0")).toBe("0001");
expect(leftPad("1", 4, "0")).toBe("0001");
expect(leftPad(10, 4, 0)).toBe("0010");
expect(leftPad("bar", 6, "foo")).toBe("foobar");
expect(leftPad("bar", 11, "foo")).toBe("foofoofobar");
expect(leftPad("bar", 4, "foo")).toBe("fbar");
expect(leftPad("bar", 2, "foo")).toBe("ar");
expect(leftPad("bar", 3, "foo")).toBe("bar");
});
});

View File

@ -82,7 +82,7 @@ export function parseBoolean(value: any): boolean {
* @param pad Text to add.
* @return Padded text.
*/
export function padLeft(
export function leftPad(
value: string | number,
length: number,
pad: string | number = " "
@ -287,10 +287,10 @@ export function decodeBase64(input: string): string {
export function humanDate(initialDate: Date | null = null): string {
const date = initialDate || new Date();
// Use getDate, getDay returns the week day.
const day = padLeft(date.getDate(), 2, 0);
const day = leftPad(date.getDate(), 2, 0);
// The getMonth function returns the month starting by 0.
const month = padLeft(date.getMonth() + 1, 2, 0);
const year = padLeft(date.getFullYear(), 4, 0);
const month = leftPad(date.getMonth() + 1, 2, 0);
const year = leftPad(date.getFullYear(), 4, 0);
// Format: 'd/m/Y'.
return `${day}/${month}/${year}`;
@ -304,9 +304,9 @@ export function humanDate(initialDate: Date | null = null): string {
*/
export function humanTime(initialDate: Date | null = null): string {
const date = initialDate || new Date();
const hours = padLeft(date.getHours(), 2, 0);
const minutes = padLeft(date.getMinutes(), 2, 0);
const seconds = padLeft(date.getSeconds(), 2, 0);
const hours = leftPad(date.getHours(), 2, 0);
const minutes = leftPad(date.getMinutes(), 2, 0);
const seconds = leftPad(date.getSeconds(), 2, 0);
return `${hours}:${minutes}:${seconds}`;
}