From f859c43400ef6de29b340abfd534f2f59c183e2b Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 27 Sep 2017 21:11:24 +0200 Subject: Add spec-test for date-time util module --- src/util/date-time.js | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) (limited to 'src/util/date-time.js') diff --git a/src/util/date-time.js b/src/util/date-time.js index 26039368..e9d7664f 100644 --- a/src/util/date-time.js +++ b/src/util/date-time.js @@ -45,7 +45,7 @@ export function parseDateTime(dateTimeString) { /** * Serializes the given date and time value to a human-friendly string. * - * @param dateTime An rack representation of a date and time. + * @param dateTime An object representation of a date and time. * @returns {string} A human-friendly string version of that date and time. */ export function formatDateTime(dateTime) { @@ -70,34 +70,6 @@ export function formatDateTime(dateTime) { addPaddingToTwo(dateTime.minute); } -/** - * Returns a string representation of the current date and time. - * - * The format assumed is "YYYY-MM-DDTHH:MM:SS". - * - * @returns {string} A string representation of the current date and time. - */ -export function getCurrentDateTime() { - const currentDate = new Date(); - return currentDate.getFullYear() + "-" + addPaddingToTwo(currentDate.getMonth() + 1) + "-" + - addPaddingToTwo(currentDate.getDate()) + "T" + addPaddingToTwo(currentDate.getHours()) + ":" + - addPaddingToTwo(currentDate.getMinutes()) + ":" + addPaddingToTwo(currentDate.getSeconds()); -} - -/** - * Pads the given integer to have at least two digits. - * - * @param integer An integer to be padded. - * @returns {string} A string containing the padded integer. - */ -export function addPaddingToTwo(integer) { - if (integer < 10) { - return "0" + integer.toString(); - } else { - return integer.toString(); - } -} - /** * Formats the given number of seconds/ticks to a formatted time representation. * @@ -125,3 +97,17 @@ export function convertSecondsToFormattedTime(seconds) { return hour + "h" + addPaddingToTwo(minute) + "m" + addPaddingToTwo(second) + "s"; } } + +/** + * Pads the given integer to have at least two digits. + * + * @param integer An integer to be padded. + * @returns {string} A string containing the padded integer. + */ +function addPaddingToTwo(integer) { + if (integer < 10) { + return "0" + integer.toString(); + } else { + return integer.toString(); + } +} -- cgit v1.2.3