diff --git a/frontend/src/ChangeDataDialogue.svelte b/frontend/src/ChangeDataDialogue.svelte index 923e3ff..43704d3 100644 --- a/frontend/src/ChangeDataDialogue.svelte +++ b/frontend/src/ChangeDataDialogue.svelte @@ -2,6 +2,7 @@ import {anime} from "./GetAniListSingleItemAndOpenModal.svelte"; import {Button} from "flowbite-svelte"; import StarRatting from "@ernane/svelte-star-rating" + import moment from 'moment' const ratingInWords = { 0: "Not Reviewed", @@ -61,6 +62,8 @@ score: anime.data.MediaList.score, notes: anime.data.MediaList.notes } + let startedAtDate: string + let completedAtDate: string const changeRating = (e) => { config.score = e.target.valueAsNumber @@ -79,7 +82,11 @@ count++ } - let startedAtDate = `${values.startedAt.year}-${values.startedAt.month}-${values.startedAt.day}` + if (values.startedAt.year > 0) { + let startedAtISODate = new Date(values.startedAt.year, values.startedAt.month - 1, values.startedAt.day) + let startedAtMoment = moment(startedAtISODate) + startedAtDate = startedAtMoment.format('YYYY-MM-DD') + } const transformStartedAtDate = (e) => { const re = /^([0-9]{4})-([0-9]{2})-([0-9]{2})/ @@ -89,31 +96,42 @@ values.startedAt.day = Number(date[3]) } - console.log(startedAtDate) + if (values.completedAt.year > 0) { + let completedAtISODate = new Date(values.completedAt.year, values.completedAt.month - 1, values.completedAt.day) + let completedAtMoment = moment(completedAtISODate) + completedAtDate = completedAtMoment.format('YYYY-MM-DD') + } + + const transformCompletedAtDate = (e) => { + const re = /^([0-9]{4})-([0-9]{2})-([0-9]{2})/ + const date = re.exec(e.target.value) + values.completedAt.year = Number(date[1]) + values.completedAt.month = Number(date[2]) + values.completedAt.day = Number(date[3]) + }
Rating: {config.score * 2}
{ratingInWords[config.score * 2]}