summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-08-09 14:29:14 +0300
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-23 10:05:18 +0200
commit67a771cbb02ec9da3c60704901f3150b46a7262b (patch)
treef5e8e28cc0b7539196e7cdc2f4f4e7cc2c165fbd /src/util
parentd1194f0706789287b98996b629451042f62bf6eb (diff)
Create basic projects page with add-button
Diffstat (limited to 'src/util')
-rw-r--r--src/util/authorizations.js11
-rw-r--r--src/util/date-time.js32
2 files changed, 32 insertions, 11 deletions
diff --git a/src/util/authorizations.js b/src/util/authorizations.js
new file mode 100644
index 00000000..9a7d4e36
--- /dev/null
+++ b/src/util/authorizations.js
@@ -0,0 +1,11 @@
+export const AUTH_ICON_MAP = {
+ "OWN": "home",
+ "EDIT": "pencil",
+ "VIEW": "eye",
+};
+
+export const AUTH_DESCRIPTION_MAP = {
+ "OWN": "Own",
+ "EDIT": "Can Edit",
+ "VIEW": "Can View",
+};
diff --git a/src/util/date-time.js b/src/util/date-time.js
index f8a2ac45..0093e846 100644
--- a/src/util/date-time.js
+++ b/src/util/date-time.js
@@ -1,4 +1,16 @@
/**
+ * Parses and formats the given date-time string representation.
+ *
+ * The format assumed is "YYYY-MM-DDTHH:MM:SS".
+ *
+ * @param dateTimeString A string expressing a date and a time, in the above mentioned format.
+ * @returns {string} A human-friendly string version of that date and time.
+ */
+export function parseAndFormatDateTime(dateTimeString) {
+ return formatDateTime(parseDateTime(dateTimeString));
+}
+
+/**
* Parses date-time string representations and returns a parsed object.
*
* The format assumed is "YYYY-MM-DDTHH:MM:SS".
@@ -13,30 +25,28 @@ export function parseDateTime(dateTimeString) {
day: 0,
hour: 0,
minute: 0,
- second: 0
+ second: 0,
};
const dateAndTime = dateTimeString.split("T");
const dateComponents = dateAndTime[0].split("-");
- output.year = parseInt(dateComponents[0]);
- output.month = parseInt(dateComponents[1]);
- output.day = parseInt(dateComponents[2]);
+ output.year = parseInt(dateComponents[0], 10);
+ output.month = parseInt(dateComponents[1], 10);
+ output.day = parseInt(dateComponents[2], 10);
const timeComponents = dateAndTime[1].split(":");
- output.hour = parseInt(timeComponents[0]);
- output.minute = parseInt(timeComponents[1]);
- output.second = parseInt(timeComponents[2]);
+ output.hour = parseInt(timeComponents[0], 10);
+ output.minute = parseInt(timeComponents[1], 10);
+ output.second = parseInt(timeComponents[2], 10);
return output;
}
/**
- * Serializes the given date and time value to a string.
- *
- * The format assumed is "YYYY-MM-DDTHH:MM:SS".
+ * Serializes the given date and time value to a human-friendly string.
*
* @param dateTime An object representation of a date and time.
- * @returns {string} A string representation of that date and time.
+ * @returns {string} A human-friendly string version of that date and time.
*/
export function formatDateTime(dateTime) {
let date;