erickguan / ffi-icu

FFI wrappers for ICU. MRI extension with the dynamic C library.
https://github.com/erickguan/ffi-icu
MIT License
35 stars 22 forks source link

🐛 hourCycle : fi (Finish) replaces k with h #63

Closed lwelti closed 1 year ago

lwelti commented 1 year ago

and I was able to replicate it locally, very simple code:

puts ICU::TimeFormatting.format(Time.mktime(2015, 3, 12, 15, 21, 16), {:locale => 'fi', :zone => 'America/Los_Angeles', :date => :long, :time => :short, :hour_cycle => 'h12'})
puts ICU::TimeFormatting.format(Time.mktime(2015, 3, 12, 15, 21, 16), {:locale => 'fi', :zone => 'America/Los_Angeles', :date => :long, :time => :short, :hour_cycle => 'h24'})

returns:

12. maaliskuuta 2015 hlo 3.21 ip.   <--- replaces k with h so it becomes hlo
12. maaliskuuta 2015 klo 15.21

if you compare with Intl.js code:

const date = new Date(Date.UTC(2020, 2, 13, 3, 23, 16, 738));
console.log(new Intl.DateTimeFormat('fi-u-hc-h12', { dateStyle: 'long', timeStyle: 'short', timeZone: 'America/Los_Angeles' }).format(date));
console.log(new Intl.DateTimeFormat('fi-u-hc-h24', { dateStyle: 'long', timeStyle: 'short', timeZone: 'America/Los_Angeles' }).format(date));

returns:

> "12. maaliskuuta 2020 klo 8.23 ip."   <--- keeps klo
> "12. maaliskuuta 2020 klo 20.23"

We believe the issue is on the at replacement, which in this case should respect text inside quotes