Feat/personal highscore #44

Merged
KevinMidboe merged 19 commits from feat/personal-highscore into master 2020-10-11 16:19:52 +00:00
2 changed files with 17 additions and 10 deletions
Showing only changes of commit 59792f9aae - Show all commits

View File

@@ -58,6 +58,7 @@
<script>
import { highscoreStatistics } from "@/api";
import { humanReadableDate, daysAgo } from "@/utils";
import Wine from "@/ui/Wine";
export default {
@@ -92,19 +93,13 @@ export default {
}
},
methods: {
humanReadableDate: humanReadableDate,
daysAgo: daysAgo,
resetFilter() {
this.highscore = this.highscoreResponse;
this.highscoreFilter = '';
document.getElementsByTagName('input')[0].focus();
},
humanReadableDate(date) {
const options = { year: 'numeric', month: 'long', day: 'numeric' };
return new Date(date).toLocaleDateString(undefined, options);
},
daysAgo(date) {
const day = 24 * 60 * 60 * 1000;
return Math.round(Math.abs((new Date() - new Date(date)) / day));
},
selectWinner(winner) {
if (this.selectedWinner != null && this.selectedWinner["name"] == winner["name"]) {
this.selectedWinner = null;

View File

@@ -7,6 +7,18 @@ const dateString = (date) => {
return `${ye}-${mo}-${da}`
}
module.exports = {
dateString
function humanReadableDate(date) {
const options = { year: 'numeric', month: 'long', day: 'numeric' };
return new Date(date).toLocaleDateString(undefined, options);
}
function daysAgo(date) {
const day = 24 * 60 * 60 * 1000;
return Math.round(Math.abs((new Date() - new Date(date)) / day));
}
module.exports = {
dateString,
humanReadableDate,
daysAgo
}