-
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.
Merge pull request #112 from aceleradora-TW/73/feat-eventos-mostrar-a…
…tividades 73/feat eventos mostrar atividades
- Loading branch information
Showing
3 changed files
with
385 additions
and
227 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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, { | ||
year: 'numeric', | ||
timeZone: 'UTC' | ||
}) | ||
return `${daysOfWeekInPtBr[date.getDay()]}, ${day} ${month} ${year}` | ||
} | ||
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) { | ||
return endsOnSameDay(workshop) | ||
? formatDate(new Date(workshop.attributes?.data_inicio)) | ||
: `${formatDate(new Date(workshop.attributes?.data_inicio))} | ||
> ${formatDate(new Date(workshop.attributes?.data_fim))}` | ||
} | ||
} |
Oops, something went wrong.