diff --git a/src/js/components/root.js b/src/js/components/root.js index a864427..07a5e95 100644 --- a/src/js/components/root.js +++ b/src/js/components/root.js @@ -3,6 +3,34 @@ import { BrowserRouter, Route } from "react-router-dom"; import _ from 'lodash'; import { HeaderBar } from "./lib/header-bar.js" +class TimeScheduleWidget extends Component { + constructor(props) { + super(props) + this.state = { curTime: new Date() }; + } + + componentDidMount() { + this.timerId = setInterval(() => this.tick(), 1000); + } + componentWillUnmount() { + clearInterval(this.timerId); + } + + tick() { + this.setState({curTime: new Date()}); + } + + render() { + const curTime = this.state.curTime; + const timeStr = curTime.toLocaleTimeString(); + const serviceStr = curTime.getDay() === 0 ? "Sunday service" : "Weekday / Saturday service"; + return (
Current time: {timeStr}
+{serviceStr}
+Current time is (current time)
-Today's bart map:
+