Commit Graph

257 Commits

Author SHA1 Message Date
KJ Tsanaktsidis da26ebcfbc Add formatting for durations e.g. "2h 4min. 2sec."
Uses unumf_* to format the individual components of the duration, and
ulistfmt_* to join them. That's roughly analogous with what the C++
MeasureFormatter class does internally.

I asked about some feedback for this approach on the ICU mailing list
too: https://sourceforge.net/p/icu/mailman/message/37645785/
2022-12-20 11:13:42 +01:00
KJ Tsanaktsidis 44b11a658f Add a helper for attaching functions if present 2022-12-20 11:13:42 +01:00
Erick Guan d47b79fa11
Merge pull request #61 from erickguan/update-travis
Update travis with ICU 71.1
2022-12-20 10:32:29 +01:00
Erick Guan 1f54f1550f build icu 2022-12-19 23:50:42 +01:00
Erick Guan 79a471f4b0 get more information about icu 2022-12-19 21:30:19 +01:00
Erick Guan 40dc82b538
Merge pull request #59 from sandbergja/add-transliteration-example-to-readme
Add transliteration example to README
2022-12-12 21:55:31 +01:00
Erick Guan 744f49f230
Merge pull request #58 from day7/collator_improvements
Fix pull 32 Collator Improvements
2022-12-12 21:54:48 +01:00
Erick Guan a4d889dac0
Merge pull request #60 from erickguan/revert-32-collator_improvements
Revert "Two collator improvements"
2022-12-12 21:54:30 +01:00
Erick Guan b5e740471e
Revert "Two collator improvements" 2022-12-12 21:51:59 +01:00
Erick Guan 67ed2859d0
Merge pull request #32 from ccutrer/collator_improvements
Two collator improvements
2022-12-12 21:50:59 +01:00
Jane Sandberg 0d8505405f Add transliteration example to README 2022-09-12 14:21:46 -07:00
Craig Alan Pettersen 6834c33462 change 'be_true' and 'be_false' to 'be true' and 'be false' in spec/collation_spec.rb so tests will pass 2022-05-31 15:29:52 -05:00
Craig Alan Pettersen 57a5b61d05 Merge commit 'refs/pull/32/head' of https://github.com/erickguan/ffi-icu into collator_improvements 2022-05-31 15:05:09 -05:00
Damian Nelson b57e49bad5 v0.4.3 2022-04-15 11:30:42 -07:00
Damian Nelson 7280d2dd40
Merge pull request #55 from KJTsanaktsidis/ktsanaktsidis/dont_include_ampm_by_itself
Don't add am/pm marker if there is no time in the format string
2022-04-15 10:31:16 -07:00
KJ Tsanaktsidis bf6cfa6bb1
Don't add am/pm marker if there is no time in the format string
Currently, doing something like `format(time, time: :none, hour_cycle:
'h12')` will give a string like "10/04/2021 PM" - the am/pm marker is
added to the skeleton even though the skeleton has no other time
markers.
2022-04-15 14:08:48 +10:00
Damian Nelson 2554722181 v0.4.2 2022-04-06 16:54:51 -07:00
Damian Nelson 0da02b1725
Merge pull request #53 from KJTsanaktsidis/ktsanaktsidis/handle_hour_cycle
Add support for h11/h12/h23/h24 hour cycle
2022-04-06 16:49:26 -07:00
KJ Tsanaktsidis 514f145c1a
Add support for h11/h12/h23/h24 hour cycle
The hour cycle can be directly specified to the call to #format, or
inferred from an "@hours=" keyword on the locale.

The algorithm for fixing up the skeletons & patterns is the same as that
used in Firefox:
https://github.com/tc39/ecma402/issues/665#issuecomment-1084833809
2022-04-06 16:36:43 +10:00
Damian Nelson 59a20a72d8
Merge pull request #54 from KJTsanaktsidis/ktsanaktsidis/allow_overriding_icu_on_macos
Allow overriding libicu on MacOS with FFI_ICU_LIB
2022-04-01 17:29:02 -07:00
Damian Nelson e1797c0f66
Merge pull request #52 from KJTsanaktsidis/ktsanaktsidis/fix_udatpg_destructor
Use the correct function to delete udatpg objects
2022-04-01 08:55:44 -07:00
KJ Tsanaktsidis e8b6b6bfdf
Allow overriding libicu on MacOS with FFI_ICU_LIB 2022-04-01 16:03:08 +11:00
KJ Tsanaktsidis 5f63e6ff1d
Use the correct function to delete udatpg objects
The skeleton generator is currently using udat_close to delete objects
created with udatpg_open; it should be using udatpg_close instead.

The C-side implementation of udat_close calls straight into the C++
delete operator:

    U_CAPI void U_EXPORT2
    udat_close(UDateFormat* format)
    {
        delete (DateFormat*)format;
    }

The destructor on the DateFormat class is virtual, so i'm frankly
astonished this isn't just chasing and calling a pointer to nowhere. I
guess we got "lucky" and DateFormat and DateTimePatternGenerator have
a similar enough layout by chance that this works. However it's entirely
at the whim of the compiler as to whether this keeps working or not, so
we should fix it and call the correct cleanup function.
2022-04-01 13:28:59 +11:00
Damian Nelson a3d2a14dcf v0.4.1 2022-03-24 14:10:14 -07:00
Damian Nelson 787488275a
Merge pull request #49 from KJTsanaktsidis/ktsanaktsidis/fix_memory_saftey_patter
Fix memory saftey issues in passing UcharPointer's to ICU in skeleton_format
2022-03-24 11:47:57 -07:00
KJ Tsanaktsidis 8a3058f591
Fix memory saftey issues in passing UcharPointer's to ICU
ICU expects the length of these pointers to be expressed in
_characters_, not _bytes_. This leads to ICU attempting to read past the
end of e.g. a provided pattern.

Because FFI allocates an extra 7 bytes for every malloc call (to
guarantee that it can qword-align everything), this more often than not
leads to ICU reading _unitialized_ memory, rather than _unmapped_
memory, and thus date patterns etc wind up containing garbage.
2022-03-16 16:20:41 +11:00
Konstantinos Tsanaktsidis d2241ad65f
Fix number formatter following removal of Fixnum / Bignum from ruby-next (#50)
The current ruby head in CI removes Fixnum and Bignum classes, which has led to broken builds.

This fix attempts to coalesce the passed-in number to an `int64_t`; if that fails, it falls back to calling `unum_format_decimal` - if the versions of ICU does not support `unum_format_decimal`, a `RangeError` will be raised (which should not be an issue for modern versions of ICU)
2022-03-15 18:15:44 -07:00
Erick Guan 0c6f8b201f
Merge pull request #47 from ccutrer/patch-1
automatically include any Debian multi-arch
2021-08-16 23:16:58 +02:00
Damian Nelson 5b39a7f4e8 v0.4.0 2021-08-16 11:51:24 -07:00
Damian Nelson fd3bced02e
Merge pull request #46 from erickguan/dnelson/add_skeleton_formatting
Add support for skeleton date patterns
2021-08-16 11:20:27 -07:00
Damian Nelson c2e3dea0bc Merge branch 'dnelson/add_skeleton_formatting' of github.com:erickguan/ffi-icu into dnelson/add_skeleton_formatting 2021-08-16 09:47:03 -07:00
Damian Nelson a5e1c84c8f Merge branch 'master' into dnelson/add_skeleton_formatting 2021-08-16 09:46:39 -07:00
Cody Cutrer d9d6e89c72 automatically include any Debian multi-arch
I could make it "correct" with

```
`dpkg-architecture -qDEB_TARGET_MULTIARCH`.strip
```

but that seems weird to shell out
2021-08-16 10:41:12 -06:00
Erick Guan aab5acaea4
Merge pull request #48 from erickguan/update-travis
Update travis config
2021-08-16 18:36:59 +02:00
Erick Guan a573eaa027 allow arm builds to fail until path is fixed 2021-08-15 22:47:15 +02:00
Erick Guan d390f8ef32 fix a broken test in transliteration 2021-08-15 22:43:14 +02:00
Erick Guan dd79fb97e1 migrate to travis.com and update travis settings 2021-08-15 22:28:58 +02:00
Damian Nelson 2652ed491b
Update lib/ffi-icu/time_formatting.rb
Co-authored-by: Igor Justino <697824+dadah89@users.noreply.github.com>
2021-08-12 21:02:09 -07:00
Damian Nelson 31c1403f8d
Update README.md
Co-authored-by: Igor Justino <697824+dadah89@users.noreply.github.com>
2021-08-12 21:01:59 -07:00
Damian Nelson c141668c14 Update README.md 2021-08-11 12:17:36 -07:00
Damian Nelson 6b74fac1bd Extract skeleton code and cleanup 2021-08-11 11:56:53 -07:00
Damian Nelson f71e1fabeb Add support for skeleton date formats 2021-03-25 00:02:32 -07:00
Damian Nelson 7fc5d65f6d v0.3.0 2021-01-14 13:56:36 -08:00
Damian Nelson 95ddb2fe54
Merge pull request #45 from maths22/osx-big-sur
Support macos big sur
2021-01-14 12:49:31 -08:00
Jacob Burroughs 8be8aebbba Support macos big sur
Also makes tests pass against newer icu and ruby

fixes #44
2020-12-02 11:29:43 -06:00
Alex Schmitt d6c036c621
Remove support for EOL Ruby versions (#42)
Support for 1.9 ended on Feb 23, 2015 - https://www.ruby-lang.org/en/news/2014/01/10/ruby-1-9-3-will-end-on-2015/
Support for 2.4 ended on April 5, 2020 - https://www.ruby-lang.org/en/news/2020/04/05/support-of-ruby-2-4-has-ended/
2020-10-09 08:16:20 -07:00
Alex Schmitt 0caa2fe04a
Add CI badge to README (#43)
Closes https://github.com/erickguan/ffi-icu/issues/36
2020-10-07 16:33:03 -07:00
Alex Schmitt b6b2122527
Update CI to include Ruby 2.7 (#41)
This also simplifies the prior Ruby versions to let Travis pull the latest release (more [here](https://docs.travis-ci.com/user/languages/ruby/#specifying-ruby-versions-and-implementations)), and updates docs to match.

Since 2.7 has some failures, we're allowing for failures on that build for now so we can coordinate the appropriate fixes in a followup.
2020-10-07 13:37:13 -07:00
Alex Schmitt 8aea54b8a7
Update RSpec to 3.9 and address deprecation warnings (#40)
See https://relishapp.com/rspec/rspec-core/v/3-9/docs for more on docs

This addresses deprecation warnings re: `should` and friends as well.
2020-10-07 11:27:02 -07:00
Erick Guan 487bcb4cf4
Update rake 2020-03-26 15:42:40 +08:00