Skip to content

fix: Fixing cast date type. #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/DatetimePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</template>

<script>
import { format, parse } from 'date-fns'
import { format } from 'date-fns'

const DEFAULT_DATE = ''
const DEFAULT_TIME = '00:00:00'
Expand Down Expand Up @@ -145,7 +145,7 @@ export default {
if (this.time.length === 5) {
datetimeString += ':00'
}
return parse(datetimeString, this.defaultDateTimeFormat, new Date())
return new Date(datetimeString)
} else {
return null
}
Expand All @@ -165,7 +165,7 @@ export default {
initDateTime = this.datetime
} else if (typeof this.datetime === 'string' || this.datetime instanceof String) {
// see https://stackoverflow.com/a/9436948
initDateTime = parse(this.datetime, this.dateTimeFormat, new Date())
initDateTime = new Date(this.datetime)
}

this.date = format(initDateTime, DEFAULT_DATE_FORMAT)
Expand Down