Skip to content

Commit

Permalink
Ajustes adicional de bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bardolog1 committed Aug 7, 2023
1 parent c38af78 commit 3e88d22
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/hooks/useDateFormatted.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import {useState, useEffect} from 'react';
export function useDateFormatted(data, order) {

const [dateFormatted, setDateFormatted] = useState(null);
const today = new Date().getDay();
const days = [null, 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
const months = [null, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct','Nov', 'Dec'];



useEffect(() => {

const today = new Date().getDay();
const days = [null, 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
const months = [null, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct','Nov', 'Dec'];

const getDate = () => {
if(
data !== null &&
Expand All @@ -29,18 +31,16 @@ export function useDateFormatted(data, order) {
}else {
const dayMonth = new Date().getDate();
const monthCurrent = new Date().getMonth();

setDateFormatted( days[(today-1)<1? 7 : (today-1)] + ', ' + dayMonth + ' ' + months[monthCurrent+1]);


}

}
getDate();

const intervalId = setInterval(() => getDate, 60000);
return () => clearInterval(intervalId);
}, [data, order, today, days, months]);
}, [data, order]);



Expand Down

0 comments on commit 3e88d22

Please sign in to comment.