2018-05-24 09:21:44 +00:00
|
|
|
/**
|
|
|
|
* Transforms a UTC date to JSON date without datetime.
|
2018-05-25 15:25:35 +00:00
|
|
|
*
|
2018-05-24 09:21:44 +00:00
|
|
|
* @param {date} date Date to format
|
|
|
|
* @return {String} Formatted date string
|
|
|
|
*/
|
|
|
|
export function toJsonDate(date) {
|
2018-05-25 09:40:04 +00:00
|
|
|
date = new Date(date);
|
|
|
|
|
2018-05-24 09:21:44 +00:00
|
|
|
let day = date.getDate();
|
|
|
|
let month = date.getMonth() + 1;
|
|
|
|
let year = date.getFullYear();
|
|
|
|
|
|
|
|
if (day < 10)
|
2018-05-25 15:25:35 +00:00
|
|
|
day = `0${day}`;
|
2018-05-24 09:21:44 +00:00
|
|
|
|
2018-05-25 15:25:35 +00:00
|
|
|
if (month < 10)
|
|
|
|
month = `0${month}`;
|
2018-05-24 09:21:44 +00:00
|
|
|
|
2018-05-25 09:40:04 +00:00
|
|
|
return new Date(`${year}-${month}-${day}`);
|
2018-05-25 15:25:35 +00:00
|
|
|
}
|