Skip to content

Commit

Permalink
feat(components): improved format date
Browse files Browse the repository at this point in the history
  • Loading branch information
AngeloCG97 committed Mar 10, 2023
1 parent db9b28d commit b2d73a3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const ElectionScheduleSegment = () => {
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")})
All times are UTC ({electionDates.startDateTime})
</Text>
<Schedule>
<ScheduleEntry timeUtc="12:00">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import React, { useState } from "react";
import { useQueryClient } from "react-query";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";

dayjs.extend(utc);

import {
delay,
Expand Down Expand Up @@ -91,11 +88,11 @@ export const ParticipationCard = ({ election }: Props) => {
return <Text>{(e as Error).message}</Text>;
}

const electionDate = electionDates.startDateTime.utc().format("LL");
const electionStartTime = electionDates.startDateTime.utc().format("LT");
const electionParticipationLimitTime = electionDates.participationTimeLimit
.utc()
.format("LLL");
const electionDate = electionDates.startDateTime.format("LL");
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 b2d73a3

Please sign in to comment.