Skip to content
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

TimePicker timeFormatter doesn't seem to be used #1433

Closed
zedrdave opened this issue May 26, 2019 · 6 comments
Closed

TimePicker timeFormatter doesn't seem to be used #1433

zedrdave opened this issue May 26, 2019 · 6 comments
Assignees

Comments

@zedrdave
Copy link
Contributor

Buefy version: 0.7.6
Vuejs version: 2.6.10

Description

Steps to reproduce

<b-timepicker 
v-model="myTime"
:time-formatter="myTimeFormatter"
/>
[...]
methods: {
myTimeFormatter(date) {
      console.info("debug!")
      return dayjs.utc(date).format("HH:mm");
    },
}

Expected behavior

myTimeFormatter gets called and debug message displayed.

Actual behavior

Formatter function is never called.
Looking at the code for TimePickerMixin, the prop is read, but never used (only the formatter from config).

@jtommy jtommy closed this as completed in 0e38558 May 26, 2019
@guestisp
Copy link

still doesn't work with the latest version

@wesdevpro
Copy link
Member

still doesn't work with the latest version

Please send more information showing what issues you are currently having. Thanks

@wesdevpro wesdevpro reopened this Aug 11, 2023
@wesdevpro wesdevpro self-assigned this Aug 11, 2023
@guestisp
Copy link

Please send more information showing what issues you are currently having. Thanks

Exactly the same as first message. The :time-formatter or :time-parser are not called.. I've put a console.log in the custom function and it's never called

@kikuomax kikuomax self-assigned this Dec 27, 2023
@kikuomax
Copy link
Collaborator

@guestisp @wesdevpro I tested the behavior of BTimepicker with the following code:

<template>
    <div class="container is-max-desktop">
        <b-timepicker
            v-model="dt"
            :time-parser="timeParser"
            :time-formatter="timeFormatter"
            editable
        />
    </div>
</template>

<script>
export default {
    data() {
        return {
            dt: new Date()
        }
    },
    methods: {
        timeParser(timeStr) {
            console.log('timeParser called', timeStr)
            const [h, m] = timeStr.split(':')
            const dt = new Date()
            dt.setHours(parseInt(h))
            dt.setMinutes(parseInt(m))
            return dt
        },
        timeFormatter(dt) {
            console.log('timeFormatter called', dt)
            const h = dt.getHours().toString().padStart(2, '0')
            const m = dt.getMinutes().toString().padStart(2, '0')
            return `${h}:${m}`
        }
    }
}
</script>

As far as I tested, both timeFormatter and timeParser were called:
image

@wesdevpro
Copy link
Member

Exactly the same as first message. The :time-formatter or :time-parser are not called.. I've put a console.log in the custom function and it's never called

Interesting.

@wesdevpro
Copy link
Member

Closing this because we cannot reproduce this issue. @guestisp If you could reopen when you can provide more information to reproduce this problem. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Completed ✅
Development

No branches or pull requests

4 participants