diff --git a/src/utils/transformToScheduleHour.js b/src/utils/transformToScheduleHour.js index b989d8b..253b1dd 100644 --- a/src/utils/transformToScheduleHour.js +++ b/src/utils/transformToScheduleHour.js @@ -1,15 +1,31 @@ -import dayjs from 'dayjs'; +// import dayjs from 'dayjs'; + +const adjustGMT = (hours) => { + const localTime = hours - 3; + const withZero = localTime.toString().length === 1 ? `0${localTime}` : localTime; + return withZero; +}; + +const dateToTime = (date) => { + const fullTime = date.split('T')[1]; + const time = fullTime.substring(0, 5); + const hours = time.split(':')[0]; + const minutes = time.split(':')[1]; + + return `${adjustGMT(hours)}:${minutes}`; +}; /** * @param {string} start * @param {string} [end] * @retuns {string} */ + const transformToScheduleHour = (start, end = null) => { - start = dayjs(start).format('HH:mm'); + start = dateToTime(start); if (end) { - end = dayjs(end).format('HH:mm'); + end = dateToTime(end); } return start + (end ? ` - ${end}` : '');