-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(src/compontents/events-carrosel/index.js/helpers/format-data/ind…
…ex.js/pages/events-description/index.js): Refatora funcao formatDate exibe hora em evento -@angeloneves19 -@thayanneregoo -@Ester-Arruda
- Loading branch information
1 parent
6cfaa06
commit ab772d0
Showing
3 changed files
with
22 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,29 @@ | ||
const daysOfWeekInPtBr = [ | ||
'Domingo', | ||
'Segunda', | ||
'Terça', | ||
'Quarta', | ||
'Quinta', | ||
'Sexta', | ||
'Sábado' | ||
] | ||
const formatDate = (date) => { | ||
const day = date.toLocaleDateString(undefined, { | ||
day: 'numeric', | ||
timeZone: 'UTC' | ||
}) | ||
const month = date.toLocaleDateString('pt-BR', { month: 'short' }) | ||
const year = date.toLocaleDateString(undefined, { | ||
return new Intl.DateTimeFormat('pt-BR', { | ||
timeZone: 'UTC', | ||
day: '2-digit', | ||
month: 'short', | ||
year: 'numeric', | ||
timeZone: 'UTC' | ||
}) | ||
return `${daysOfWeekInPtBr[date.getDay()]}, ${day} ${month} ${year}` | ||
weekday: 'long', | ||
}).format(date) | ||
} | ||
const formatWorkshopDuration = (workshop) => | ||
|
||
export const formatWorkshopDuration = (workshop) => | ||
`, ${workshop.attributes?.horario_inicio} > ${workshop.attributes?.horario_fim}` | ||
|
||
const endsOnSameDay = (workshop) => | ||
workshop.attributes?.data_inicio === workshop.attributes?.data_fim | ||
|
||
export const formatWorkshopDates = (workshop) => { | ||
if (workshop && workshop.attributes && workshop.attributes.data_inicio && workshop.attributes.data_fim) { | ||
if ( | ||
workshop && | ||
workshop.attributes && | ||
workshop.attributes.data_inicio && | ||
workshop.attributes.data_fim | ||
) { | ||
return endsOnSameDay(workshop) | ||
? formatDate(new Date(`${workshop.attributes?.data_inicio}T00:00:00-0300`)) | ||
: `${formatDate(new Date(`${workshop.attributes?.data_inicio}T00:00:00-0300`))} | ||
> ${formatDate(new Date(`${workshop.attributes?.data_fim}T00:00:00-0300`))}` | ||
? formatDate(new Date(workshop.attributes?.data_inicio)) | ||
: `${formatDate(new Date(workshop.attributes?.data_inicio))} | ||
> ${formatDate(new Date(workshop.attributes?.data_fim))}` | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters