(Fix) US date format (#70)
* Show if ballot is finalized * Display US date format * Codacy suggestion: Expected { after 'if' condition. (curly) * typo
This commit is contained in:
parent
4d2293abda
commit
d25086561a
|
@ -8,6 +8,7 @@ import swal from "sweetalert2";
|
||||||
|
|
||||||
const ACCEPT = 1;
|
const ACCEPT = 1;
|
||||||
const REJECT = 2;
|
const REJECT = 2;
|
||||||
|
const USDateTimeFormat = "MM/DD/YYYY h:mm:ss A";
|
||||||
@inject("commonStore", "contractsStore", "ballotStore", "routing")
|
@inject("commonStore", "contractsStore", "ballotStore", "routing")
|
||||||
@observer
|
@observer
|
||||||
export class BallotCard extends React.Component {
|
export class BallotCard extends React.Component {
|
||||||
|
@ -61,20 +62,20 @@ export class BallotCard extends React.Component {
|
||||||
getStartTime = async () => {
|
getStartTime = async () => {
|
||||||
const { contractsStore, id, votingType } = this.props;
|
const { contractsStore, id, votingType } = this.props;
|
||||||
let startTime = await this.getContract(contractsStore, votingType).getStartTime(id);
|
let startTime = await this.getContract(contractsStore, votingType).getStartTime(id);
|
||||||
this.startTime = moment.utc(startTime * 1000).format("DD/MM/YYYY h:mm:ss A");
|
this.startTime = moment.utc(startTime * 1000).format(USDateTimeFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action("Get end time of keys ballot")
|
@action("Get end time of keys ballot")
|
||||||
getEndTime = async () => {
|
getEndTime = async () => {
|
||||||
const { contractsStore, id, votingType } = this.props;
|
const { contractsStore, id, votingType } = this.props;
|
||||||
let endTime = await this.getContract(contractsStore, votingType).getEndTime(id);
|
let endTime = await this.getContract(contractsStore, votingType).getEndTime(id);
|
||||||
this.endTime = moment.utc(endTime * 1000).format("DD/MM/YYYY h:mm:ss A");
|
this.endTime = moment.utc(endTime * 1000).format(USDateTimeFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action("Calculate time to finish")
|
@action("Calculate time to finish")
|
||||||
calcTimeToFinish = () => {
|
calcTimeToFinish = () => {
|
||||||
const now = moment();
|
const now = moment();
|
||||||
const finish = moment.utc(this.endTime, "DD/MM/YYYY h:mm:ss A");
|
const finish = moment.utc(this.endTime, USDateTimeFormat);
|
||||||
let ms = finish.diff(now);
|
let ms = finish.diff(now);
|
||||||
if (ms <= 0) {
|
if (ms <= 0) {
|
||||||
return this.timeToFinish = moment(0, "h").format("HH") + ":" + moment(0, "m").format("mm") + ":" + moment(0, "s").format("ss");
|
return this.timeToFinish = moment(0, "h").format("HH") + ":" + moment(0, "m").format("mm") + ":" + moment(0, "s").format("ss");
|
||||||
|
|
Loading…
Reference in New Issue