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

The parse of a time with the locale 'ko' doesn't take into consideration the AM/PM part. #2721

Open
collets opened this issue Sep 6, 2024 · 0 comments

Comments

@collets
Copy link

collets commented Sep 6, 2024

I'm trying to parse a time in korean using the format a hh:mm:ss but seems like dayjs translate it always as AM.

import './style.css';
import dayjs from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import 'dayjs/locale/ko';

dayjs.extend(customParseFormat);
dayjs.locale('ko');

const dateAM = dayjs('오전 04:00:00', 'a hh:mm:ss');
console.log('Parsed hour 24h format AM', dateAM.hour()); // => Parsed hour 24h format AM: 4
console.log('Reformatted parsed data AM', dateAM.format('a hh:mm:ss')); // => Reformatted parsed data AM: 오전 04:00:00

const datePM = dayjs('오후 04:00:00', 'a hh:mm:ss');
console.log('Parsed hour 24h format PM', datePM.hour()); // => Parsed hour 24h format PM: 4
console.log('Reformatted parsed data PM', datePM.format('a hh:mm:ss')); // => Reformatted parsed data PM: 오전 04:00:00

Link to a stackblitz with an example: https://stackblitz.com/edit/dayjs-playground-euzysg?file=index.js

Expected behavior
When passing the PM time to dayjs, it should parse correctly, so for example:

const datePM = dayjs('오후 04:00:00', 'a hh:mm:ss');
console.log('Parsed hour 24h format PM', datePM.hour()); // => Parsed hour 24h format PM: 16
console.log('Reformatted parsed data PM', datePM.format('a hh:mm:ss')); // => Reformatted parsed data PM: 오후 04:00:00

Information

  • Day.js Version v1.11.13
  • OS: macOS 14.6.1
  • Browser [chrome 128
  • Time zone: UTC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant