как сравнить час в реакции родного? - PullRequest
0 голосов
/ 04 октября 2019

Я пытаюсь сравнить час в реакции родного, вставляя некоторые параметры;как: текущее время, время начала и время окончания, чтобы открыть экран режима, ниже приведен следующий код:

import React, { Component } from 'react';
import moment from "moment";
import SplashScreen from './Components/SplashScreen.js';
import Intro from './Components/Menu.js';
import Intro2 from './Components/Menu2.js';

export default class Index extends Component {
state = {
ready: false,
};
componentDidMount() {
var that = this;
setTimeout(() => {
  this.setState({ ready: true });
}, 3500);
var currentD = new Date();
var startIntroHourD = new Date();
startIntroHourD.setHours(13,30,0); // 5.30 pm
var endIntroHourD = new Date();
endIntroHourD.setHours(5,30,0); // 5.30 am

}

render() {
 if (this.state.currentD >= this.state.startIntroHourD && this.state.currentD <this.state.endIntroHourD ){
    if (this.state.ready === false) {
        return <SplashScreen />;
      }
    return <Intro/>;
}else{
    if (this.state.ready === false) {
      return <SplashScreen />;
    }
  return <Intro2/>;
  }
 }
}

Но эти параметры не работают, кто-то может помочь мне установить правильное время следующего формата

...