Skip to content

Commit

Permalink
Merge pull request #96 from edenia/fix/ui
Browse files Browse the repository at this point in the history
fix(webapp): fixed dates format
  • Loading branch information
fagomezra committed Mar 28, 2023
2 parents 046220e + d6c3746 commit 5a92acc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ export const ElectionScheduleSegment = () => {
they're participating in, we do expect the Community Room to
turn into an epic watch party that you might not want to miss!
</Text>
<Text type="info">
All times are local ({electionDates.startDateTime.format("z")})
</Text>
<Text type="info">All times are UTC</Text>
<Schedule>
<ScheduleEntry timeUtc="12:00">
Community Zoom Room opens. We'll discuss what to expect, how
Expand Down Expand Up @@ -76,7 +74,9 @@ interface ScheduleEntry {
}

const ScheduleEntry = ({ timeUtc, children }: ScheduleEntry) => {
const timeString = dayjs(`2021-10-09T${timeUtc}:00.000Z`).format("LT");
const timeString = dayjs(`2021-10-09T${timeUtc}:00.000Z`)
.utc()
.format("LT");
return (
<li>
<div className="flex flex-col sm:flex-row sm:space-x-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ export const ParticipationCard = ({ election }: Props) => {
}

const electionDate = electionDates.startDateTime.format("LL");
const electionStartTime = electionDates.startDateTime.format("LT z");
const electionParticipationLimitTime = electionDates.participationTimeLimit.format(
"LLL z"
);
const electionStartTime = `${electionDates.startDateTime.format("LT")} UTC`;
const electionParticipationLimitTime = `${electionDates.participationTimeLimit.format(
"LLL"
)} UTC`;

const isPastElectionParticipationTimeLimit = dayjs().isAfter(
electionDates.participationTimeLimit
Expand Down
5 changes: 4 additions & 1 deletion packages/webapp/src/elections/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import dayjs, { Dayjs } from "dayjs";
import utc from "dayjs/plugin/utc";

dayjs.extend(utc);

import { ActiveStateConfigType, SimpleVoteData } from "./interfaces";
import { getMemberGroupFromIndex } from "./api";
Expand All @@ -13,7 +16,7 @@ export const extractElectionDates = (election: any) => {
throw new Error("Error parsing the Election start date.");
}

const startDateTime = dayjs(rawStartDateTime);
const startDateTime = dayjs(rawStartDateTime).utc();
const participationTimeLimit = startDateTime.subtract(24, "hour");
const estimatedEndDateTime = startDateTime.add(
10, // TODO: estimate and calculate this value properly based on round numbers
Expand Down

0 comments on commit 5a92acc

Please sign in to comment.