17 lines
592 B
JavaScript
17 lines
592 B
JavaScript
const utils = {
|
|
/**
|
|
* A function that takes a date in the format 'dd/mm/yyyy' and returns the day of the week as a string.
|
|
*
|
|
* @param {string} date - The input date in the format 'dd/mm/yyyy'
|
|
* @return {string} The day of the week
|
|
*/
|
|
getDay(date) {
|
|
let isoDate = date.split('/');
|
|
date = isoDate[2] + '-' + isoDate[1] + '-' + isoDate[0];
|
|
const names = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
const day = new Date(date).getDay();
|
|
return names[day];
|
|
},
|
|
};
|
|
export default utils;
|