Use native date constructor to calculate timeout until midnight

This commit is contained in:
Pavel Djundik 2018-09-20 10:50:00 +03:00
parent 5ba0e33fb9
commit def494533b
2 changed files with 5 additions and 4 deletions

View File

@ -92,8 +92,6 @@
</template>
<script>
const moment = require("moment");
import {throttle} from "lodash";
import NetworkList from "./NetworkList.vue";
@ -134,7 +132,10 @@ export default {
isPublic: () => document.body.classList.contains("public"),
msUntilNextDay() {
// Compute how many milliseconds are remaining until the next day starts
return moment().add(1, "day").startOf("day") - moment();
const today = new Date();
const tommorow = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1);
return tommorow - today;
},
},
};

View File

@ -33,7 +33,7 @@ export default {
},
methods: {
hoursPassed() {
return moment.duration(moment().diff(moment(this.message.time))).asHours();
return (Date.now() - Date.parse(this.message.time)) / 3600000;
},
dayChange() {
this.$forceUpdate();