(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:
Victor Baranov 2018-01-17 02:58:45 +03:00 committed by Roman Storm
parent 4d2293abda
commit d25086561a
1 changed files with 4 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import swal from "sweetalert2";
const ACCEPT = 1;
const REJECT = 2;
const USDateTimeFormat = "MM/DD/YYYY h:mm:ss A";
@inject("commonStore", "contractsStore", "ballotStore", "routing")
@observer
export class BallotCard extends React.Component {
@ -61,20 +62,20 @@ export class BallotCard extends React.Component {
getStartTime = async () => {
const { contractsStore, id, votingType } = this.props;
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")
getEndTime = async () => {
const { contractsStore, id, votingType } = this.props;
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")
calcTimeToFinish = () => {
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);
if (ms <= 0) {
return this.timeToFinish = moment(0, "h").format("HH") + ":" + moment(0, "m").format("mm") + ":" + moment(0, "s").format("ss");