Vuetify: [Bug Report] Can't change time format for event in v-calendar

Created on 4 Sep 2019  路  7Comments  路  Source: vuetifyjs/vuetify

Environment

Vuetify Version: 2.0.14
Vue Version: 2.6.10
Browsers: Chrome 76.0.3809.132
OS: Linux x86_64

Steps to reproduce

calendar-with-events.ts
...
formatTime (withTime: VTimestamp, ampm: boolean): string {
const suffix = ampm ? (withTime.hour < 12 ? 'a' : 'p') : ''
const hour = withTime.hour % 12 || 12
const minute = withTime.minute

  return minute > 0
    ? (minute < 10
      ? `${hour}:0${minute}${suffix}`
      : `${hour}:${minute}${suffix}`)
    : `${hour}${suffix}`
},

....

but

eventNameFunction (): VNameFunction {
  return typeof this.eventName === 'function'
    ? this.eventName as VNameFunction
    : (event, timedEvent) => {
      const name = event.input[this.eventName as string] as string
      if (event.start.hasTime) {
        if (timedEvent) {
          const showStart = event.start.hour < 12 && event.end.hour >= 12


          const start = this.formatTime(event.start, showStart)  
                                     what is "showStart"?

          const end = this.formatTime(event.end, true)
                               why is always "true' here?


          return `<strong>${name}</strong><br>${start} - ${end}`
        } else {


          const time = this.formatTime(event.start, true)
                                   why is always "true' here?


          return `<strong>${time}</strong> ${name}`
        }
      }
      return name
    }
},

Expected Behavior

I expect 24 hours time format

Actual Behavior

Only 12 hours time format

Reproduction Link

https://codepen.io/yasn0st/pen/BaBJJOE

VCalendar bug

Most helpful comment

https://codepen.io/yasn0st/pen/BaBJJOE
there is a reprocution. At "ru" locale timeformat should be "24h".
but "ampm" format hardcoded in calendar-with-events.ts file

All 7 comments

You've submitted an issue that does not contain a reproduction. In order to effectively disposition this, we need to verify that the problem exists outside of your environment. This issue will be tagged as needs reproduction for the next 14 days before being closed.

You can find information on how to contribute to vuetify here.

Services to create a reproduction:

Thank you for your contribution and interest in improving Vuetify.

Reproduction:
Event name always has "ampm" time format?
You can do anything, but can't change it. It hardcoded.

@yasn0st we need runnable codepen reproduction please.

https://codepen.io/yasn0st/pen/BaBJJOE
there is a reprocution. At "ru" locale timeformat should be "24h".
but "ampm" format hardcoded in calendar-with-events.ts file

This can be a feature since the fix is to add a new property to VCalendar. @ClickerMonkey your thoughts?

Well, it should probably generate this time using the browser functionality which takes into account the person's locale. If they want further customization, they can specify a function for event-name.

Well, it should probably generate this time using the browser functionality which takes into account the person's locale. If they want further customization, they can specify a function for event-name.

It should use the locale set on the v-calendar component , the browser language set is not an option because the page language is not necessarily the browser language, language can come from user login session, user choice, etc

Was this page helpful?
0 / 5 - 0 ratings