summaryrefslogtreecommitdiff
path: root/src/util/date-time.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-27 21:11:24 +0200
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-27 21:11:24 +0200
commitf859c43400ef6de29b340abfd534f2f59c183e2b (patch)
treeedb32ca220c037713c20b48bcf20ee0923cfeff3 /src/util/date-time.js
parent911290cb5e13482acf9701ec9da7a3b16fd17061 (diff)
Add spec-test for date-time util module
Diffstat (limited to 'src/util/date-time.js')
-rw-r--r--src/util/date-time.js44
1 files changed, 15 insertions, 29 deletions
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) {
@@ -71,34 +71,6 @@ export function formatDateTime(dateTime) {
}
/**
- * 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.
*
* @param seconds The number of seconds.
@@ -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();
+ }
+}