Merge pull request #88 from rstormsf/fix_timezone

Fix timezone
This commit is contained in:
Victor Baranov 2018-01-23 23:34:47 +03:00 committed by GitHub
commit 61a11a78ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 16 deletions

View File

@ -43,7 +43,8 @@ export class BallotKeysMetadata extends React.Component {
<div className="form-el">
<label htmlFor="key">Ballot End</label>
<input type="datetime-local" id="key"
value={ballotStore.endTime}
value={ballotStore.endTime}
min={ballotStore.endTime}
onChange={e => ballotStore.changeBallotMetadata(e, "endTime")}
/>
<p className="hint">

View File

@ -8,7 +8,6 @@ import { BallotKeysMetadata } from './BallotKeysMetadata';
import { BallotMinThresholdMetadata } from './BallotMinThresholdMetadata';
import { BallotProxyMetadata } from './BallotProxyMetadata';
import { messages } from "../messages";
@inject("commonStore", "ballotStore", "validatorStore", "contractsStore", "routing")
@observer
export class NewBallot extends React.Component {
@ -19,8 +18,10 @@ export class NewBallot extends React.Component {
checkValidation() {
const { commonStore, contractsStore, ballotStore, validatorStore } = this.props;
const isAfter = moment(ballotStore.endTime).isAfter(moment());
const isTwoDaysMinimum = moment(ballotStore.endTime).isAfter(moment().add(2, 'days'));
const twoDays = moment.utc().add(2, 'days').format();
let neededMinutes = moment(twoDays).diff(moment(ballotStore.endTime), 'minutes');
let neededHours = Math.round(neededMinutes/60);
let duration = 48 - neededHours;
if (ballotStore.isNewValidatorPersonalData) {
for (let validatorProp in validatorStore) {
@ -32,20 +33,15 @@ export class NewBallot extends React.Component {
}
}
if (!isAfter) {
swal("Warning!", messages.END_TIME_SHOULD_BE_GREATER_THAN_NOW_MSG, "warning");
commonStore.hideLoading();
return false;
}
if(!ballotStore.memo){
swal("Warning!", messages.DESCRIPTION_IS_EMPTY, "warning");
commonStore.hideLoading();
return false;
}
if(!isTwoDaysMinimum) {
swal("Warning!", messages.SHOULD_BE_MORE_THAN_TWO_DAYS, "warning");
if(neededMinutes > 0) {
neededMinutes = neededHours*60 - neededMinutes;
swal("Warning!", messages.SHOULD_BE_MORE_THAN_TWO_DAYS(duration, neededHours, neededMinutes), "warning");
commonStore.hideLoading();
return false;
}
@ -189,8 +185,7 @@ export class NewBallot extends React.Component {
default:
break;
}
const curDate = new Date();
let curDateInSeconds = moment(curDate).add(5, 'minute').unix();
let curDateInSeconds = moment.utc().add(5, 'minute').unix();
methodToCreateBallot(curDateInSeconds)
.on("receipt", () => {
commonStore.hideLoading();

View File

@ -21,7 +21,11 @@ Check POA Network <a href='https://github.com/poanetwork/wiki' target='blank'>wi
messages.ballotIsNotActiveMsg = function(timeToStart) {
return `The ballot is not active yet. Time to start: ${timeToStart}`;
};
messages.SHOULD_BE_MORE_THAN_TWO_DAYS = "Ballot end time should be at least 48 hours from now";
messages.SHOULD_BE_MORE_THAN_TWO_DAYS = (duration, neededHours, neededMinutes) => {
return `Ballot end time should be at least 48 hours from now in UTC time. Current duration is ${duration} hours.
Please add ${neededHours} hours and ${neededMinutes} minutes in order to set correct end time
`;
}
messages.DESCRIPTION_IS_EMPTY = "Description cannot be empty";
module.exports = {
messages

View File

@ -35,8 +35,9 @@ class BallotStore {
constructor() {
const twoDays = moment().add(2, 'days').add(10, 'minutes').format("YYYY-MM-DDTHH:mm");
this.ballotType = null;
this.endTime = "";
this.endTime = twoDays;
this.ballotKeys = {
keyType: null,