Skip to content
Snippets Groups Projects
Commit d4ce35e1 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Ajout d'un fonction de formatage de date dans unicaenVue

parent 2cde5763
Branches master
No related tags found
No related merge requests found
...@@ -47,7 +47,39 @@ const unicaenVue = { ...@@ -47,7 +47,39 @@ const unicaenVue = {
} }
return params.join('&'); return params.join('&');
},
/**
* Formate une date pour affichage
*
* @param String val
* @param String format
* @returns String
*/
formatDate: (val, format) => {
if (val === undefined) {
return undefined;
} }
let date = new Date(val);
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hour = date.getHours().toString().padStart(2, '0');
const min = date.getMinutes().toString().padStart(2, '0');
const sec = date.getSeconds().toString().padStart(2, '0');
if(format) {
switch(format){
case 'datetime':
return `${day}/${month}/${year} à ${hour}:${min}`;
case 'time':
return `${hour}:${min}:${sec}`;
}
}
return `${day}/${month}/${year}`;
}
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment