VDS13 / telegram-inline-calendar

Date and time picker and Inline calendar for Node.js telegram bots
MIT License
88 stars 16 forks source link

Get the wrong time when calling clickButtonCalendar #8

Closed alexchekmenev closed 1 year ago

alexchekmenev commented 1 year ago

When I call result = session.calendar.clickButtonCalendar(callbackQuery) to get the time from callbackQuery I receive the wrong time when selecting it from the range 00:00-00:59. For example, I choose 00:15 and result = 'YYYY-MM-DD 12:15' but definitely must be 'YYYY-MM-DD 00:15'. Am I doing something wrong?

VDS13 commented 1 year ago

Hello, @alexchekmenev. Can you show what parameters you pass when creating an instance of the class?

alexchekmenev commented 1 year ago
  const { session } = ctx.scene
  const minDate =
    session.drawSettingsStep === 'startMethod'
      ? dayjs.tz(Date.now(), session.timezone.name)
      : dayjs(session.drawStartsAt).tz(session.timezone.name)
  console.log('minDate', minDate.format('YYYY-MM-DD'))
  session.calendar = new Calendar(ctx, {
    bot_api: 'telegraf',
    language: session.locale,
    date_format: 'YYYY-MM-DD hh:mm',
    start_date: minDate.format('YYYY-MM-DD'),
    stop_date: dayjs(minDate).add(30, 'days').format('YYYY-MM-DD'),
    start_week_day: 1,
    time_selector_mod: true,
    time_range: '00:00-23:59',
    time_step: '15m',
  })
  session.calendar.startNavCalendar(ctx)
VDS13 commented 1 year ago

@alexchekmenev, image https://day.js.org/docs/en/display/format

alexchekmenev commented 1 year ago

Oh, my bad, thank you a lot!