ui-kit icon indicating copy to clipboard operation
ui-kit copied to clipboard

TimeInput - format on blur with Chinese and Japenese Locale loses value

Open montezume opened this issue 6 years ago • 2 comments

Summary

When you have your locale set to Chinese, and you try to enter a time, it formats on blur, and then when you try to change it, it loses the value.

I assume the problem is it's prefixing the value with the Chinese characters for AM / PM.

Here's some gifs

broken formatonblur

montezume avatar Jul 25 '19 23:07 montezume

I did some research, it looks like the problem is in this crazy regex expression in parse-time.

  const match = time.match(
    /^(\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:\.(\d{1,3}))?)?)?\s*(am|pm)?$/
  );
  if (!match) return null;

Two approaches are possible.

  1. We have to allow "times" to start with chinese AM or PM
  2. Or we change our formatting so it stops auto formatting Chinese times with the AM/PM.

It might make sense to do some research and find out how Chinese users want to enter times.

montezume avatar Jul 25 '19 23:07 montezume

we face the same issue with the Japanese locale.

aminbenselim avatar Nov 25 '19 10:11 aminbenselim