taiga-family / taiga-ui

Angular UI Kit and components library for awesome people

Home Page:https://taiga-ui.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🐞 - TuiDay не корректно парсит дату

evoytenkoapps opened this issue · comments

Playground Link

No response

Description

при дате '2024-1-20'; месяц уходит в дату
при '2024-01-20'; все норм
мне кажется что если есть тире, то это однозначный разделитель дат.

 it('Должен конвертировать в дату тайги, через тире', () => {
   const data = '2024-1-20';
   const convertedData = {day: 20, month: 0, year: 2024} as TuiDay;

   expect(service.formatTuiDay(data, 'YMD')).toEqual(convertedData);
 });
// сам метод
  formatTuiDay(date: string, dateMode?: TuiDateMode): TuiDay {
  return TuiDay.normalizeParse(date, dateMode);
}
Снимок экрана 2024-06-27 в 12 31 48

Angular version

No response

Taiga UI version

No response

Which browsers have you used?

  • Chrome
  • Firefox
  • Safari
  • Edge

Which operating systems have you used?

  • macOS
  • Windows
  • Linux
  • iOS
  • Android

When you are using YMD format, it expects 2 digit day and month: yyyy-mm-dd.
Your 2024-1-20 date doesn't match the format. It should be 2024-01-20 instead.

Parsing logic:

day: parseInt(date.slice(8, 10), 10),

hakimio is right, you should also see [parseRawDateString]: wrong date string length assertion error in console. You are welcome to create a PR if you want to support this format, but currently it is working as planned. As a workaround TuiDay.fromLocalNativeDate(new Date('2024-1-20')) seems to work.