Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG - Events dates are dynamic (different timezones), but time is static! #2966

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions components/training/eventBooking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ export const isEmpty = (value) => {
);
};

export const formatTimeWithAmPm = (date) => {
let hours = date.getHours();
const minutes = date.getMinutes();
const amPm = hours >= 12 ? "PM" : "AM";

hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'

const formattedMinutes = minutes < 10 ? "0" + minutes : minutes;

return minutes === 0
? `${hours}${amPm}`
: `${hours}:${formattedMinutes}${amPm}`;
};

const classes = {
mdColSpan4: "md:col-span-4",
mdColSpan6: "md:col-span-6",
Expand Down Expand Up @@ -96,7 +111,11 @@ const EventCard = ({ event, count, index, eventDurationInDays, schema }) => {
/>
</div>
<div className="py-0.5 text-xs uppercase text-gray-500">
{EventModel.TIMINGS}
{event.date && event.endDate
? formatTimeWithAmPm(new Date(event.date)) +
" - " +
formatTimeWithAmPm(new Date(event.endDate))
: EventModel.TIMINGS}
fenix2222 marked this conversation as resolved.
Show resolved Hide resolved
</div>
</>
)}
Expand Down Expand Up @@ -260,6 +279,7 @@ export const eventBookingBlock = {
value: "eventList",
city: "city",
date: "date",
endDate: "endDate",
bookingURL: "bookingURL",
location: "location",
},
Expand Down Expand Up @@ -321,7 +341,17 @@ export const eventBookingSchema: Template = {
label: "Start Date",
name: eventBookingBlock.eventList.date,
ui: {
parse: (value) => value && value.format("YYYY-MM-DD"),
parse: (value) => value && value.format("YYYY-MM-DD HH:mm"),
timeFormat: "HH:mm",
},
},
{
type: "datetime",
label: "End Date (for time only)",
name: eventBookingBlock.eventList.endDate,
ui: {
parse: (value) => value && value.format("YYYY-MM-DD HH:mm"),
timeFormat: "HH:mm",
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion tina/tina-lock.json

Large diffs are not rendered by default.

Loading