From 327998254e1e8a6ff9ed27eb71028256bc8c5725 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Mon, 6 Aug 2007 23:22:53 +0000 Subject: [PATCH] ICU-3487 Duration implementation checkin X-SVN-Rev: 22293 --- .gitattributes | 83 +++ icu4j/build.xml | 14 +- icu4j/src/com/ibm/icu/dev/test/TestAll.java | 1 + icu4j/src/com/ibm/icu/dev/test/TestFmwk.java | 49 +- .../dev/test/duration/DataReadWriteTest.java | 356 +++++++++ .../dev/test/duration/ICUDurationTest.java | 78 ++ .../dev/test/duration/LanguageTestRoot.java | 683 ++++++++++++++++++ .../duration/PeriodBuilderFactoryTest.java | 91 +++ .../dev/test/duration/PeriodBuilderTest.java | 22 + .../ibm/icu/dev/test/duration/PeriodTest.java | 112 +++ ...ceBasedPeriodFormatterDataServiceTest.java | 39 + .../ibm/icu/dev/test/duration/TestAll.java | 38 + .../dev/test/duration/languages/TestAll.java | 44 ++ .../test/duration/languages/Test_ar_EG.java | 33 + .../dev/test/duration/languages/Test_en.java | 29 + .../dev/test/duration/languages/Test_es.java | 32 + .../dev/test/duration/languages/Test_fr.java | 32 + .../test/duration/languages/Test_he_IL.java | 32 + .../dev/test/duration/languages/Test_hi.java | 68 ++ .../dev/test/duration/languages/Test_it.java | 32 + .../dev/test/duration/languages/Test_ja.java | 69 ++ .../dev/test/duration/languages/Test_ko.java | 32 + .../dev/test/duration/languages/Test_ru.java | 33 + .../test/duration/languages/Test_zh_Hans.java | 33 + .../duration/languages/Test_zh_Hans_SG.java | 32 + .../test/duration/languages/Test_zh_Hant.java | 33 + .../duration/languages/Test_zh_Hant_HK.java | 33 + .../test/duration/testdata/testdata_ar_EG.txt | 401 ++++++++++ .../test/duration/testdata/testdata_en.txt | 401 ++++++++++ .../test/duration/testdata/testdata_es.txt | 401 ++++++++++ .../test/duration/testdata/testdata_fr.txt | 401 ++++++++++ .../test/duration/testdata/testdata_he_IL.txt | 401 ++++++++++ .../test/duration/testdata/testdata_hi.txt | 401 ++++++++++ .../test/duration/testdata/testdata_it.txt | 401 ++++++++++ .../test/duration/testdata/testdata_ja.txt | 401 ++++++++++ .../test/duration/testdata/testdata_ko.txt | 401 ++++++++++ .../test/duration/testdata/testdata_ru.txt | 401 ++++++++++ .../test/duration/testdata/testdata_th.txt | 401 ++++++++++ .../duration/testdata/testdata_zh_Hans.txt | 401 ++++++++++ .../duration/testdata/testdata_zh_Hans_SG.txt | 401 ++++++++++ .../duration/testdata/testdata_zh_Hant.txt | 401 ++++++++++ .../duration/testdata/testdata_zh_Hant_HK.txt | 401 ++++++++++ .../impl/duration/BasicDurationFormat.java | 60 ++ .../impl/duration/BasicDurationFormatter.java | 118 +++ .../BasicDurationFormatterFactory.java | 236 ++++++ .../duration/BasicPeriodBuilderFactory.java | 489 +++++++++++++ .../impl/duration/BasicPeriodFormatter.java | 199 +++++ .../duration/BasicPeriodFormatterFactory.java | 234 ++++++ .../duration/BasicPeriodFormatterService.java | 63 ++ .../ibm/icu/impl/duration/DateFormatter.java | 52 ++ .../icu/impl/duration/DurationFormatter.java | 76 ++ .../duration/DurationFormatterFactory.java | 79 ++ .../src/com/ibm/icu/impl/duration/Period.java | 373 ++++++++++ .../ibm/icu/impl/duration/PeriodBuilder.java | 54 ++ .../impl/duration/PeriodBuilderFactory.java | 112 +++ .../icu/impl/duration/PeriodFormatter.java | 43 ++ .../impl/duration/PeriodFormatterFactory.java | 74 ++ .../impl/duration/PeriodFormatterService.java | 45 ++ .../com/ibm/icu/impl/duration/TimeUnit.java | 85 +++ .../icu/impl/duration/TimeUnitConstants.java | 37 + .../icu/impl/duration/impl/DataRecord.java | 317 ++++++++ .../duration/impl/PeriodFormatterData.java | 678 +++++++++++++++++ .../impl/PeriodFormatterDataService.java | 32 + .../icu/impl/duration/impl/RecordReader.java | 23 + .../icu/impl/duration/impl/RecordWriter.java | 23 + ...sourceBasedPeriodFormatterDataService.java | 145 ++++ .../com/ibm/icu/impl/duration/impl/Utils.java | 225 ++++++ .../impl/duration/impl/XMLRecordReader.java | 303 ++++++++ .../impl/duration/impl/XMLRecordWriter.java | 257 +++++++ .../impl/duration/impl/YMDDateFormatter.java | 98 +++ .../ibm/icu/impl/duration/impl/data/index.txt | 19 + .../icu/impl/duration/impl/data/pfd_ar_EG.xml | 118 +++ .../duration/impl/data/pfd_ar_EG.xml.escaped | 118 +++ .../icu/impl/duration/impl/data/pfd_en.xml | 128 ++++ .../icu/impl/duration/impl/data/pfd_es.xml | 150 ++++ .../icu/impl/duration/impl/data/pfd_fr.xml | 105 +++ .../icu/impl/duration/impl/data/pfd_he_IL.xml | 129 ++++ .../icu/impl/duration/impl/data/pfd_hi.xml | 105 +++ .../icu/impl/duration/impl/data/pfd_it.xml | 175 +++++ .../icu/impl/duration/impl/data/pfd_ja.xml | 128 ++++ .../icu/impl/duration/impl/data/pfd_ko.xml | 93 +++ .../icu/impl/duration/impl/data/pfd_ru.xml | 143 ++++ .../icu/impl/duration/impl/data/pfd_th.xml | 118 +++ .../impl/duration/impl/data/pfd_zh_Hans.xml | 132 ++++ .../duration/impl/data/pfd_zh_Hans_SG.xml | 130 ++++ .../impl/duration/impl/data/pfd_zh_Hant.xml | 130 ++++ .../duration/impl/data/pfd_zh_Hant_HK.xml | 116 +++ .../src/com/ibm/icu/text/DurationFormat.java | 12 +- 88 files changed, 14717 insertions(+), 10 deletions(-) create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/DataReadWriteTest.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/LanguageTestRoot.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/PeriodBuilderFactoryTest.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/PeriodBuilderTest.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/PeriodTest.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/ResourceBasedPeriodFormatterDataServiceTest.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/TestAll.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/TestAll.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ar_EG.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_en.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_es.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_fr.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_he_IL.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_hi.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_it.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ja.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ko.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ru.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hans.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hans_SG.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hant.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hant_HK.java create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ar_EG.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_en.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_es.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_fr.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_he_IL.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_hi.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_it.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ja.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ko.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ru.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_th.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hans.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hans_SG.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hant.txt create mode 100644 icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hant_HK.txt create mode 100644 icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormat.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormatter.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormatterFactory.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/BasicPeriodBuilderFactory.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatter.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatterFactory.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatterService.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/DateFormatter.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/DurationFormatter.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/DurationFormatterFactory.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/Period.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/PeriodBuilder.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/PeriodBuilderFactory.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/PeriodFormatter.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/PeriodFormatterFactory.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/PeriodFormatterService.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/TimeUnit.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/TimeUnitConstants.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/DataRecord.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/PeriodFormatterData.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/PeriodFormatterDataService.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/RecordReader.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/RecordWriter.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/ResourceBasedPeriodFormatterDataService.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/Utils.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/XMLRecordReader.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/XMLRecordWriter.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/YMDDateFormatter.java create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/index.txt create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ar_EG.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ar_EG.xml.escaped create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_en.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_es.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_fr.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_he_IL.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_hi.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_it.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ja.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ko.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ru.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_th.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hans.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hans_SG.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hant.xml create mode 100644 icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hant_HK.xml diff --git a/.gitattributes b/.gitattributes index 19383532e85..877c05f748e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -201,6 +201,44 @@ icu4j/src/com/ibm/icu/dev/data/rbbi/english.dict -text icu4j/src/com/ibm/icu/dev/data/testdata.jar -text icu4j/src/com/ibm/icu/dev/data/thai6.ucs -text icu4j/src/com/ibm/icu/dev/test/calendar/IndianTest.java -text +icu4j/src/com/ibm/icu/dev/test/duration/DataReadWriteTest.java -text +icu4j/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java -text +icu4j/src/com/ibm/icu/dev/test/duration/LanguageTestRoot.java -text +icu4j/src/com/ibm/icu/dev/test/duration/PeriodBuilderFactoryTest.java -text +icu4j/src/com/ibm/icu/dev/test/duration/PeriodBuilderTest.java -text +icu4j/src/com/ibm/icu/dev/test/duration/PeriodTest.java -text +icu4j/src/com/ibm/icu/dev/test/duration/ResourceBasedPeriodFormatterDataServiceTest.java -text +icu4j/src/com/ibm/icu/dev/test/duration/TestAll.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/TestAll.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ar_EG.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_en.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_es.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_fr.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_he_IL.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_hi.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_it.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ja.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ko.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ru.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hans.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hans_SG.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hant.java -text +icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hant_HK.java -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ar_EG.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_en.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_es.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_fr.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_he_IL.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_hi.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_it.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ja.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ko.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ru.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_th.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hans.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hans_SG.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hant.txt -text +icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hant_HK.txt -text icu4j/src/com/ibm/icu/dev/test/perf/data/collation/TestNames_Asian.txt -text icu4j/src/com/ibm/icu/dev/test/perf/data/collation/TestNames_Chinese.txt -text icu4j/src/com/ibm/icu/dev/test/perf/data/collation/TestNames_Japanese.txt -text @@ -288,6 +326,51 @@ icu4j/src/com/ibm/icu/impl/ICUCache.java -text icu4j/src/com/ibm/icu/impl/SimpleCache.java -text icu4j/src/com/ibm/icu/impl/data/icudata.jar -text icu4j/src/com/ibm/icu/impl/data/th.brk -text +icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormat.java -text +icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormatter.java -text +icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormatterFactory.java -text +icu4j/src/com/ibm/icu/impl/duration/BasicPeriodBuilderFactory.java -text +icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatter.java -text +icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatterFactory.java -text +icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatterService.java -text +icu4j/src/com/ibm/icu/impl/duration/DateFormatter.java -text +icu4j/src/com/ibm/icu/impl/duration/DurationFormatter.java -text +icu4j/src/com/ibm/icu/impl/duration/DurationFormatterFactory.java -text +icu4j/src/com/ibm/icu/impl/duration/Period.java -text +icu4j/src/com/ibm/icu/impl/duration/PeriodBuilder.java -text +icu4j/src/com/ibm/icu/impl/duration/PeriodBuilderFactory.java -text +icu4j/src/com/ibm/icu/impl/duration/PeriodFormatter.java -text +icu4j/src/com/ibm/icu/impl/duration/PeriodFormatterFactory.java -text +icu4j/src/com/ibm/icu/impl/duration/PeriodFormatterService.java -text +icu4j/src/com/ibm/icu/impl/duration/TimeUnit.java -text +icu4j/src/com/ibm/icu/impl/duration/TimeUnitConstants.java -text +icu4j/src/com/ibm/icu/impl/duration/impl/DataRecord.java -text +icu4j/src/com/ibm/icu/impl/duration/impl/PeriodFormatterData.java -text +icu4j/src/com/ibm/icu/impl/duration/impl/PeriodFormatterDataService.java -text +icu4j/src/com/ibm/icu/impl/duration/impl/RecordReader.java -text +icu4j/src/com/ibm/icu/impl/duration/impl/RecordWriter.java -text +icu4j/src/com/ibm/icu/impl/duration/impl/ResourceBasedPeriodFormatterDataService.java -text +icu4j/src/com/ibm/icu/impl/duration/impl/Utils.java -text +icu4j/src/com/ibm/icu/impl/duration/impl/XMLRecordReader.java -text +icu4j/src/com/ibm/icu/impl/duration/impl/XMLRecordWriter.java -text +icu4j/src/com/ibm/icu/impl/duration/impl/YMDDateFormatter.java -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/index.txt -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ar_EG.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ar_EG.xml.escaped -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_en.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_es.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_fr.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_he_IL.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_hi.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_it.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ja.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ko.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ru.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_th.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hans.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hans_SG.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hant.xml -text +icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hant_HK.xml -text icu4j/src/com/ibm/icu/text/DurationFormat.java -text icu4j/src/com/ibm/icu/util/AnnualTimeZoneRule.java -text icu4j/src/com/ibm/icu/util/BasicTimeZone.java -text diff --git a/icu4j/build.xml b/icu4j/build.xml index d78aef790cf..82e1c5fb633 100644 --- a/icu4j/build.xml +++ b/icu4j/build.xml @@ -173,6 +173,12 @@ + + + + + + - + @@ -357,6 +363,9 @@ + + + @@ -381,6 +390,7 @@ +
@@ -1554,7 +1564,7 @@ - + diff --git a/icu4j/src/com/ibm/icu/dev/test/TestAll.java b/icu4j/src/com/ibm/icu/dev/test/TestAll.java index 21821417986..e73f8cb4966 100755 --- a/icu4j/src/com/ibm/icu/dev/test/TestAll.java +++ b/icu4j/src/com/ibm/icu/dev/test/TestAll.java @@ -40,6 +40,7 @@ public class TestAll extends TestGroup { "com.ibm.icu.dev.test.timescale.TestAll", "com.ibm.icu.dev.test.charsetdet.TestCharsetDetector", "com.ibm.icu.dev.test.bidi.TestAll", + "com.ibm.icu.dev.test.duration.TestAll", //#ifndef FOUNDATION "com.ibm.icu.dev.test.charset.TestAll", "com.ibm.icu.dev.test.serializable.SerializableTest" // *is* a group diff --git a/icu4j/src/com/ibm/icu/dev/test/TestFmwk.java b/icu4j/src/com/ibm/icu/dev/test/TestFmwk.java index dbb4e7c42d1..2ae3a0a7701 100755 --- a/icu4j/src/com/ibm/icu/dev/test/TestFmwk.java +++ b/icu4j/src/com/ibm/icu/dev/test/TestFmwk.java @@ -296,6 +296,15 @@ public class TestFmwk extends AbstractTestLog { return next; } + public Target append(Target targets) { + Target t = this; + while(t.next != null) { + t = t.next; + } + t.next = targets; + return this; + } + public void run() throws Exception { int f = filter(); if (f == -1) { @@ -372,6 +381,7 @@ public class TestFmwk extends AbstractTestLog { }catch (ExceptionInInitializerError e){ handleException(e); } catch (InvocationTargetException e) { + e.printStackTrace(); handleException(e); }catch (MissingResourceException e) { handleException(e); @@ -674,18 +684,27 @@ public class TestFmwk extends AbstractTestLog { * of the object's class whose name starts with "Test" or "test". */ protected Target getTargets(String targetName) { - Class cls = getClass(); + return getClassTargets(getClass(), targetName); + } + + protected Target getClassTargets(Class cls, String targetName) { + if (cls == null) { + return null; + } + + Target target = null; if (targetName != null) { try { Method method = cls.getMethod(targetName, (Class[])null); - return new MethodTarget(targetName, method); + target = new MethodTarget(targetName, method); } catch (NoSuchMethodException e) { - return new Target(targetName); // invalid target + if (!inheritTargets()) { + return new Target(targetName); // invalid target + } } catch (SecurityException e) { return null; } } else { - Target target = null; if (params.doMethods()) { Method[] methods = cls.getDeclaredMethods(); for (int i = methods.length; --i >= 0;) { @@ -696,8 +715,24 @@ public class TestFmwk extends AbstractTestLog { } } } - return target; } + + if (inheritTargets()) { + Target parentTarget = getClassTargets(cls.getSuperclass(), targetName); + if (parentTarget == null) { + return target; + } + if (target == null) { + return parentTarget; + } + return parentTarget.append(target); + } + + return target; + } + + protected boolean inheritTargets() { + return false; } protected String getDescription() { @@ -1742,8 +1777,8 @@ public class TestFmwk extends AbstractTestLog { logln("OK" + message + ": " + (flip ? expected + relation + actual : expected)); } else { - // assert must assume errors are true errors and not just warnings - // so cannot warnln here + // assert must assume errors are true errors and not just warnings + // so cannot warnln here errln(message + ": expected" + (flip ? relation + expected : " " + expected diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/DataReadWriteTest.java b/icu4j/src/com/ibm/icu/dev/test/duration/DataReadWriteTest.java new file mode 100644 index 00000000000..003944540de --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/DataReadWriteTest.java @@ -0,0 +1,356 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration; + +import com.ibm.icu.dev.test.TestFmwk; + +import com.ibm.icu.impl.duration.impl.XMLRecordReader; +import com.ibm.icu.impl.duration.impl.XMLRecordWriter; + +import java.io.StringReader; +import java.io.StringWriter; +import java.util.Collection; +import java.util.Collections; + +public class DataReadWriteTest extends TestFmwk { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new DataReadWriteTest().run(args); + } + + // strip line ends and trailing spaces + private String normalize(String str) { + StringBuilder sb = new StringBuilder(); + boolean inLine = true; + for (int i = 0; i < str.length(); ++i) { + char c = str.charAt(i); + if (inLine && c == ' ') { + continue; + } + if (c == '\n') { + inLine = true; + continue; + } + inLine = false; + sb.append("" + c); + } + return sb.toString(); + } + + public void testOpenClose() { + StringWriter sw = new StringWriter(); + XMLRecordWriter xrw = new XMLRecordWriter(sw); + assertTrue(null, xrw.open("Test")); + assertTrue(null, xrw.close()); + xrw.flush(); + String str = sw.toString(); + assertEquals(null, "", normalize(str)); + + StringReader sr = new StringReader(str); + XMLRecordReader xrr = new XMLRecordReader(sr); + assertTrue(null, xrr.open("Test")); + assertTrue(null, xrr.close()); + } + + public void testBool() { + StringWriter sw = new StringWriter(); + XMLRecordWriter xrw = new XMLRecordWriter(sw); + xrw.bool("x", true); + xrw.bool("y", false); + xrw.flush(); + String str = sw.toString(); + assertEquals(null, "truefalse", normalize(str)); + + StringReader sr = new StringReader(str); + XMLRecordReader xrr = new XMLRecordReader(sr); + assertTrue(null, xrr.bool("x")); + assertFalse(null, xrr.bool("y")); + } + + public void testBoolArray() { + boolean[][] datas = { + {}, + { true }, + { true, false }, + { true, false, true }, + }; + + String[] targets = { + "", + "true", + "truefalse", + "truefalse" + + "true", + }; + + for (int j = 0; j < datas.length; ++j) { + boolean[] data = datas[j]; + String target = targets[j]; + + StringWriter sw = new StringWriter(); + XMLRecordWriter xrw = new XMLRecordWriter(sw); + xrw.boolArray("test", data); + xrw.flush(); + String str = sw.toString(); + assertEquals("" + j, target, normalize(str)); + + StringReader sr = new StringReader(str); + XMLRecordReader xrr = new XMLRecordReader(sr); + boolean[] out = xrr.boolArray("test"); + + assertNotNull("" + j, out); + assertEquals("" + j, data.length, out.length); + for (int i = 0; i < data.length; ++i) { + assertEquals("" + j + "/" + i, data[i], out[i]); + } + } + } + + public void testCharacter() { + StringWriter sw = new StringWriter(); + XMLRecordWriter xrw = new XMLRecordWriter(sw); + xrw.character("x", 'a'); + xrw.character("y", 'b'); + xrw.flush(); + String str = sw.toString(); + assertEquals(null, "ab", normalize(str)); + + StringReader sr = new StringReader(str); + XMLRecordReader xrr = new XMLRecordReader(sr); + assertEquals(null, 'a', xrr.character("x")); + assertEquals(null, 'b', xrr.character("y")); + } + + public void testCharacterArray() { + char[][] datas = { + {}, + { 'a' }, + { 'a', 'b' }, + { 'a', 'b', 'c' }, + }; + + String[] targets = { + "", + "a", + "ab", + "ab" + + "c", + }; + + for (int j = 0; j < datas.length; ++j) { + char[] data = datas[j]; + String target = targets[j]; + + StringWriter sw = new StringWriter(); + XMLRecordWriter xrw = new XMLRecordWriter(sw); + xrw.characterArray("test", data); + xrw.flush(); + String str = sw.toString(); + assertEquals("" + j, target, normalize(str)); + + StringReader sr = new StringReader(str); + XMLRecordReader xrr = new XMLRecordReader(sr); + char[] out = xrr.characterArray("test"); + + assertNotNull("" + j, out); + assertEquals("" + j, data.length, out.length); + for (int i = 0; i < data.length; ++i) { + assertEquals("" + j + "/" + i, data[i], out[i]); + } + } + } + + public void testNamedIndex() { + StringWriter sw = new StringWriter(); + XMLRecordWriter xrw = new XMLRecordWriter(sw); + String[] names = { "zero", "one" }; + + xrw.namedIndex("x", names, 0); + xrw.namedIndex("y", names, 1); + xrw.flush(); + String str = sw.toString(); + assertEquals(null, "zeroone", normalize(str)); + + StringReader sr = new StringReader(str); + XMLRecordReader xrr = new XMLRecordReader(sr); + assertEquals(null, 0, xrr.namedIndex("x", names)); + assertEquals(null, 1, xrr.namedIndex("y", names)); + } + + public void testNamedIndexArray() { + String[] names = { "zero", "one" }; + byte[][] datas = { + {}, + { 0 }, + { 1, 0 }, + { 0, 1, 0 }, + }; + + String[] targets = { + "", + "zero", + "onezero", + "zeroone" + + "zero", + }; + + for (int j = 0; j < datas.length; ++j) { + byte[] data = datas[j]; + String target = targets[j]; + + StringWriter sw = new StringWriter(); + XMLRecordWriter xrw = new XMLRecordWriter(sw); + xrw.namedIndexArray("test", names, data); + xrw.flush(); + String str = sw.toString(); + assertEquals("" + j, target, normalize(str)); + + StringReader sr = new StringReader(str); + XMLRecordReader xrr = new XMLRecordReader(sr); + byte[] out = xrr.namedIndexArray("test", names); + + assertNotNull("" + j, out); + assertEquals("" + j, data.length, out.length); + for (int i = 0; i < data.length; ++i) { + assertEquals("" + j + "/" + i, data[i], out[i]); + } + } + } + + public void testString() { + StringWriter sw = new StringWriter(); + XMLRecordWriter xrw = new XMLRecordWriter(sw); + + String s = " This is &&\t test. "; + String s1 = " This is && test. "; + String t = " This is <a> && test. "; + xrw.string("x", s); + xrw.flush(); + String str = sw.toString(); + assertEquals("\n'" + normalize(str) + "' = \n'" + t + "", + "" + t + "", normalize(str)); + + StringReader sr = new StringReader(str); + XMLRecordReader xrr = new XMLRecordReader(sr); + String res = xrr.string("x"); + assertEquals("\n'" + res + "' == \n'" + s1 + "'", s1, res); + } + + public void testStringArray() { + String s1 = ""; + String s2 = " "; + String s3 = "This is a test"; + String s4 = " It is\n only a test\t "; + String s4x = " It is only a test "; + + String[][] datas = { + {}, + { s1 }, + { s2, s1 }, + { s3, s2, s1 }, + { s3, null, s1, null }, + { s4, s1, s3, s2 } + }; + + String[] targets = { + "", + "" + s1 + "", + "" + s2 + "" + s1 + "", + "" + s3 + "" + s2 + + "" + s1 + "", + "" + s3 + "Null" + s1 + + "Null", + "" + s4x + "" + s1 + + "" + s3 + "" + s2 + "", + }; + + for (int j = 0; j < datas.length; ++j) { + String[] data = datas[j]; + String target = targets[j]; + + StringWriter sw = new StringWriter(); + XMLRecordWriter xrw = new XMLRecordWriter(sw); + xrw.stringArray("test", data); + xrw.flush(); + String str = sw.toString(); + assertEquals("" + j + " '" + str + "'", target, normalize(str)); + + StringReader sr = new StringReader(str); + XMLRecordReader xrr = new XMLRecordReader(sr); + String[] out = xrr.stringArray("test"); + + assertNotNull("" + j, out); + assertEquals("" + j, data.length, out.length); + for (int i = 0; i < data.length; ++i) { + String standin = data[i]; + if (s4.equals(standin)) { + standin = s4x; + } + assertEquals("" + j + "/" + i + " '" + out[i] + "'", standin, out[i]); + } + } + } + + public void testStringTable() { + String s1 = ""; + String s2 = " "; + String s3 = "This is a test"; + String s4 = "It is only a test"; + + String[][] table = { + {}, + { s1 }, + { s2, s1 }, + { s3, s2, s1 }, + null, + { s4, s1, s3, s2 } + }; + + String target = "" + + "" + + "" + + " " + + "This is a test " + + "" + + "Null" + + "It is only a test" + + "This is a test " + + ""; + + StringWriter sw = new StringWriter(); + XMLRecordWriter xrw = new XMLRecordWriter(sw); + xrw.stringTable("test", table); + xrw.flush(); + String str = sw.toString(); + assertEquals("'" + str + "'", target, normalize(str)); + } + + public void testOmittedFields() { + StringWriter sw = new StringWriter(); + XMLRecordWriter xrw = new XMLRecordWriter(sw); + xrw.open("omit"); + xrw.bool("x", true); + xrw.bool("y", false); + xrw.close(); + xrw.flush(); + String str = sw.toString(); + + StringReader sr = new StringReader(str); + XMLRecordReader xrr = new XMLRecordReader(sr); + assertTrue(null, xrr.open("omit")); + assertTrue(null, xrr.bool("x")); + assertEquals(null, '\uffff', xrr.character("z")); + assertFalse(null, xrr.bool("y")); + assertTrue(null, xrr.close()); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java b/icu4j/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java new file mode 100644 index 00000000000..33d1cfb154d --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java @@ -0,0 +1,78 @@ +/* + ******************************************************************************* + * Copyright (C) 2007, International Business Machines Corporation and * + * others. All Rights Reserved. * + ******************************************************************************* + */ +package com.ibm.icu.dev.test.duration; + +import java.util.Date; + +import com.ibm.icu.dev.test.TestFmwk; +import com.ibm.icu.text.DurationFormat; +import com.ibm.icu.util.ULocale; + +/** + * @author srl + * + */ +public class ICUDurationTest extends TestFmwk { + + /** + * + */ + public ICUDurationTest() { + } + + /** + * @param args + */ + public static void main(String[] args) { + new ICUDurationTest().run(args); + } + + + /** + * Basic test + */ + public void TestBasics() { + DurationFormat df; + String expect; + String formatted; + + df = DurationFormat.getInstance(new ULocale("it")); + formatted = df.formatDurationFromNow(4096); + expect = "fra quattro secondi"; + if(!expect.equals(formatted)) { + errln("Expected " + expect + " but got " + formatted); + } else { + logln("format duration -> " + formatted); + } + + formatted = df.formatDurationFromNowTo(new Date(0)); + expect = "fra 37 anni"; // will break next year. + if(!expect.equals(formatted)) { + errln("Expected " + expect + " but got " + formatted); + } else { + logln("format date -> " + formatted); + } + + formatted = df.formatDurationFrom(1000*3600*24, new Date(0).getTime()); + expect = "fra un giorno"; + if(!expect.equals(formatted)) { + errln("Expected " + expect + " but got " + formatted); + } else { + logln("format date from -> " + formatted); + } + + formatted = df.format(new Long(1000*3600*24*2)); + expect = "fra due giorni"; + if(!expect.equals(formatted)) { + errln("Expected " + expect + " but got " + formatted); + } else { + logln("format long obj -> " + formatted); + } + + + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/LanguageTestRoot.java b/icu4j/src/com/ibm/icu/dev/test/duration/LanguageTestRoot.java new file mode 100644 index 00000000000..58b119fa33c --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/LanguageTestRoot.java @@ -0,0 +1,683 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration; + +import com.ibm.icu.dev.test.TestFmwk; + +import com.ibm.icu.impl.duration.TimeUnitConstants; +import com.ibm.icu.impl.duration.TimeUnit; +import com.ibm.icu.impl.duration.BasicPeriodFormatterService; +import com.ibm.icu.impl.duration.DurationFormatterFactory; +import com.ibm.icu.impl.duration.PeriodFormatterFactory; +import com.ibm.icu.impl.duration.Period; +import com.ibm.icu.impl.duration.PeriodBuilder; +import com.ibm.icu.impl.duration.PeriodBuilderFactory; +import com.ibm.icu.impl.duration.PeriodFormatter; + +import com.ibm.icu.impl.duration.impl.DataRecord.EUnitVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.ECountVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.EUnitVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.EUnitVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.EUnitVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.EUnitVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.EUnitVariant; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Test cases for en + */ +public class LanguageTestRoot extends TestFmwk implements TimeUnitConstants { + + private static final TimeUnit[] units = { + TimeUnit.YEAR, TimeUnit.MONTH, TimeUnit.WEEK, TimeUnit.DAY, TimeUnit.HOUR, + TimeUnit.MINUTE, TimeUnit.SECOND, TimeUnit.MILLISECOND + }; + + protected boolean inheritTargets() { + return true; + } + + private static final BasicPeriodFormatterService pfs = + BasicPeriodFormatterService.getInstance(); + + private TestData data; + private String locale; + + private DurationFormatterFactory dfFactory; + private PeriodFormatterFactory pfFactory; + private PeriodBuilderFactory pbFactory; + + private PrintWriter pw; + + private static final Map datacache = new HashMap(); // String->TestData + + private static final long[] approxDurations = { + 36525L*24*60*60*10, 3045*24*60*60*10L, 7*24*60*60*1000L, 24*60*60*1000L, + 60*60*1000L, 60*1000L, 1000L, 1L + }; + + private static long approximateDuration(TimeUnit unit) { + return approxDurations[unit.ordinal()]; + } + + private static TestData getTestData(String locale) { + // debug + if (locale.equals("testFullPluralizedForms")) { + Thread.dumpStack(); + } + TestData data = (TestData)datacache.get(locale); + if (data == null) { + try { + InputStream is = LanguageTestRoot.class.getResourceAsStream( + "testdata/testdata_" + locale + ".txt"); + // debug + if (is == null) { + System.out.println("test data for locale '" + locale + "' is null"); + } + InputStreamReader isr = new InputStreamReader(is, "UTF-8"); + data = new FileTestData(isr); + } + catch (Exception e) { + System.err.println(e.getMessage()); + // swallow any exception + } + } + return data; + } + + public LanguageTestRoot(String locale, boolean ignore) { + this(getTestData(locale), locale); + } + + public LanguageTestRoot(TestData data, String locale) { + if (data == null) { + data = DefaultData.getInstance(); + } + this.data = data; + this.locale = locale; + } + + public static void writeData(PrintWriter pw, String locale) throws Exception { + LanguageTestRoot test = new LanguageTestRoot(DefaultData.getInstance(), locale); + test.writeData(pw); + } + + private void writeData(PrintWriter pw) throws Exception { + /* + this.pw = pw; + setUp(); + testFullPluralizedForms(); + tearDown(); + setUp(); + testMediumForms(); + tearDown(); + setUp(); + testShortForms(); + tearDown(); + setUp(); + testCustomMinutes(); + tearDown(); + setUp(); + testLimitedUnits(); + tearDown(); + setUp(); + testHalfUnits(); + tearDown(); + setUp(); + testFractionalUnits(); + tearDown(); + setUp(); + testMultipleUnits(); + tearDown(); + this.pw = null; + pw.flush(); + */ + } + + protected void xAssertEquals(String msg, String[] expected, int n, String actual) { + if (pw != null) { + pw.println(actual); + } else { + // java doesn't dump enough context to be useful, so do it myself + if (actual == null) { + assertEquals(msg, expected[n], actual); + } else { + if (!actual.equals(expected[n])) { + fail("\n(!!" + msg + ") " + asciify("expected '" + expected[n] + "' but got '" + actual + "'")); + } + } + } + } + + protected static String timestring(Period ts) { + StringBuilder buf = new StringBuilder(); + if (ts.isMoreThan()) { + buf.append("mt"); + } else if (ts.isLessThan()) { + buf.append("lt"); + } + for (int i = 0; i < units.length; ++i) { + TimeUnit p = units[i]; + if (ts.isSet(p)) { + buf.append(Float.toString(ts.getCount(p))); + buf.append(p.toString().charAt(0)); + } + } + buf.append(ts.isInPast() ? "p" : "f"); + return buf.toString(); + } + + protected static String asciify(String s) { + StringBuilder sb = null; + for (int i = 0, e = s.length(); i < e; ++i) { + char c = s.charAt(i); + if (c < 0x20 || c > 0x7e) { + if (sb == null) { + sb = new StringBuilder(); + sb.append(s.substring(0, i)); + } + sb.append("\\u"); + if (c < 0x10) { + sb.append("000"); + } else if (c < 0x100) { + sb.append("00"); + } else if (c < 0x1000) { + sb.append("0"); + } + sb.append(Integer.toHexString(c)); + } else { + if (sb != null) { + sb.append(c); + } + } + } + if (sb != null) { + System.out.println("asciify '" + s + "' --> '" + sb.toString() + "'"); + } + return sb == null ? s : sb.toString(); + } + + private void xAssertEquals(String[] expected, int n, String actual) { + xAssertEquals(null, expected, n, actual); + } + + protected void setUp() throws Exception { + pfFactory = pfs.newPeriodFormatterFactory().setLocale(locale); + pbFactory = pfs.newPeriodBuilderFactory().setLocale(locale); + } + + public void testFullPluralizedForms() throws Exception { + setUp(); + int[] counts = data.getFullPluralizedFormCounts(); + String[] targets = data.getFullPluralizedFormTargets(); + if (pw != null) { + pw.println("=fullPluralizedFormCounts"); + for (int i = 0; i < counts.length; ++i) { + int c = counts[i]; + pw.println(String.valueOf(c)); + } + pw.println("=fullPluralizedFormTargets"); + } + + int n = 0; + PeriodFormatter pf = pfFactory.getFormatter(); + for (int i = 0; i < units.length; ++i) { + TimeUnit u = units[i]; + // System.err.print("\nunit: " + u); + PeriodBuilder pb = pbFactory.getFixedUnitBuilder(u); + for (int j = 0; j < counts.length; ++j) { + int c = counts[j]; + //System.err.println("\ncount[" + j + "]: " + c); + Period p = pb.create(approximateDuration(u) * c); + String string = pf.format(p); + xAssertEquals(u.toString() + c, targets, n++, string); + } + } + } + + public void testMediumForms() throws Exception { + setUp(); + String[] targets = data.getMediumFormTargets(); + + if (pw != null) { + pw.println("=mediumFormTargets"); + } + + pfFactory.setUnitVariant(EUnitVariant.MEDIUM); + pfFactory.setDisplayPastFuture(false); + PeriodFormatter pf = pfFactory.getFormatter(); + int n = 0; + for (int i = 0; i < units.length; ++i) { + TimeUnit u = units[i]; + PeriodBuilder pb = pbFactory.getFixedUnitBuilder(u); + Period p = pb.create(approximateDuration(u) * 3); + String string = pf.format(p); + xAssertEquals(u.toString(), targets, n++, string); + } + } + + public void testShortForms() throws Exception { + setUp(); + String[] targets = data.getShortFormTargets(); + + if (pw != null) { + pw.println("=shortFormTargets"); + } + + pfFactory.setUnitVariant(EUnitVariant.SHORT); + pfFactory.setDisplayPastFuture(false); + PeriodFormatter pf = pfFactory.getFormatter(); + int n = 0; + for (int i = 0; i < units.length; ++i) { + TimeUnit u = units[i]; + PeriodBuilder pb = pbFactory.getFixedUnitBuilder(u); + Period p = pb.create(approximateDuration(u) * 3); + String string = pf.format(p); + xAssertEquals(u.toString(), targets, n++, string); + } + } + + public void testCustomMinutes() throws Exception { + setUp(); + String[] targets = data.getCustomMinuteTargets(); + + if (pw != null) { + pw.println("=customMinuteTargets"); + } + + pfFactory.setCountVariant(ECountVariant.INTEGER_CUSTOM); + pfFactory.setDisplayPastFuture(false); + PeriodFormatter pf = pfFactory.getFormatter(); + + Period p = Period.at(1, HOUR); + int n = 0; + for (int i = 1; i < 12; ++i) { + p = p.and(i*5, MINUTE).omit(HOUR); + xAssertEquals(targets, n++, pf.format(p)); + p = p.and(1, HOUR); + xAssertEquals(targets, n++, pf.format(p)); + } + } + + public void testLimitedUnits() throws Exception { + setUp(); + String[] targets = data.getLimitedUnitTargets(); + + if (pw != null) { + pw.println("=limitedPeriodTargets"); + } + + Period p = Period.at(1, MONTH); + int n = 0; + for (int i = 0; i < 3; ++i) { + switch(i) { + case 0: p = p.at(); break; + case 1: p = p.lessThan(); break; + case 2: p = p.moreThan(); break; + } + for (int j = 0; j < 3; ++j) { + pfFactory.setDisplayPastFuture(true); + switch (j) { + case 0: pfFactory.setDisplayPastFuture(false); break; + case 1: p = p.inPast(); break; + case 2: p = p.inFuture(); break; + } + + PeriodFormatter pf = pfFactory.getFormatter(); + + p = p.omit(WEEK).omit(DAY); + xAssertEquals(targets, n++, pf.format(p)); + + p = p.and(2, WEEK); + xAssertEquals(targets, n++, pf.format(p)); + + p = p.and(3, DAY); + xAssertEquals(targets, n++, pf.format(p)); + } + } + + p = p.omit(MONTH).omit(WEEK).omit(DAY).and(1, HOUR); + for (int i = 0; i < 3; ++i) { + switch(i) { + case 0: p = p.at(); break; + case 1: p = p.lessThan(); break; + case 2: p = p.moreThan(); break; + } + for (int j = 0; j < 3; ++j) { + pfFactory.setDisplayPastFuture(true); + switch (j) { + case 0: pfFactory.setDisplayPastFuture(false); break; + case 1: p = p.inPast(); break; + case 2: p = p.inFuture(); break; + } + + PeriodFormatter pf = pfFactory.getFormatter(); + + p = p.omit(MINUTE).omit(SECOND); + xAssertEquals(targets, n++, pf.format(p)); + + p = p.and(2, MINUTE); + xAssertEquals(targets, n++, pf.format(p)); + + p = p.and(3, SECOND); + xAssertEquals(targets, n++, pf.format(p)); + } + } + } + + public void testHalfUnits() throws Exception { + setUp(); + int[] counts = data.getHalfUnitCounts(); + String[] targets = data.getHalfUnitTargets(); + + if (pw != null) { + pw.println("=halfPeriodCounts"); + for (int i = 0; i < counts.length; ++i) { + int c = counts[i]; + pw.println(String.valueOf(c)); + } + pw.println("=halfPeriodTargets"); + } + + pfFactory.setCountVariant(ECountVariant.HALF_FRACTION); + pfFactory.setDisplayPastFuture(false); + PeriodFormatter pf = pfFactory.getFormatter(); + + int n = 0; + for (int i = 0; i < units.length; ++i) { + TimeUnit u = units[i]; + for (int j = 0; j < counts.length; ++j) { + int c = counts[j]; + Period p = Period.at(c + .5f, u); + String string = pf.format(p); + xAssertEquals(u.toString(), targets, n++, string); + } + } + } + + public void testFractionalUnits() throws Exception { + setUp(); + float[] counts = data.getFractionalUnitCounts(); + String[] targets = data.getFractionalUnitTargets(); + + if (pw != null) { + pw.println("=fractionalPeriodCounts"); + for (int i = 0; i < counts.length; ++i) { + float c = counts[i]; + pw.println(String.valueOf(c)); + } + pw.println("=fractionalPeriodTargets"); + } + + pfFactory.setCountVariant(ECountVariant.DECIMAL2); + pfFactory.setDisplayPastFuture(false); + PeriodFormatter pf = pfFactory.getFormatter(); + + int n = 0; + for (int i = 0; i < units.length; ++i) { + TimeUnit u = units[i]; + for (int j = 0; j < counts.length; ++j) { + float c = counts[j]; + Period p = Period.at(c, u); + String string = pf.format(p); + xAssertEquals(u.toString(), targets, n++, string); + } + } + } + + public void testMultipleUnits() throws Exception { + setUp(); + String[] targets = data.getMultipleUnitTargets(); + + if (pw != null) { + pw.println("=multiplePeriodTargets"); + } + + pfFactory.setCountVariant(ECountVariant.INTEGER); + pfFactory.setDisplayPastFuture(false); + PeriodFormatter pf = pfFactory.getFormatter(); + + int n = 0; + for (int i = 0; i < units.length - 1; ++i) { + Period p = Period.at(1, units[i]).and(2, units[i+1]); + xAssertEquals(targets, n++, pf.format(p)); + if (i < units.length - 2) { + p = Period.at(1, units[i]).and(3, units[i+2]); + xAssertEquals(targets, n++, pf.format(p)); + p = Period.at(1, units[i]).and(2, units[i+1]).and(3, units[i+2]); + xAssertEquals(targets, n++, pf.format(p)); + } + } + } + + public static abstract class TestData { + abstract int[] getFullPluralizedFormCounts(); + abstract String[] getFullPluralizedFormTargets(); + abstract String[] getMediumFormTargets(); + abstract String[] getShortFormTargets(); + abstract String[] getCustomMinuteTargets(); + abstract String[] getLimitedUnitTargets(); + abstract int[] getHalfUnitCounts(); + abstract String[] getHalfUnitTargets(); + abstract float[] getFractionalUnitCounts(); + abstract String[] getFractionalUnitTargets(); + abstract String[] getMultipleUnitTargets(); + } + +} + +class FileTestData extends LanguageTestRoot.TestData { + private int[] fullPluralizedFormCounts; + private String[] fullPluralizedFormTargets; + private String[] mediumFormTargets; + private String[] shortFormTargets; + private String[] customMinuteTargets; + private String[] limitedUnitTargets; + private int[] halfUnitCounts; + private String[] halfUnitTargets; + private float[] fractionalUnitCounts; + private String[] fractionalUnitTargets; + private String[] multipleUnitTargets; + + int[] getFullPluralizedFormCounts() { return fullPluralizedFormCounts; } + String[] getFullPluralizedFormTargets() { return fullPluralizedFormTargets; } + String[] getMediumFormTargets() { return mediumFormTargets; } + String[] getShortFormTargets() { return shortFormTargets; } + String[] getCustomMinuteTargets() { return customMinuteTargets; } + String[] getLimitedUnitTargets() { return limitedUnitTargets; } + int[] getHalfUnitCounts() { return halfUnitCounts; } + String[] getHalfUnitTargets() { return halfUnitTargets; } + float[] getFractionalUnitCounts() { return fractionalUnitCounts; } + String[] getFractionalUnitTargets() { return fractionalUnitTargets; } + String[] getMultipleUnitTargets() { return multipleUnitTargets; } + + public FileTestData(InputStreamReader isr) throws Exception { + BufferedReader br = new BufferedReader(isr); + + class Wrapup { + int[] intArray; + float[] floatArray; + String[] stringArray; + + void wrapup(List /* of String */ list, Element element) { + if (list == null) return; + + switch (element.mode) { + case EMode.mString: + stringArray = (String[])list.toArray(new String[list.size()]); + break; + + case EMode.mInt: + intArray = new int[list.size()]; + for (int i = 0, e = intArray.length; i < e; ++i) { + intArray[i] = Integer.parseInt((String)list.get(i)); + } + break; + + case EMode.mFloat: + floatArray = new float[list.size()]; + for (int i = 0, e = floatArray.length; i < e; ++i) { + floatArray[i] = Float.parseFloat((String)list.get(i)); + } + break; + } + + switch (element.which) { + case Element.XfullPluralizedFormCounts: + FileTestData.this.fullPluralizedFormCounts = intArray; break; + case Element.XfullPluralizedFormTargets: + FileTestData.this.fullPluralizedFormTargets = stringArray; break; + case Element.XmediumFormTargets: + FileTestData.this.mediumFormTargets = stringArray; break; + case Element.XshortFormTargets: + FileTestData.this.shortFormTargets = stringArray; break; + case Element.XcustomMinuteTargets: + FileTestData.this.customMinuteTargets = stringArray; break; + case Element.XlimitedUnitTargets: + FileTestData.this.limitedUnitTargets = stringArray; break; + case Element.XhalfUnitCounts: + FileTestData.this.halfUnitCounts = intArray; break; + case Element.XhalfUnitTargets: + FileTestData.this.halfUnitTargets = stringArray; break; + case Element.XfractionalUnitCounts: + FileTestData.this.fractionalUnitCounts = floatArray; break; + case Element.XfractionalUnitTargets: + FileTestData.this.fractionalUnitTargets = stringArray; break; + case Element.XmultipleUnitTargets: + FileTestData.this.multipleUnitTargets = stringArray; break; + } + } + } + Wrapup w = new Wrapup(); + + List /* of String */ list = null; + Element element = null; + String line = null; + while (null != (line = br.readLine())) { + line = line.trim(); + if (line.length() == 0 || line.charAt(0) == '#') continue; + if (line.charAt(0) == '=') { + w.wrapup(list, element); + + list = new ArrayList(); + element = Element.forString(line.substring(1)); + } else if (line.equals("null")) { + list.add(null); + } else { + list.add(line); + } + } + w.wrapup(list, element); + } +} + +class DefaultData extends LanguageTestRoot.TestData { + private static final int[] fullPluralizedFormCounts = { + -3, -2, -1, 0, 1, 2, 3, 5, 10, 11, 12, 20, 21, 22, 23, 25 + }; + private static final int[] halfUnitCounts = { + 0, 1, 2, 5, 10, 11, 12, 20, 21, 22 + }; + private static final float[] fractionalUnitCounts = { + 0.025f, 1.0f, 1.205f, 2.125f, 12.05f + }; + + private static final DefaultData instance = new DefaultData(); + + private DefaultData() { + } + + public static DefaultData getInstance() { + return instance; + } + + int[] getFullPluralizedFormCounts() { return fullPluralizedFormCounts; } + String[] getFullPluralizedFormTargets() { return null; } + String[] getMediumFormTargets() { return null; } + String[] getShortFormTargets() { return null; } + String[] getCustomMinuteTargets() { return null; } + String[] getLimitedUnitTargets() { return null; } + int[] getHalfUnitCounts() { return halfUnitCounts; } + String[] getHalfUnitTargets() { return null; } + float[] getFractionalUnitCounts() { return fractionalUnitCounts; } + String[] getFractionalUnitTargets() { return null; } + String[] getMultipleUnitTargets() { return null; } +} + +class EMode { + static final int mString = 0; + static final int mInt = 1; + static final int mFloat = 2; +} + +class Element { + final String name; + final int mode; + final int which; + + static int counter = 0; + static Element[] list = new Element[11]; + + Element(String name) { + this.name = name; + mode = EMode.mString; + this.which = counter++; + list[this.which] = this; + } + + Element(String name, int mode) { + this.name = name; + this.mode = mode; + this.which = counter++; + list[this.which] = this; + } + + static final int XfullPluralizedFormCounts = 0; + static final int XfullPluralizedFormTargets = 1; + static final int XmediumFormTargets = 2; + static final int XshortFormTargets = 3; + static final int XcustomMinuteTargets = 4; + static final int XlimitedUnitTargets = 5; + static final int XhalfUnitCounts = 6; + static final int XhalfUnitTargets = 7; + static final int XfractionalUnitCounts = 8; + static final int XfractionalUnitTargets = 9; + static final int XmultipleUnitTargets = 10; + + static final Element fullPluralizedFormCounts = new Element("fullPluralizedFormCounts", EMode.mInt); + static final Element fullPluralizedFormTargets = new Element("fullPluralizedFormTargets"); + static final Element mediumFormTargets = new Element("mediumFormTargets"); + static final Element shortFormTargets = new Element("shortFormTargets"); + static final Element customMinuteTargets = new Element("customMinuteTargets"); + static final Element limitedUnitTargets = new Element("limitedUnitTargets"); + static final Element halfUnitCounts = new Element("halfUnitCounts",EMode.mInt); + static final Element halfUnitTargets = new Element("halfUnitTargets"); + static final Element fractionalUnitCounts = new Element("fractionalUnitCounts",EMode.mFloat); + static final Element fractionalUnitTargets = new Element("fractionalUnitTargets"); + static final Element multipleUnitTargets = new Element("multipleUnitTargets"); + + static Element forString(String s) { + for (int i = 0; i < list.length; ++i) { + if (list[i].name.equals(s)) { + return list[i]; + } + } + return null; + } +} + diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/PeriodBuilderFactoryTest.java b/icu4j/src/com/ibm/icu/dev/test/duration/PeriodBuilderFactoryTest.java new file mode 100644 index 00000000000..a6b27acf24e --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/PeriodBuilderFactoryTest.java @@ -0,0 +1,91 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2007 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration; + +import com.ibm.icu.dev.test.TestFmwk; + +import com.ibm.icu.impl.duration.BasicPeriodFormatterService; +import com.ibm.icu.impl.duration.PeriodBuilder; +import com.ibm.icu.impl.duration.TimeUnit; +import com.ibm.icu.impl.duration.Period; +import com.ibm.icu.impl.duration.PeriodBuilderFactory; +import com.ibm.icu.impl.duration.TimeUnitConstants; + +public class PeriodBuilderFactoryTest extends TestFmwk implements TimeUnitConstants { + private PeriodBuilderFactory pbf; + + private static final long[] approxDurations = { + 36525L*24*60*60*10, 3045*24*60*60*10L, 7*24*60*60*1000L, 24*60*60*1000L, + 60*60*1000L, 60*1000L, 1000L, 1L + }; + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new PeriodBuilderFactoryTest().run(args); + } + + public void testSetAvailableUnitRange() { + // sanity check, make sure by default all units are set + pbf = BasicPeriodFormatterService.getInstance().newPeriodBuilderFactory(); + pbf.setLocale("en"); // in en locale, all units always available + PeriodBuilder b = pbf.getSingleUnitBuilder(); + for (TimeUnit unit = YEAR; unit != null; unit = unit.smaller()) { + Period p = b.create((long)(approxDurations[unit.ordinal()]*2.5)); + assertTrue(null, p.isSet(unit)); + } + + pbf.setAvailableUnitRange(MINUTE, MONTH); + // units that are not available are never set + b = pbf.getSingleUnitBuilder(); + for (TimeUnit unit = YEAR; unit != null; unit = unit.smaller()) { + Period p = b.create((long)(approxDurations[unit.ordinal()]*2.5)); + assertEquals(null, p.isSet(unit), unit.ordinal() >= MONTH.ordinal() && unit.ordinal() <= MINUTE.ordinal()); + } + + // fixed unit builder returns null when unit is not available + for (TimeUnit unit = YEAR; unit != null; unit = unit.smaller()) { + b = pbf.getFixedUnitBuilder(unit); + if (unit.ordinal() >= MONTH.ordinal() && unit.ordinal() <= MINUTE.ordinal()) { + assertNotNull(null, b); + } else { + assertNull(null, b); + } + } + + // can't set empty range + try { + pbf.setAvailableUnitRange(MONTH, MINUTE); + fail("set empty range"); + } catch (IllegalArgumentException e) { + // pass + } + } + + public void testSetUnitIsAvailable() { + pbf = BasicPeriodFormatterService.getInstance().newPeriodBuilderFactory(); + pbf.setAvailableUnitRange(MONTH, MONTH); + assertNotNull(null, pbf.getSingleUnitBuilder()); + assertNotNull(null, pbf.getOneOrTwoUnitBuilder()); + assertNotNull(null, pbf.getMultiUnitBuilder(2)); + + // now no units are available, make sure we can't generate a builder + pbf.setUnitIsAvailable(MONTH, false); + assertNull(null, pbf.getSingleUnitBuilder()); + assertNull(null, pbf.getOneOrTwoUnitBuilder()); + assertNull(null, pbf.getMultiUnitBuilder(2)); + + pbf.setUnitIsAvailable(DAY, true); + assertNotNull(null, pbf.getSingleUnitBuilder()); + assertNotNull(null, pbf.getOneOrTwoUnitBuilder()); + assertNotNull(null, pbf.getMultiUnitBuilder(2)); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/PeriodBuilderTest.java b/icu4j/src/com/ibm/icu/dev/test/duration/PeriodBuilderTest.java new file mode 100644 index 00000000000..7a7927f24f2 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/PeriodBuilderTest.java @@ -0,0 +1,22 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration; + +import com.ibm.icu.dev.test.TestFmwk; + +public class PeriodBuilderTest extends TestFmwk { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new PeriodBuilderTest().run(args); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/PeriodTest.java b/icu4j/src/com/ibm/icu/dev/test/duration/PeriodTest.java new file mode 100644 index 00000000000..875a7e2a7a8 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/PeriodTest.java @@ -0,0 +1,112 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration; + +import com.ibm.icu.dev.test.TestFmwk; + +import com.ibm.icu.impl.duration.Period; +import com.ibm.icu.impl.duration.TimeUnit; + +public class PeriodTest extends TestFmwk { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new PeriodTest().run(args); + } + + public void testIsSet() { + Period p = Period.at(0, TimeUnit.YEAR); + assertTrue(null, p.isSet()); + assertTrue(null, p.isSet(TimeUnit.YEAR)); + assertFalse(null, p.isSet(TimeUnit.MONTH)); + assertEquals(null, 0f, p.getCount(TimeUnit.YEAR), .1f); + p = p.omit(TimeUnit.YEAR); + assertFalse(null, p.isSet(TimeUnit.YEAR)); + } + + public void testMoreLessThan() { + Period p = Period.moreThan(1, TimeUnit.YEAR); + assertTrue(null, p.isMoreThan()); + assertFalse(null, p.isLessThan()); + p = p.at(); + assertFalse(null, p.isMoreThan()); + assertFalse(null, p.isLessThan()); + p = p.lessThan(); + assertFalse(null, p.isMoreThan()); + assertTrue(null, p.isLessThan()); + p = p.moreThan(); + assertTrue(null, p.isMoreThan()); + assertFalse(null, p.isLessThan()); + + p = Period.lessThan(1, TimeUnit.YEAR); + assertFalse(null, p.isMoreThan()); + assertTrue(null, p.isLessThan()); + + p = Period.at(1, TimeUnit.YEAR); + assertFalse(null, p.isMoreThan()); + assertFalse(null, p.isLessThan()); + + assertEquals(null, 1f, p.getCount(TimeUnit.YEAR), .1f); + } + + public void testFuturePast() { + Period p = Period.at(1, TimeUnit.YEAR).inFuture(); + assertTrue(null, p.isInFuture()); + p = p.inPast(); + assertFalse(null, p.isInFuture()); + p = p.inFuture(true); + assertTrue(null, p.isInFuture()); + p = p.inFuture(false); + assertFalse(null, p.isInFuture()); + } + + public void testAnd() { + Period p = Period.at(1, TimeUnit.YEAR).and(3, TimeUnit.MONTH).inFuture(); + assertTrue(null, p.isSet(TimeUnit.YEAR)); + assertTrue(null, p.isSet(TimeUnit.MONTH)); + assertEquals(null, 3f, p.getCount(TimeUnit.MONTH), .1f); + p = p.and(2, TimeUnit.MONTH); + assertEquals(null, 2f, p.getCount(TimeUnit.MONTH), .1f); + } + + public void testInvalidCount() { + try { + Period p = Period.at(-1, TimeUnit.YEAR); + fail("at -1"); + } + catch (IllegalArgumentException e) { + // passed + } + try { + Period p = Period.moreThan(-1, TimeUnit.YEAR); + fail("moreThan -1"); + } + catch (IllegalArgumentException e) { + // passed + } + try { + Period p = Period.lessThan(-1, TimeUnit.YEAR); + fail("lessThan -1"); + } + catch (IllegalArgumentException e) { + // passed + } + Period p = Period.at(1, TimeUnit.YEAR); + try { + p = p.and(-1, TimeUnit.MONTH); + fail("and -1"); + } + catch (IllegalArgumentException e) { + // passed + } + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/ResourceBasedPeriodFormatterDataServiceTest.java b/icu4j/src/com/ibm/icu/dev/test/duration/ResourceBasedPeriodFormatterDataServiceTest.java new file mode 100644 index 00000000000..cb88a5be658 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/ResourceBasedPeriodFormatterDataServiceTest.java @@ -0,0 +1,39 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration; + +import com.ibm.icu.dev.test.TestFmwk; + +import com.ibm.icu.impl.duration.impl.ResourceBasedPeriodFormatterDataService; +import com.ibm.icu.impl.duration.impl.PeriodFormatterData; + +import java.util.Iterator; +import java.util.Collection; + +public class ResourceBasedPeriodFormatterDataServiceTest extends TestFmwk { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new ResourceBasedPeriodFormatterDataServiceTest().run(args); + } + + public void testAvailable() { + ResourceBasedPeriodFormatterDataService service = + ResourceBasedPeriodFormatterDataService.getInstance(); + Collection locales = service.getAvailableLocales(); + for (Iterator i = locales.iterator(); i.hasNext();) { + String locale = (String)i.next(); + PeriodFormatterData pfd = service.get(locale); + assertFalse(locale + ": " + pfd.pluralization(), -1 == pfd.pluralization()); + } + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/TestAll.java b/icu4j/src/com/ibm/icu/dev/test/duration/TestAll.java new file mode 100644 index 00000000000..9b1a17fa602 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/TestAll.java @@ -0,0 +1,38 @@ +// Copyright 2006 Google Inc. All Rights Reserved. +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + + +package com.ibm.icu.dev.test.duration; + +import com.ibm.icu.dev.test.TestFmwk.TestGroup; + +/** + * Top level test used to run all other tests as a batch. + */ +public class TestAll extends TestGroup { + + public static void main(String[] args) { + new TestAll().run(args); + } + + public TestAll() { + super(new String[] { + "com.ibm.icu.dev.test.duration.ICUDurationTest", + "com.ibm.icu.dev.test.duration.DataReadWriteTest", + "com.ibm.icu.dev.test.duration.PeriodBuilderFactoryTest", + "com.ibm.icu.dev.test.duration.PeriodBuilderTest", + "com.ibm.icu.dev.test.duration.PeriodTest", + "com.ibm.icu.dev.test.duration.ResourceBasedPeriodFormatterDataServiceTest", + "com.ibm.icu.dev.test.duration.languages.TestAll", + }, + "Duration Tests"); + } + + public static final String CLASS_TARGET_NAME = "Duration"; +} + diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/TestAll.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/TestAll.java new file mode 100644 index 00000000000..ed66b2e1127 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/TestAll.java @@ -0,0 +1,44 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.TestFmwk.TestGroup; + +/** + * Top level test used to run all other tests as a batch. + */ +public class TestAll extends TestGroup { + + public static void main(String[] args) { + new TestAll().run(args); + } + + public TestAll() { + super(new String[] { + // "com.ibm.icu.dev.test.duration.languages.Test_ar_EG", + "com.ibm.icu.dev.test.duration.languages.Test_en", + "com.ibm.icu.dev.test.duration.languages.Test_es", + "com.ibm.icu.dev.test.duration.languages.Test_fr", + "com.ibm.icu.dev.test.duration.languages.Test_he_IL", + "com.ibm.icu.dev.test.duration.languages.Test_hi", + "com.ibm.icu.dev.test.duration.languages.Test_it", + "com.ibm.icu.dev.test.duration.languages.Test_ja", + "com.ibm.icu.dev.test.duration.languages.Test_ko", + "com.ibm.icu.dev.test.duration.languages.Test_zh_Hans", + "com.ibm.icu.dev.test.duration.languages.Test_zh_Hans_SG", + "com.ibm.icu.dev.test.duration.languages.Test_zh_Hant", + "com.ibm.icu.dev.test.duration.languages.Test_zh_Hant_HK", + }, + "Duration Language Tests"); + } + + public static final String CLASS_TARGET_NAME = "DurationLanguages"; +} + diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ar_EG.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ar_EG.java new file mode 100644 index 00000000000..09a059c154c --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ar_EG.java @@ -0,0 +1,33 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + + +/** + * Test cases for ar_EG + */ +public class Test_ar_EG extends LanguageTestRoot { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_ar_EG().run(args); + } + + /** + * Constructor. + */ + public Test_ar_EG() { + super("ar_EG", false); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_en.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_en.java new file mode 100644 index 00000000000..d9fad8517d2 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_en.java @@ -0,0 +1,29 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + +/** + * Test cases for en + */ +public class Test_en extends LanguageTestRoot { + + public static void main(String[] args) { + new Test_en().run(args); + } + + /** + * Constructor. + */ + public Test_en() { + super("en", false); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_es.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_es.java new file mode 100644 index 00000000000..f1ccaf20f4c --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_es.java @@ -0,0 +1,32 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + +/** + * Test cases for es + */ +public class Test_es extends LanguageTestRoot { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_es().run(args); + } + + /** + * Constructor. + */ + public Test_es() { + super("es", false); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_fr.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_fr.java new file mode 100644 index 00000000000..eb17231be1d --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_fr.java @@ -0,0 +1,32 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + +/** + * Test cases for fr + */ +public class Test_fr extends LanguageTestRoot { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_fr().run(args); + } + + /** + * Constructor. + */ + public Test_fr() { + super("fr", false); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_he_IL.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_he_IL.java new file mode 100644 index 00000000000..cb7e3eb5cdd --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_he_IL.java @@ -0,0 +1,32 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + + +/** + * Test cases for he_IL + */ +public class Test_he_IL extends LanguageTestRoot { + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_he_IL().run(args); + } + + /** + * Constructor. + */ + public Test_he_IL() { + super("he_IL", false); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_hi.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_hi.java new file mode 100644 index 00000000000..51b632d8cd0 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_hi.java @@ -0,0 +1,68 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + +import com.ibm.icu.impl.duration.Period; +import com.ibm.icu.impl.duration.PeriodFormatter; +import com.ibm.icu.impl.duration.BasicPeriodFormatterFactory; +import com.ibm.icu.impl.duration.PeriodFormatterFactory; +import com.ibm.icu.impl.duration.TimeUnitConstants; + +/** + * Test cases for hi + */ +public class Test_hi extends LanguageTestRoot implements TimeUnitConstants { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_hi().run(args); + } + + /** + * Constructor. + */ + public Test_hi() { + super("hi", false); + } + + public void testMonthNames() { + // test that month uses the plural form with singular digit + // in these cases: + // "1 months from now" + // "1 months, and 2 weeks from now" + // "more than 1 months", + // "more than 1 months ago" + + Period[] times = { + Period.at(1, MONTH).inFuture(), + Period.at(1, MONTH).and(2, WEEK).inFuture(), + Period.moreThan(1, MONTH), + Period.moreThan(1, MONTH).inFuture(), + }; + + String[] targets = { + "\u0905\u092d\u0940 \u0938\u0947 \u0967 \u092e\u0939\u0940\u0928\u0947 \u092c\u093e\u0926", + "\u0905\u092d\u0940 \u0938\u0947 \u0967 \u092e\u0939\u0940\u0928\u0947 \u0914\u0930 \u0968 \u0938\u092a\u094d\u0924\u093e\u0939 \u092c\u093e\u0926", + "\u0967 \u092e\u0939\u0940\u0928\u0947 \u0938\u0947 \u0915\u092e", + "\u0967 \u092e\u0939\u0940\u0928\u0947 \u0938\u0947 \u0915\u092e \u092a\u0939\u0932\u0947", + }; + + PeriodFormatterFactory pff = BasicPeriodFormatterFactory.getDefault() + .setLocale("hi"); + PeriodFormatter pf = pff.getFormatter(); + for (int i = 0; i < targets.length; ++i) { + //xAssertEquals(timestring(times[i]), targets, i, pf.format(times[i])); + } + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_it.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_it.java new file mode 100644 index 00000000000..518788b77fe --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_it.java @@ -0,0 +1,32 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + +/** + * Test cases for it + */ +public class Test_it extends LanguageTestRoot { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_it().run(args); + } + + /** + * Constructor. + */ + public Test_it() { + super("it", false); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ja.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ja.java new file mode 100644 index 00000000000..02619e6f4d4 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ja.java @@ -0,0 +1,69 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + +import com.ibm.icu.impl.duration.BasicPeriodFormatterFactory; +import com.ibm.icu.impl.duration.Period; +import com.ibm.icu.impl.duration.PeriodFormatter; +import com.ibm.icu.impl.duration.TimeUnitConstants; + +/** + * Test cases for en + */ +public class Test_ja extends LanguageTestRoot implements TimeUnitConstants { + private BasicPeriodFormatterFactory pff; + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_ja().run(args); + } + + /** + * Constructor. + */ + public Test_ja() { + super("ja", false); + this.pff = (BasicPeriodFormatterFactory)BasicPeriodFormatterFactory.getDefault(). + setLocale("ja"); + } + + public void testNoMillis() { + // explicit test that japanese doesn't use both seconds + // and milliseconds when formatting. if both appear, + // force decimal3 seconds and merge millis with it. + logln("test disabled"); + /* + PeriodFormatter pf = pff.getFormatter(); + Period p = Period.at(1, MILLISECOND); + assertEquals(null, "1\u30df\u30ea\u79d2\u524d", pf.format(p)); + + p.and(1, SECOND); + assertEquals(null, "1.001\u79d2\u524d", pf.format(p)); + + p.and(1, MINUTE).omit(SECOND); + assertEquals(null, "1\u5206\u30681\u30df\u30ea\u79d2\u524d", pf.format(p)); + */ + } + + public void testOmitZeros() { + // zeros are treated as omitted + + PeriodFormatter pf = pff.getFormatter(); + Period p = Period.at(1, MINUTE).and(0, SECOND).and(1, MILLISECOND); + String s1 = pf.format(p); + p.omit(SECOND); + String s2 = pf.format(p); + assertEquals(null, s1, s2); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ko.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ko.java new file mode 100644 index 00000000000..ae722a0a7b3 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ko.java @@ -0,0 +1,32 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + +/** + * Test cases for ko + */ +public class Test_ko extends LanguageTestRoot { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_ko().run(args); + } + + /** + * Constructor. + */ + public Test_ko() { + super("ko", false); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ru.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ru.java new file mode 100644 index 00000000000..f27d0a15500 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_ru.java @@ -0,0 +1,33 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + + +/** + * Test cases for ru + */ +public class Test_ru extends LanguageTestRoot { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_ru().run(args); + } + + /** + * Constructor. + */ + public Test_ru() { + super("ru", false); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hans.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hans.java new file mode 100644 index 00000000000..1dbc28a3340 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hans.java @@ -0,0 +1,33 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + + +/** + * Test cases for zh_Hans + */ +public class Test_zh_Hans extends LanguageTestRoot { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_zh_Hans().run(args); + } + + /** + * Constructor. + */ + public Test_zh_Hans() { + super("zh_Hans", false); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hans_SG.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hans_SG.java new file mode 100644 index 00000000000..3932c064d0a --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hans_SG.java @@ -0,0 +1,32 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + +/** + * Test cases for zh_Hans_SG + */ +public class Test_zh_Hans_SG extends LanguageTestRoot { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_zh_Hans_SG().run(args); + } + + /** + * Constructor. + */ + public Test_zh_Hans_SG() { + super("zh_Hans_SG", false); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hant.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hant.java new file mode 100644 index 00000000000..df6963f75db --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hant.java @@ -0,0 +1,33 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + + +/** + * Test cases for zh_Hant + */ +public class Test_zh_Hant extends LanguageTestRoot { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_zh_Hant().run(args); + } + + /** + * Constructor. + */ + public Test_zh_Hant() { + super("zh_Hant", false); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hant_HK.java b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hant_HK.java new file mode 100644 index 00000000000..4e49aff5122 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/languages/Test_zh_Hant_HK.java @@ -0,0 +1,33 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package com.ibm.icu.dev.test.duration.languages; + +import com.ibm.icu.dev.test.duration.LanguageTestRoot; + + +/** + * Test cases for zh_Hant_HK + */ +public class Test_zh_Hant_HK extends LanguageTestRoot { + + /** + * Invoke the tests. + */ + public static void main(String[] args) { + new Test_zh_Hant_HK().run(args); + } + + /** + * Constructor. + */ + public Test_zh_Hant_HK() { + super("zh_Hant_HK", false); + } +} diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ar_EG.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ar_EG.txt new file mode 100644 index 00000000000..40f20eee1d4 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ar_EG.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +منذ ٣ سنوات +منذ سنتين +منذ سنة +٠ سنوات +سنة بعد الآن +سنتين بعد الآن +٣ سنوات بعد الآن +٥ سنوات بعد الآن +١٠ سنوات بعد الآن +١١ سنة بعد الآن +١٢ سنة بعد الآن +٢٠ سنة بعد الآن +٢١ سنة بعد الآن +٢٢ سنة بعد الآن +٢٣ سنة بعد الآن +٢٥ سنة بعد الآن +منذ ٣ شهور +منذ شهرين +منذ شهر +٠ شهور +شهر بعد الآن +شهرين بعد الآن +٣ شهور بعد الآن +٥ شهور بعد الآن +١٠ شهور بعد الآن +١١ شهر بعد الآن +١٢ شهر بعد الآن +٢٠ شهر بعد الآن +٢١ شهر بعد الآن +٢٢ شهر بعد الآن +٢٣ شهر بعد الآن +٢٥ شهر بعد الآن +منذ ٣ أسابيع +منذ أسبوعين +منذ أسبوع +٠ أسابيع +أسبوع بعد الآن +أسبوعين بعد الآن +٣ أسابيع بعد الآن +٥ أسابيع بعد الآن +١٠ أسابيع بعد الآن +١١ أسبوع بعد الآن +١٢ أسبوع بعد الآن +٢٠ أسبوع بعد الآن +٢١ أسبوع بعد الآن +٢٢ أسبوع بعد الآن +٢٣ أسبوع بعد الآن +٢٥ أسبوع بعد الآن +منذ ٣ أيام +منذ يومين +منذ يوم +٠ أيام +يوم بعد الآن +يومين بعد الآن +٣ أيام بعد الآن +٥ أيام بعد الآن +١٠ أيام بعد الآن +١١ يوم بعد الآن +١٢ يوم بعد الآن +٢٠ يوم بعد الآن +٢١ يوم بعد الآن +٢٢ يوم بعد الآن +٢٣ يوم بعد الآن +٢٥ يوم بعد الآن +منذ ٣ ساعات +منذ ساعتين +منذ ساعة +٠ ساعات +ساعة بعد الآن +ساعتين بعد الآن +٣ ساعات بعد الآن +٥ ساعات بعد الآن +١٠ ساعات بعد الآن +١١ ساعة بعد الآن +١٢ ساعة بعد الآن +٢٠ ساعة بعد الآن +٢١ ساعة بعد الآن +٢٢ ساعة بعد الآن +٢٣ ساعة بعد الآن +٢٥ ساعة بعد الآن +منذ ٣ دقائق +منذ دقيقتين +منذ دقيقة +٠ دقائق +دقيقة بعد الآن +دقيقتين بعد الآن +٣ دقائق بعد الآن +٥ دقائق بعد الآن +١٠ دقائق بعد الآن +١١ دقيقة بعد الآن +١٢ دقيقة بعد الآن +٢٠ دقيقة بعد الآن +٢١ دقيقة بعد الآن +٢٢ دقيقة بعد الآن +٢٣ دقيقة بعد الآن +٢٥ دقيقة بعد الآن +منذ ٣ ثواني +منذ ثانيتين +منذ ثانية +٠ ثواني +ثانية بعد الآن +ثانيتين بعد الآن +٣ ثواني بعد الآن +٥ ثواني بعد الآن +١٠ ثواني بعد الآن +١١ ثانية بعد الآن +١٢ ثانية بعد الآن +٢٠ ثانية بعد الآن +٢١ ثانية بعد الآن +٢٢ ثانية بعد الآن +٢٣ ثانية بعد الآن +٢٥ ثانية بعد الآن +منذ ٣ أجزاء من الثانية +منذ جزئين من الثانية +منذ جزء من الثانية +٠ أجزاء من الثانية +جزء من الثانية بعد الآن +جزئين من الثانية بعد الآن +٣ أجزاء من الثانية بعد الآن +٥ أجزاء من الثانية بعد الآن +١٠ أجزاء من الثانية بعد الآن +١١ جزء من الثانية بعد الآن +١٢ جزء من الثانية بعد الآن +٢٠ جزء من الثانية بعد الآن +٢١ جزء من الثانية بعد الآن +٢٢ جزء من الثانية بعد الآن +٢٣ جزء من الثانية بعد الآن +٢٥ جزء من الثانية بعد الآن +=mediumFormTargets +٣ سنوات +٣ شهور +٣ أسابيع +٣ أيام +٣ ساعات +٣ دقائق +٣ ثواني +٣ أجزاء من الثانية +=shortFormTargets +٣ سنوات +٣ شهور +٣ أسابيع +٣ أيام +٣ ساعات +٣ دقائق +٣ ثواني +٣ أجزاء من الثانية +=customMinuteTargets +٥ دقائق +ساعة و٥ دقائق +١٠ دقائق +ساعة و١٠ دقائق +١٥ دقيقة +ساعة و١٥ دقيقة +٢٠ دقيقة +ساعة و٢٠ دقيقة +٢٥ دقيقة +ساعة و٢٥ دقيقة +٣٠ دقيقة +ساعة و٣٠ دقيقة +٣٥ دقيقة +ساعة و٣٥ دقيقة +٤٠ دقيقة +ساعة و٤٠ دقيقة +٤٥ دقيقة +ساعة و٤٥ دقيقة +٥٠ دقيقة +ساعة و٥٠ دقيقة +٥٥ دقيقة +ساعة و٥٥ دقيقة +=limitedUnitTargets +شهر +شهر وأسبوعين +شهر، وأسبوعين، و٣ أيام +منذ شهر +منذ شهر وأسبوعين +منذ شهر، وأسبوعين، و٣ أيام +شهر بعد الآن +شهر وأسبوعين بعد الآن +شهر، وأسبوعين، و٣ أيام بعد الآن +أقل من شهر +أقل من شهر وأسبوعين +أقل من شهر، وأسبوعين، و٣ أيام +منذ أقل من شهر +منذ أقل من شهر وأسبوعين +منذ أقل من شهر، وأسبوعين، و٣ أيام +أقل من شهر بعد الآن +أقل من شهر وأسبوعين بعد الآن +أقل من شهر، وأسبوعين، و٣ أيام بعد الآن +أكثر من شهر +أكثر من شهر وأسبوعين +أكثر من شهر، وأسبوعين، و٣ أيام +منذ أكثر من شهر +منذ أكثر من شهر وأسبوعين +منذ أكثر من شهر، وأسبوعين، و٣ أيام +أكثر من شهر بعد الآن +أكثر من شهر وأسبوعين بعد الآن +أكثر من شهر، وأسبوعين، و٣ أيام بعد الآن +ساعة +ساعة ودقيقتين +ساعة، ودقيقتين، و٣ ثواني +منذ ساعة +منذ ساعة ودقيقتين +منذ ساعة، ودقيقتين، و٣ ثواني +ساعة بعد الآن +ساعة ودقيقتين بعد الآن +ساعة، ودقيقتين، و٣ ثواني بعد الآن +أقل من ساعة +أقل من ساعة ودقيقتين +أقل من ساعة، ودقيقتين، و٣ ثواني +منذ أقل من ساعة +منذ أقل من ساعة ودقيقتين +منذ أقل من ساعة، ودقيقتين، و٣ ثواني +أقل من ساعة بعد الآن +أقل من ساعة ودقيقتين بعد الآن +أقل من ساعة، ودقيقتين، و٣ ثواني بعد الآن +أكثر من ساعة +أكثر من ساعة ودقيقتين +أكثر من ساعة، ودقيقتين، و٣ ثواني +منذ أكثر من ساعة +منذ أكثر من ساعة ودقيقتين +منذ أكثر من ساعة، ودقيقتين، و٣ ثواني +أكثر من ساعة بعد الآن +أكثر من ساعة ودقيقتين بعد الآن +أكثر من ساعة، ودقيقتين، و٣ ثواني بعد الآن +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +نصف سنة +سنة ونصف +سنتين ونصف +٥ سنوات ونصف +١٠ سنوات ونصف +١١ سنة ونصف +١٢ سنة ونصف +٢٠ سنة ونصف +٢١ سنة ونصف +٢٢ سنة ونصف +نصف شهر +شهر ونصف +شهرين ونصف +٥ شهور ونصف +١٠ شهور ونصف +١١ شهر ونصف +١٢ شهر ونصف +٢٠ شهر ونصف +٢١ شهر ونصف +٢٢ شهر ونصف +نصف أسبوع +أسبوع ونصف +أسبوعين ونصف +٥ أسابيع ونصف +١٠ أسابيع ونصف +١١ أسبوع ونصف +١٢ أسبوع ونصف +٢٠ أسبوع ونصف +٢١ أسبوع ونصف +٢٢ أسبوع ونصف +نصف يوم +يوم ونصف +يومين ونصف +٥ أيام ونصف +١٠ أيام ونصف +١١ يوم ونصف +١٢ يوم ونصف +٢٠ يوم ونصف +٢١ يوم ونصف +٢٢ يوم ونصف +نصف ساعة +ساعة ونصف +ساعتين ونصف +٥ ساعات ونصف +١٠ ساعات ونصف +١١ ساعة ونصف +١٢ ساعة ونصف +٢٠ ساعة ونصف +٢١ ساعة ونصف +٢٢ ساعة ونصف +نصف دقيقة +دقيقة ونصف +دقيقتين ونصف +٥ دقائق ونصف +١٠ دقائق ونصف +١١ دقيقة ونصف +١٢ دقيقة ونصف +٢٠ دقيقة ونصف +٢١ دقيقة ونصف +٢٢ دقيقة ونصف +نصف ثانية +ثانية ونصف +ثانيتين ونصف +٥ ثواني ونصف +١٠ ثواني ونصف +١١ ثانية ونصف +١٢ ثانية ونصف +٢٠ ثانية ونصف +٢١ ثانية ونصف +٢٢ ثانية ونصف +نصف جزء من الثانية +جزء من الثانية ونصف +جزئين من الثانية ونصف +٥ أجزاء من الثانية ونصف +١٠ أجزاء من الثانية ونصف +١١ جزء من الثانية ونصف +١٢ جزء من الثانية ونصف +٢٠ جزء من الثانية ونصف +٢١ جزء من الثانية ونصف +٢٢ جزء من الثانية ونصف +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +٠٫٠٢ سنة +١٫٠٠ سنة +١٫٢٠ سنة +٢٫١٢ سنة +١٢٫٠٥ سنة +٠٫٠٢ شهر +١٫٠٠ شهر +١٫٢٠ شهر +٢٫١٢ شهر +١٢٫٠٥ شهر +٠٫٠٢ أسبوع +١٫٠٠ أسبوع +١٫٢٠ أسبوع +٢٫١٢ أسبوع +١٢٫٠٥ أسبوع +٠٫٠٢ يوم +١٫٠٠ يوم +١٫٢٠ يوم +٢٫١٢ يوم +١٢٫٠٥ يوم +٠٫٠٢ ساعة +١٫٠٠ ساعة +١٫٢٠ ساعة +٢٫١٢ ساعة +١٢٫٠٥ ساعة +٠٫٠٢ دقيقة +١٫٠٠ دقيقة +١٫٢٠ دقيقة +٢٫١٢ دقيقة +١٢٫٠٥ دقيقة +٠٫٠٢ ثانية +١٫٠٠ ثانية +١٫٢٠ ثانية +٢٫١٢ ثانية +١٢٫٠٥ ثانية +٠٫٠٢ جزء من الثانية +١٫٠٠ جزء من الثانية +١٫٢٠ جزء من الثانية +٢٫١٢ جزء من الثانية +١٢٫٠٥ جزء من الثانية +=multipleUnitTargets +سنة وشهرين +سنة و٣ أسابيع +سنة، وشهرين، و٣ أسابيع +شهر وأسبوعين +شهر و٣ أيام +شهر، وأسبوعين، و٣ أيام +أسبوع ويومين +أسبوع و٣ ساعات +أسبوع، ويومين، و٣ ساعات +يوم وساعتين +يوم و٣ دقائق +يوم، وساعتين، و٣ دقائق +ساعة ودقيقتين +ساعة و٣ ثواني +ساعة، ودقيقتين، و٣ ثواني +دقيقة وثانيتين +دقيقة و٣ أجزاء من الثانية +دقيقة، وثانيتين، و٣ أجزاء من الثانية +ثانية وجزئين من الثانية diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_en.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_en.txt new file mode 100644 index 00000000000..4d5a1d857ae --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_en.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +3 years ago +2 years ago +1 year ago +0 years +1 year from now +2 years from now +3 years from now +5 years from now +10 years from now +11 years from now +12 years from now +20 years from now +21 years from now +22 years from now +23 years from now +25 years from now +3 months ago +2 months ago +1 month ago +0 months +1 month from now +2 months from now +3 months from now +5 months from now +10 months from now +11 months from now +12 months from now +20 months from now +21 months from now +22 months from now +23 months from now +25 months from now +3 weeks ago +2 weeks ago +1 week ago +0 weeks +1 week from now +2 weeks from now +3 weeks from now +5 weeks from now +10 weeks from now +11 weeks from now +12 weeks from now +20 weeks from now +21 weeks from now +22 weeks from now +23 weeks from now +25 weeks from now +3 days ago +2 days ago +1 day ago +0 days +1 day from now +2 days from now +3 days from now +5 days from now +10 days from now +11 days from now +12 days from now +20 days from now +21 days from now +22 days from now +23 days from now +25 days from now +3 hours ago +2 hours ago +1 hour ago +0 hours +1 hour from now +2 hours from now +3 hours from now +5 hours from now +10 hours from now +11 hours from now +12 hours from now +20 hours from now +21 hours from now +22 hours from now +23 hours from now +25 hours from now +3 minutes ago +2 minutes ago +1 minute ago +0 minutes +1 minute from now +2 minutes from now +3 minutes from now +5 minutes from now +10 minutes from now +11 minutes from now +12 minutes from now +20 minutes from now +21 minutes from now +22 minutes from now +23 minutes from now +25 minutes from now +3 seconds ago +2 seconds ago +1 second ago +0 seconds +1 second from now +2 seconds from now +3 seconds from now +5 seconds from now +10 seconds from now +11 seconds from now +12 seconds from now +20 seconds from now +21 seconds from now +22 seconds from now +23 seconds from now +25 seconds from now +3 milliseconds ago +2 milliseconds ago +1 millisecond ago +0 milliseconds +1 millisecond from now +2 milliseconds from now +3 milliseconds from now +5 milliseconds from now +10 milliseconds from now +11 milliseconds from now +12 milliseconds from now +20 milliseconds from now +21 milliseconds from now +22 milliseconds from now +23 milliseconds from now +25 milliseconds from now +=mediumFormTargets +3 yr +3 mnth +3 wk +3 dy +3 hr +3 min +3 sec +3 ms +=shortFormTargets +3 y +3 m +3 w +3 d +3 h +3 m +3 s +3 x +=customMinuteTargets +5 minutes +1 hour and 5 minutes +10 minutes +1 hour and 10 minutes +15 minutes +1 hour and 15 minutes +20 minutes +1 hour and 20 minutes +25 minutes +1 hour and 25 minutes +30 minutes +1 hour and 30 minutes +35 minutes +1 hour and 35 minutes +40 minutes +1 hour and 40 minutes +45 minutes +1 hour and 45 minutes +50 minutes +1 hour and 50 minutes +55 minutes +1 hour and 55 minutes +=limitedUnitTargets +1 month +1 month and 2 weeks +1 month, 2 weeks, and 3 days +1 month ago +1 month and 2 weeks ago +1 month, 2 weeks, and 3 days ago +1 month from now +1 month and 2 weeks from now +1 month, 2 weeks, and 3 days from now +less than 1 month +less than 1 month and 2 weeks +less than 1 month, 2 weeks, and 3 days +less than 1 month ago +less than 1 month and 2 weeks ago +less than 1 month, 2 weeks, and 3 days ago +less than 1 month from now +less than 1 month and 2 weeks from now +less than 1 month, 2 weeks, and 3 days from now +more than 1 month +more than 1 month and 2 weeks +more than 1 month, 2 weeks, and 3 days +more than 1 month ago +more than 1 month and 2 weeks ago +more than 1 month, 2 weeks, and 3 days ago +more than 1 month from now +more than 1 month and 2 weeks from now +more than 1 month, 2 weeks, and 3 days from now +1 hour +1 hour and 2 minutes +1 hour, 2 minutes, and 3 seconds +1 hour ago +1 hour and 2 minutes ago +1 hour, 2 minutes, and 3 seconds ago +1 hour from now +1 hour and 2 minutes from now +1 hour, 2 minutes, and 3 seconds from now +less than 1 hour +less than 1 hour and 2 minutes +less than 1 hour, 2 minutes, and 3 seconds +less than 1 hour ago +less than 1 hour and 2 minutes ago +less than 1 hour, 2 minutes, and 3 seconds ago +less than 1 hour from now +less than 1 hour and 2 minutes from now +less than 1 hour, 2 minutes, and 3 seconds from now +more than 1 hour +more than 1 hour and 2 minutes +more than 1 hour, 2 minutes, and 3 seconds +more than 1 hour ago +more than 1 hour and 2 minutes ago +more than 1 hour, 2 minutes, and 3 seconds ago +more than 1 hour from now +more than 1 hour and 2 minutes from now +more than 1 hour, 2 minutes, and 3 seconds from now +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +½ year +1½ years +2½ years +5½ years +10½ years +11½ years +12½ years +20½ years +21½ years +22½ years +½ month +1½ months +2½ months +5½ months +10½ months +11½ months +12½ months +20½ months +21½ months +22½ months +½ week +1½ weeks +2½ weeks +5½ weeks +10½ weeks +11½ weeks +12½ weeks +20½ weeks +21½ weeks +22½ weeks +½ day +1½ days +2½ days +5½ days +10½ days +11½ days +12½ days +20½ days +21½ days +22½ days +½ hour +1½ hours +2½ hours +5½ hours +10½ hours +11½ hours +12½ hours +20½ hours +21½ hours +22½ hours +½ minute +1½ minutes +2½ minutes +5½ minutes +10½ minutes +11½ minutes +12½ minutes +20½ minutes +21½ minutes +22½ minutes +½ second +1½ seconds +2½ seconds +5½ seconds +10½ seconds +11½ seconds +12½ seconds +20½ seconds +21½ seconds +22½ seconds +½ millisecond +1½ milliseconds +2½ milliseconds +5½ milliseconds +10½ milliseconds +11½ milliseconds +12½ milliseconds +20½ milliseconds +21½ milliseconds +22½ milliseconds +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0.02 years +1.00 years +1.20 years +2.12 years +12.05 years +0.02 months +1.00 months +1.20 months +2.12 months +12.05 months +0.02 weeks +1.00 weeks +1.20 weeks +2.12 weeks +12.05 weeks +0.02 days +1.00 days +1.20 days +2.12 days +12.05 days +0.02 hours +1.00 hours +1.20 hours +2.12 hours +12.05 hours +0.02 minutes +1.00 minutes +1.20 minutes +2.12 minutes +12.05 minutes +0.02 seconds +1.00 seconds +1.20 seconds +2.12 seconds +12.05 seconds +0.02 milliseconds +1.00 milliseconds +1.20 milliseconds +2.12 milliseconds +12.05 milliseconds +=multipleUnitTargets +1 year and 2 months +1 year and 3 weeks +1 year, 2 months, and 3 weeks +1 month and 2 weeks +1 month and 3 days +1 month, 2 weeks, and 3 days +1 week and 2 days +1 week and 3 hours +1 week, 2 days, and 3 hours +1 day and 2 hours +1 day and 3 minutes +1 day, 2 hours, and 3 minutes +1 hour and 2 minutes +1 hour and 3 seconds +1 hour, 2 minutes, and 3 seconds +1 minute and 2 seconds +1 minute and 3 milliseconds +1 minute, 2 seconds, and 3 milliseconds +1 second and 2 milliseconds diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_es.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_es.txt new file mode 100644 index 00000000000..ff440fff0a3 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_es.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +hace 3 años +hace 2 años +hace un año +0 años +dentro de un año +dentro de 2 años +dentro de 3 años +dentro de 5 años +dentro de 10 años +dentro de 11 años +dentro de 12 años +dentro de 20 años +dentro de 21 años +dentro de 22 años +dentro de 23 años +dentro de 25 años +hace 3 meses +hace 2 meses +hace un mes +0 meses +dentro de un mes +dentro de 2 meses +dentro de 3 meses +dentro de 5 meses +dentro de 10 meses +dentro de 11 meses +dentro de 12 meses +dentro de 20 meses +dentro de 21 meses +dentro de 22 meses +dentro de 23 meses +dentro de 25 meses +hace 3 semanas +hace 2 semanas +hace una semana +0 semanas +dentro de una semana +dentro de 2 semanas +dentro de 3 semanas +dentro de 5 semanas +dentro de 10 semanas +dentro de 11 semanas +dentro de 12 semanas +dentro de 20 semanas +dentro de 21 semanas +dentro de 22 semanas +dentro de 23 semanas +dentro de 25 semanas +hace 3 días +hace 2 días +hace un día +0 días +dentro de un día +dentro de 2 días +dentro de 3 días +dentro de 5 días +dentro de 10 días +dentro de 11 días +dentro de 12 días +dentro de 20 días +dentro de 21 días +dentro de 22 días +dentro de 23 días +dentro de 25 días +hace 3 horas +hace 2 horas +hace una hora +0 horas +dentro de una hora +dentro de 2 horas +dentro de 3 horas +dentro de 5 horas +dentro de 10 horas +dentro de 11 horas +dentro de 12 horas +dentro de 20 horas +dentro de 21 horas +dentro de 22 horas +dentro de 23 horas +dentro de 25 horas +hace 3 minutos +hace 2 minutos +hace un minuto +0 minutos +dentro de un minuto +dentro de 2 minutos +dentro de 3 minutos +dentro de 5 minutos +dentro de 10 minutos +dentro de 11 minutos +dentro de 12 minutos +dentro de 20 minutos +dentro de 21 minutos +dentro de 22 minutos +dentro de 23 minutos +dentro de 25 minutos +hace 3 segundos +hace 2 segundos +hace un segundo +0 segundos +dentro de un segundo +dentro de 2 segundos +dentro de 3 segundos +dentro de 5 segundos +dentro de 10 segundos +dentro de 11 segundos +dentro de 12 segundos +dentro de 20 segundos +dentro de 21 segundos +dentro de 22 segundos +dentro de 23 segundos +dentro de 25 segundos +hace 3 milisegundos +hace 2 milisegundos +hace un milisegundo +0 milisegundos +dentro de un milisegundo +dentro de 2 milisegundos +dentro de 3 milisegundos +dentro de 5 milisegundos +dentro de 10 milisegundos +dentro de 11 milisegundos +dentro de 12 milisegundos +dentro de 20 milisegundos +dentro de 21 milisegundos +dentro de 22 milisegundos +dentro de 23 milisegundos +dentro de 25 milisegundos +=mediumFormTargets +3 a +3 m +3 s +3 d +3 hr +3 min +3 seg +3 mseg +=shortFormTargets +3 a +3 m +3 s +3 d +3 h +3 m +3 s +3 ms +=customMinuteTargets +5 minutos +una hora y 5 minutos +10 minutos +una hora y 10 minutos +15 minutos +una hora y 15 minutos +20 minutos +una hora y 20 minutos +25 minutos +una hora y 25 minutos +30 minutos +una hora y 30 minutos +35 minutos +una hora y 35 minutos +40 minutos +una hora y 40 minutos +45 minutos +una hora y 45 minutos +50 minutos +una hora y 50 minutos +55 minutos +una hora y 55 minutos +=limitedUnitTargets +un mes +un mes y 2 semanas +un mes, 2 semanas y 3 días +hace un mes +hace un mes y 2 semanas +hace un mes, 2 semanas y 3 días +dentro de un mes +dentro de un mes y 2 semanas +dentro de un mes, 2 semanas y 3 días +menos de un mes +menos de un mes y 2 semanas +menos de un mes, 2 semanas y 3 días +hace menos de un mes +hace menos de un mes y 2 semanas +hace menos de un mes, 2 semanas y 3 días +dentro de menos de un mes +dentro de menos de un mes y 2 semanas +dentro de menos de un mes, 2 semanas y 3 días +más de un mes +más de un mes y 2 semanas +más de un mes, 2 semanas y 3 días +hace más de un mes +hace más de un mes y 2 semanas +hace más de un mes, 2 semanas y 3 días +dentro más de un mes +dentro más de un mes y 2 semanas +dentro más de un mes, 2 semanas y 3 días +una hora +una hora y 2 minutos +una hora, 2 minutos y 3 segundos +hace una hora +hace una hora y 2 minutos +hace una hora, 2 minutos y 3 segundos +dentro de una hora +dentro de una hora y 2 minutos +dentro de una hora, 2 minutos y 3 segundos +menos de una hora +menos de una hora y 2 minutos +menos de una hora, 2 minutos y 3 segundos +hace menos de una hora +hace menos de una hora y 2 minutos +hace menos de una hora, 2 minutos y 3 segundos +dentro de menos de una hora +dentro de menos de una hora y 2 minutos +dentro de menos de una hora, 2 minutos y 3 segundos +más de una hora +más de una hora y 2 minutos +más de una hora, 2 minutos y 3 segundos +hace más de una hora +hace más de una hora y 2 minutos +hace más de una hora, 2 minutos y 3 segundos +dentro más de una hora +dentro más de una hora y 2 minutos +dentro más de una hora, 2 minutos y 3 segundos +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +medio año +un año y medio +2 años y medio +5 años y medio +10 años y medio +11 años y medio +12 años y medio +20 años y medio +21 años y medio +22 años y medio +medio mes +un mes y medio +2 meses y medio +5 meses y medio +10 meses y medio +11 meses y medio +12 meses y medio +20 meses y medio +21 meses y medio +22 meses y medio +media semana +una semana y media +2 semanas y media +5 semanas y media +10 semanas y media +11 semanas y media +12 semanas y media +20 semanas y media +21 semanas y media +22 semanas y media +medio día +un día y medio +2 días y medio +5 días y medio +10 días y medio +11 días y medio +12 días y medio +20 días y medio +21 días y medio +22 días y medio +media hora +una hora y media +2 horas y media +5 horas y media +10 horas y media +11 horas y media +12 horas y media +20 horas y media +21 horas y media +22 horas y media +medio minuto +un minuto y medio +2 minutos y medio +5 minutos y medio +10 minutos y medio +11 minutos y medio +12 minutos y medio +20 minutos y medio +21 minutos y medio +22 minutos y medio +medio segundo +un segundo y medio +2 segundos y medio +5 segundos y medio +10 segundos y medio +11 segundos y medio +12 segundos y medio +20 segundos y medio +21 segundos y medio +22 segundos y medio +medio milisegundo +un milisegundo y medio +2 milisegundos y medio +5 milisegundos y medio +10 milisegundos y medio +11 milisegundos y medio +12 milisegundos y medio +20 milisegundos y medio +21 milisegundos y medio +22 milisegundos y medio +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0,02 años +1,00 años +1,20 años +2,12 años +12,05 años +0,02 meses +1,00 meses +1,20 meses +2,12 meses +12,05 meses +0,02 semanas +1,00 semanas +1,20 semanas +2,12 semanas +12,05 semanas +0,02 días +1,00 días +1,20 días +2,12 días +12,05 días +0,02 horas +1,00 horas +1,20 horas +2,12 horas +12,05 horas +0,02 minutos +1,00 minutos +1,20 minutos +2,12 minutos +12,05 minutos +0,02 segundos +1,00 segundos +1,20 segundos +2,12 segundos +12,05 segundos +0,02 milisegundos +1,00 milisegundos +1,20 milisegundos +2,12 milisegundos +12,05 milisegundos +=multipleUnitTargets +un año y 2 meses +un año y 3 semanas +un año, 2 meses y 3 semanas +un mes y 2 semanas +un mes y 3 días +un mes, 2 semanas y 3 días +una semana y 2 días +una semana y 3 horas +una semana, 2 días y 3 horas +un día y 2 horas +un día y 3 minutos +un día, 2 horas y 3 minutos +una hora y 2 minutos +una hora y 3 segundos +una hora, 2 minutos y 3 segundos +un minuto y 2 segundos +un minuto y 3 milisegundos +un minuto, 2 segundos y 3 milisegundos +un segundo y 2 milisegundos diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_fr.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_fr.txt new file mode 100644 index 00000000000..d709b063f04 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_fr.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +il y a 3 ans +il y a 2 ans +il y a 1 an +0 an +dans 1 an +dans 2 ans +dans 3 ans +dans 5 ans +dans 10 ans +dans 11 ans +dans 12 ans +dans 20 ans +dans 21 ans +dans 22 ans +dans 23 ans +dans 25 ans +il y a 3 mois +il y a 2 mois +il y a 1 mois +0 mois +dans 1 mois +dans 2 mois +dans 3 mois +dans 5 mois +dans 10 mois +dans 11 mois +dans 12 mois +dans 20 mois +dans 21 mois +dans 22 mois +dans 23 mois +dans 25 mois +il y a 3 semaines +il y a 2 semaines +il y a 1 semaine +0 semaine +dans 1 semaine +dans 2 semaines +dans 3 semaines +dans 5 semaines +dans 10 semaines +dans 11 semaines +dans 12 semaines +dans 20 semaines +dans 21 semaines +dans 22 semaines +dans 23 semaines +dans 25 semaines +il y a 3 jours +il y a 2 jours +il y a 1 jour +0 jour +dans 1 jour +dans 2 jours +dans 3 jours +dans 5 jours +dans 10 jours +dans 11 jours +dans 12 jours +dans 20 jours +dans 21 jours +dans 22 jours +dans 23 jours +dans 25 jours +il y a 3 heures +il y a 2 heures +il y a 1 heure +0 heure +dans 1 heure +dans 2 heures +dans 3 heures +dans 5 heures +dans 10 heures +dans 11 heures +dans 12 heures +dans 20 heures +dans 21 heures +dans 22 heures +dans 23 heures +dans 25 heures +il y a 3 minutes +il y a 2 minutes +il y a 1 minute +0 minute +dans 1 minute +dans 2 minutes +dans 3 minutes +dans 5 minutes +dans 10 minutes +dans 11 minutes +dans 12 minutes +dans 20 minutes +dans 21 minutes +dans 22 minutes +dans 23 minutes +dans 25 minutes +il y a 3 secondes +il y a 2 secondes +il y a 1 seconde +0 seconde +dans 1 seconde +dans 2 secondes +dans 3 secondes +dans 5 secondes +dans 10 secondes +dans 11 secondes +dans 12 secondes +dans 20 secondes +dans 21 secondes +dans 22 secondes +dans 23 secondes +dans 25 secondes +il y a 3 millisecondes +il y a 2 millisecondes +il y a 1 milliseconde +0 milliseconde +dans 1 milliseconde +dans 2 millisecondes +dans 3 millisecondes +dans 5 millisecondes +dans 10 millisecondes +dans 11 millisecondes +dans 12 millisecondes +dans 20 millisecondes +dans 21 millisecondes +dans 22 millisecondes +dans 23 millisecondes +dans 25 millisecondes +=mediumFormTargets +3 ans +3 mois +3 semaines +3 jours +3 heures +3 minutes +3 secondes +3 millisecondes +=shortFormTargets +3 ans +3 mois +3 semaines +3 jours +3 heures +3 minutes +3 secondes +3 millisecondes +=customMinuteTargets +5 minutes +1 heure et 5 minutes +10 minutes +1 heure et 10 minutes +15 minutes +1 heure et 15 minutes +20 minutes +1 heure et 20 minutes +25 minutes +1 heure et 25 minutes +30 minutes +1 heure et 30 minutes +35 minutes +1 heure et 35 minutes +40 minutes +1 heure et 40 minutes +45 minutes +1 heure et 45 minutes +50 minutes +1 heure et 50 minutes +55 minutes +1 heure et 55 minutes +=limitedUnitTargets +1 mois +1 mois et 2 semaines +1 mois, 2 semaines et 3 jours +il y a 1 mois +il y a 1 mois et 2 semaines +il y a 1 mois, 2 semaines et 3 jours +dans 1 mois +dans 1 mois et 2 semaines +dans 1 mois, 2 semaines et 3 jours +moins de 1 mois +moins de 1 mois et 2 semaines +moins de 1 mois, 2 semaines et 3 jours +il y a moins de 1 mois +il y a moins de 1 mois et 2 semaines +il y a moins de 1 mois, 2 semaines et 3 jours +dans moins de 1 mois +dans moins de 1 mois et 2 semaines +dans moins de 1 mois, 2 semaines et 3 jours +plus de 1 mois +plus de 1 mois et 2 semaines +plus de 1 mois, 2 semaines et 3 jours +il y a plus de 1 mois +il y a plus de 1 mois et 2 semaines +il y a plus de 1 mois, 2 semaines et 3 jours +dans plus de 1 mois +dans plus de 1 mois et 2 semaines +dans plus de 1 mois, 2 semaines et 3 jours +1 heure +1 heure et 2 minutes +1 heure, 2 minutes et 3 secondes +il y a 1 heure +il y a 1 heure et 2 minutes +il y a 1 heure, 2 minutes et 3 secondes +dans 1 heure +dans 1 heure et 2 minutes +dans 1 heure, 2 minutes et 3 secondes +moins de 1 heure +moins de 1 heure et 2 minutes +moins de 1 heure, 2 minutes et 3 secondes +il y a moins de 1 heure +il y a moins de 1 heure et 2 minutes +il y a moins de 1 heure, 2 minutes et 3 secondes +dans moins de 1 heure +dans moins de 1 heure et 2 minutes +dans moins de 1 heure, 2 minutes et 3 secondes +plus de 1 heure +plus de 1 heure et 2 minutes +plus de 1 heure, 2 minutes et 3 secondes +il y a plus de 1 heure +il y a plus de 1 heure et 2 minutes +il y a plus de 1 heure, 2 minutes et 3 secondes +dans plus de 1 heure +dans plus de 1 heure et 2 minutes +dans plus de 1 heure, 2 minutes et 3 secondes +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +½ an +1½ ans +2½ ans +5½ ans +10½ ans +11½ ans +12½ ans +20½ ans +21½ ans +22½ ans +½ mois +1½ mois +2½ mois +5½ mois +10½ mois +11½ mois +12½ mois +20½ mois +21½ mois +22½ mois +½ semaine +1½ semaines +2½ semaines +5½ semaines +10½ semaines +11½ semaines +12½ semaines +20½ semaines +21½ semaines +22½ semaines +½ jour +1½ jours +2½ jours +5½ jours +10½ jours +11½ jours +12½ jours +20½ jours +21½ jours +22½ jours +½ heure +1½ heures +2½ heures +5½ heures +10½ heures +11½ heures +12½ heures +20½ heures +21½ heures +22½ heures +½ minute +1½ minutes +2½ minutes +5½ minutes +10½ minutes +11½ minutes +12½ minutes +20½ minutes +21½ minutes +22½ minutes +½ seconde +1½ secondes +2½ secondes +5½ secondes +10½ secondes +11½ secondes +12½ secondes +20½ secondes +21½ secondes +22½ secondes +½ milliseconde +1½ millisecondes +2½ millisecondes +5½ millisecondes +10½ millisecondes +11½ millisecondes +12½ millisecondes +20½ millisecondes +21½ millisecondes +22½ millisecondes +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0.02 ans +1.00 ans +1.20 ans +2.12 ans +12.05 ans +0.02 mois +1.00 mois +1.20 mois +2.12 mois +12.05 mois +0.02 semaines +1.00 semaines +1.20 semaines +2.12 semaines +12.05 semaines +0.02 jours +1.00 jours +1.20 jours +2.12 jours +12.05 jours +0.02 heures +1.00 heures +1.20 heures +2.12 heures +12.05 heures +0.02 minutes +1.00 minutes +1.20 minutes +2.12 minutes +12.05 minutes +0.02 secondes +1.00 secondes +1.20 secondes +2.12 secondes +12.05 secondes +0.02 millisecondes +1.00 millisecondes +1.20 millisecondes +2.12 millisecondes +12.05 millisecondes +=multipleUnitTargets +1 an et 2 mois +1 an et 3 semaines +1 an, 2 mois et 3 semaines +1 mois et 2 semaines +1 mois et 3 jours +1 mois, 2 semaines et 3 jours +1 semaine et 2 jours +1 semaine et 3 heures +1 semaine, 2 jours et 3 heures +1 jour et 2 heures +1 jour et 3 minutes +1 jour, 2 heures et 3 minutes +1 heure et 2 minutes +1 heure et 3 secondes +1 heure, 2 minutes et 3 secondes +1 minute et 2 secondes +1 minute et 3 millisecondes +1 minute, 2 secondes et 3 millisecondes +1 seconde et 2 millisecondes diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_he_IL.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_he_IL.txt new file mode 100644 index 00000000000..53997552106 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_he_IL.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +לפני 3 שנים +לפני שנתיים +לפני שנה +0 שנים +אחרי שנה +אחרי שנתיים +אחרי 3 שנים +אחרי 5 שנים +אחרי 10 שנים +אחרי 11 שנים +אחרי 12 שנה +אחרי 20 שנה +אחרי 21 שנה +אחרי 22 שנה +אחרי 23 שנה +אחרי 25 שנה +לפני 3 חודשים +לפני חודשיים +לפני חודש +0 חודשים +אחרי חודש +אחרי חודשיים +אחרי 3 חודשים +אחרי 5 חודשים +אחרי 10 חודשים +אחרי 11 חודשים +אחרי 12 חודשים +אחרי 20 חודשים +אחרי 21 חודשים +אחרי 22 חודשים +אחרי 23 חודשים +אחרי 25 חודשים +לפני 3 שבועות +לפני שבועיים +לפני שבוע +0 שבועות +אחרי שבוע +אחרי שבועיים +אחרי 3 שבועות +אחרי 5 שבועות +אחרי 10 שבועות +אחרי 11 שבועות +אחרי 12 שבועות +אחרי 20 שבועות +אחרי 21 שבועות +אחרי 22 שבועות +אחרי 23 שבועות +אחרי 25 שבועות +לפני 3 ימים +לפני יומיים +לפני יום +0 ימים +אחרי יום +אחרי יומיים +אחרי 3 ימים +אחרי 5 ימים +אחרי 10 ימים +אחרי 11 ימים +אחרי 12 ימים +אחרי 20 ימים +אחרי 21 ימים +אחרי 22 ימים +אחרי 23 ימים +אחרי 25 ימים +לפני 3 שעות +לפני שעתיים +לפני שעה +0 שעות +אחרי שעה +אחרי שעתיים +אחרי 3 שעות +אחרי 5 שעות +אחרי 10 שעות +אחרי 11 שעות +אחרי 12 שעות +אחרי 20 שעות +אחרי 21 שעות +אחרי 22 שעות +אחרי 23 שעות +אחרי 25 שעות +לפני 3 דקות +לפני 2 דקות +לפני דקה +0 דקות +אחרי דקה +אחרי 2 דקות +אחרי 3 דקות +אחרי 5 דקות +אחרי 10 דקות +אחרי 11 דקות +אחרי 12 דקות +אחרי 20 דקות +אחרי 21 דקות +אחרי 22 דקות +אחרי 23 דקות +אחרי 25 דקות +לפני 3 שניות +לפני 2 שניות +לפני שנייה +0 שניות +אחרי שנייה +אחרי 2 שניות +אחרי 3 שניות +אחרי 5 שניות +אחרי 10 שניות +אחרי 11 שניות +אחרי 12 שניות +אחרי 20 שניות +אחרי 21 שניות +אחרי 22 שניות +אחרי 23 שניות +אחרי 25 שניות +לפני 3 מילישניות +לפני 2 מילישניות +לפני מילישניה +0 מילישניות +אחרי מילישניה +אחרי 2 מילישניות +אחרי 3 מילישניות +אחרי 5 מילישניות +אחרי 10 מילישניות +אחרי 11 מילישניות +אחרי 12 מילישניות +אחרי 20 מילישניות +אחרי 21 מילישניות +אחרי 22 מילישניות +אחרי 23 מילישניות +אחרי 25 מילישניות +=mediumFormTargets +3 שנים +3 חודשים +3 שבועות +3 ימים +3 שעות +3 דקות +3 שניות +3 מילישניות +=shortFormTargets +3 שנים +3 חודשים +3 שבועות +3 ימים +3 שעות +3 דקות +3 שניות +3 מילישניות +=customMinuteTargets +5 דקות +שעה ו־5 דקות +10 דקות +שעה ו־10 דקות +15 דקות +שעה ו־15 דקות +20 דקות +שעה ו־20 דקות +25 דקות +שעה ו־25 דקות +30 דקות +שעה ו־30 דקות +35 דקות +שעה ו־35 דקות +40 דקות +שעה ו־40 דקות +45 דקות +שעה ו־45 דקות +50 דקות +שעה ו־50 דקות +55 דקות +שעה ו־55 דקות +=limitedUnitTargets +חודש +חודש ושבועיים +חודש, שבועיים ו־3 ימים +לפני חודש +לפני חודש ושבועיים +לפני חודש, שבועיים ו־3 ימים +אחרי חודש +אחרי חודש ושבועיים +אחרי חודש, שבועיים ו־3 ימים +יותר מחודש +יותר מחודש ושבועיים +יותר מחודש, שבועיים ו־3 ימים +לפני יותר מחודש +לפני יותר מחודש ושבועיים +לפני יותר מחודש, שבועיים ו־3 ימים +אחרי יותר מחודש +אחרי יותר מחודש ושבועיים +אחרי יותר מחודש, שבועיים ו־3 ימים +פחות מחודש +פחות מחודש ושבועיים +פחות מחודש, שבועיים ו־3 ימים +לפני פחות מחודש +לפני פחות מחודש ושבועיים +לפני פחות מחודש, שבועיים ו־3 ימים +אחרי פחות מחודש +אחרי פחות מחודש ושבועיים +אחרי פחות מחודש, שבועיים ו־3 ימים +שעה +שעה ו־2 דקות +שעה, 2 דקות ו־3 שניות +לפני שעה +לפני שעה ו־2 דקות +לפני שעה, 2 דקות ו־3 שניות +אחרי שעה +אחרי שעה ו־2 דקות +אחרי שעה, 2 דקות ו־3 שניות +יותר משעה +יותר משעה ו־2 דקות +יותר משעה, 2 דקות ו־3 שניות +לפני יותר משעה +לפני יותר משעה ו־2 דקות +לפני יותר משעה, 2 דקות ו־3 שניות +אחרי יותר משעה +אחרי יותר משעה ו־2 דקות +אחרי יותר משעה, 2 דקות ו־3 שניות +פחות משעה +פחות משעה ו־2 דקות +פחות משעה, 2 דקות ו־3 שניות +לפני פחות משעה +לפני פחות משעה ו־2 דקות +לפני פחות משעה, 2 דקות ו־3 שניות +אחרי פחות משעה +אחרי פחות משעה ו־2 דקות +אחרי פחות משעה, 2 דקות ו־3 שניות +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +½ שנה +½שנה +½שנתיים +5½ שנים +10½ שנים +11½ שנים +12½ שנה +20½ שנה +21½ שנה +22½ שנה +½ חודש +½חודש +½חודשיים +5½ חודשים +10½ חודשים +11½ חודשים +12½ חודשים +20½ חודשים +21½ חודשים +22½ חודשים +½ שבוע +½שבוע +½שבועיים +5½ שבועות +10½ שבועות +11½ שבועות +12½ שבועות +20½ שבועות +21½ שבועות +22½ שבועות +½ יום +½יום +½יומיים +5½ ימים +10½ ימים +11½ ימים +12½ ימים +20½ ימים +21½ ימים +22½ ימים +½ שעה +½שעה +½שעתיים +5½ שעות +10½ שעות +11½ שעות +12½ שעות +20½ שעות +21½ שעות +22½ שעות +½ דקה +½דקה +2½ דקות +5½ דקות +10½ דקות +11½ דקות +12½ דקות +20½ דקות +21½ דקות +22½ דקות +½ שנייה +½שנייה +2½ שניות +5½ שניות +10½ שניות +11½ שניות +12½ שניות +20½ שניות +21½ שניות +22½ שניות +½ מילישניה +½מילישניה +2½ מילישניות +5½ מילישניות +10½ מילישניות +11½ מילישניות +12½ מילישניות +20½ מילישניות +21½ מילישניות +22½ מילישניות +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0.02 שנה +1.00 שנים +1.20 שנים +2.12 שנים +12.05 שנים +0.02 חודש +1.00 חודשים +1.20 חודשים +2.12 חודשים +12.05 חודשים +0.02 שבוע +1.00 שבועות +1.20 שבועות +2.12 שבועות +12.05 שבועות +0.02 יום +1.00 ימים +1.20 ימים +2.12 ימים +12.05 ימים +0.02 שעה +1.00 שעות +1.20 שעות +2.12 שעות +12.05 שעות +0.02 דקה +1.00 דקות +1.20 דקות +2.12 דקות +12.05 דקות +0.02 שנייה +1.00 שניות +1.20 שניות +2.12 שניות +12.05 שניות +0.02 מילישניה +1.00 מילישניות +1.20 מילישניות +2.12 מילישניות +12.05 מילישניות +=multipleUnitTargets +שנה וחודשיים +שנה ו־3 שבועות +שנה, חודשיים ו־3 שבועות +חודש ושבועיים +חודש ו־3 ימים +חודש, שבועיים ו־3 ימים +שבוע ויומיים +שבוע ו־3 שעות +שבוע, יומיים ו־3 שעות +יום ושעתיים +יום ו־3 דקות +יום, שעתיים ו־3 דקות +שעה ו־2 דקות +שעה ו־3 שניות +שעה, 2 דקות ו־3 שניות +דקה ו־2 שניות +דקה ו־3 מילישניות +דקה, 2 שניות ו־3 מילישניות +שנייה ו־2 מילישניות diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_hi.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_hi.txt new file mode 100644 index 00000000000..0ac766697fb --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_hi.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +३ साल पहले +२ साल पहले +१ साल पहले +० साल +अभी से १ साल बाद +अभी से २ साल बाद +अभी से ३ साल बाद +अभी से ५ साल बाद +अभी से १० साल बाद +अभी से ११ साल बाद +अभी से १२ साल बाद +अभी से २० साल बाद +अभी से २१ साल बाद +अभी से २२ साल बाद +अभी से २३ साल बाद +अभी से २५ साल बाद +३ महीने पहले +२ महीने पहले +१ महीना पहले +० महीने +अभी से १ महीना बाद +अभी से २ महीने बाद +अभी से ३ महीने बाद +अभी से ५ महीने बाद +अभी से १० महीने बाद +अभी से ११ महीने बाद +अभी से १२ महीने बाद +अभी से २० महीने बाद +अभी से २१ महीने बाद +अभी से २२ महीने बाद +अभी से २३ महीने बाद +अभी से २५ महीने बाद +३ सप्ताह पहले +२ सप्ताह पहले +१ सप्ताह पहले +० सप्ताह +अभी से १ सप्ताह बाद +अभी से २ सप्ताह बाद +अभी से ३ सप्ताह बाद +अभी से ५ सप्ताह बाद +अभी से १० सप्ताह बाद +अभी से ११ सप्ताह बाद +अभी से १२ सप्ताह बाद +अभी से २० सप्ताह बाद +अभी से २१ सप्ताह बाद +अभी से २२ सप्ताह बाद +अभी से २३ सप्ताह बाद +अभी से २५ सप्ताह बाद +३ दिन पहले +२ दिन पहले +१ दिन पहले +० दिन +अभी से १ दिन बाद +अभी से २ दिन बाद +अभी से ३ दिन बाद +अभी से ५ दिन बाद +अभी से १० दिन बाद +अभी से ११ दिन बाद +अभी से १२ दिन बाद +अभी से २० दिन बाद +अभी से २१ दिन बाद +अभी से २२ दिन बाद +अभी से २३ दिन बाद +अभी से २५ दिन बाद +३ घंटे पहले +२ घंटे पहले +१ घंटा पहले +० घंटे +अभी से १ घंटा बाद +अभी से २ घंटे बाद +अभी से ३ घंटे बाद +अभी से ५ घंटे बाद +अभी से १० घंटे बाद +अभी से ११ घंटे बाद +अभी से १२ घंटे बाद +अभी से २० घंटे बाद +अभी से २१ घंटे बाद +अभी से २२ घंटे बाद +अभी से २३ घंटे बाद +अभी से २५ घंटे बाद +३ मिनट पहले +२ मिनट पहले +१ मिनट पहले +० मिनट +अभी से १ मिनट बाद +अभी से २ मिनट बाद +अभी से ३ मिनट बाद +अभी से ५ मिनट बाद +अभी से १० मिनट बाद +अभी से ११ मिनट बाद +अभी से १२ मिनट बाद +अभी से २० मिनट बाद +अभी से २१ मिनट बाद +अभी से २२ मिनट बाद +अभी से २३ मिनट बाद +अभी से २५ मिनट बाद +३ सेकण्ड पहले +२ सेकण्ड पहले +१ सेकण्ड पहले +० सेकण्ड +अभी से १ सेकण्ड बाद +अभी से २ सेकण्ड बाद +अभी से ३ सेकण्ड बाद +अभी से ५ सेकण्ड बाद +अभी से १० सेकण्ड बाद +अभी से ११ सेकण्ड बाद +अभी से १२ सेकण्ड बाद +अभी से २० सेकण्ड बाद +अभी से २१ सेकण्ड बाद +अभी से २२ सेकण्ड बाद +अभी से २३ सेकण्ड बाद +अभी से २५ सेकण्ड बाद +३ मिली सेकण्ड पहले +२ मिली सेकण्ड पहले +१ मिली सेकण्ड पहले +० मिली सेकण्ड +अभी से १ मिली सेकण्ड बाद +अभी से २ मिली सेकण्ड बाद +अभी से ३ मिली सेकण्ड बाद +अभी से ५ मिली सेकण्ड बाद +अभी से १० मिली सेकण्ड बाद +अभी से ११ मिली सेकण्ड बाद +अभी से १२ मिली सेकण्ड बाद +अभी से २० मिली सेकण्ड बाद +अभी से २१ मिली सेकण्ड बाद +अभी से २२ मिली सेकण्ड बाद +अभी से २३ मिली सेकण्ड बाद +अभी से २५ मिली सेकण्ड बाद +=mediumFormTargets +३ साल +३ महीने +३ सप्ताह +३ दिन +३ घंटे +३ मिनट +३ सेकण्ड +३ मिली सेकण्ड +=shortFormTargets +३ साल +३ महीने +३ सप्ताह +३ दिन +३ घंटे +३ मिनट +३ सेकण्ड +३ मिली सेकण्ड +=customMinuteTargets +५ मिनट +१ घंटा और ५ मिनट +१० मिनट +१ घंटा और १० मिनट +१५ मिनट +१ घंटा और १५ मिनट +२० मिनट +१ घंटा और २० मिनट +२५ मिनट +१ घंटा और २५ मिनट +३० मिनट +१ घंटा और ३० मिनट +३५ मिनट +१ घंटा और ३५ मिनट +४० मिनट +१ घंटा और ४० मिनट +४५ मिनट +१ घंटा और ४५ मिनट +५० मिनट +१ घंटा और ५० मिनट +५५ मिनट +१ घंटा और ५५ मिनट +=limitedUnitTargets +१ महीना +१ महीना और २ सप्ताह +१ महीना, २ सप्ताह और ३ दिन +१ महीना पहले +१ महीना और २ सप्ताह पहले +१ महीना, २ सप्ताह और ३ दिन पहले +अभी से १ महीना बाद +अभी से १ महीना और २ सप्ताह बाद +अभी से १ महीना, २ सप्ताह और ३ दिन बाद +१ महीना से कम +१ महीना और २ सप्ताह से कम +१ महीना, २ सप्ताह और ३ दिन से कम +१ महीना से कम पहले +१ महीना और २ सप्ताह से कम पहले +१ महीना, २ सप्ताह और ३ दिन से कम पहले +१ महीना से कम from now +१ महीना और २ सप्ताह से कम from now +१ महीना, २ सप्ताह और ३ दिन से कम from now +१ महीना से ज़्यादा +१ महीना और २ सप्ताह से ज़्यादा +१ महीना, २ सप्ताह और ३ दिन से ज़्यादा +१ महीना से ज़्यादा ago +१ महीना और २ सप्ताह से ज़्यादा ago +१ महीना, २ सप्ताह और ३ दिन से ज़्यादा ago +१ महीना से ज़्यादा from now +१ महीना और २ सप्ताह से ज़्यादा from now +१ महीना, २ सप्ताह और ३ दिन से ज़्यादा from now +१ घंटा +१ घंटा और २ मिनट +१ घंटा, २ मिनट और ३ सेकण्ड +१ घंटा पहले +१ घंटा और २ मिनट पहले +१ घंटा, २ मिनट और ३ सेकण्ड पहले +अभी से १ घंटा बाद +अभी से १ घंटा और २ मिनट बाद +अभी से १ घंटा, २ मिनट और ३ सेकण्ड बाद +१ घंटा से कम +१ घंटा और २ मिनट से कम +१ घंटा, २ मिनट और ३ सेकण्ड से कम +१ घंटा से कम पहले +१ घंटा और २ मिनट से कम पहले +१ घंटा, २ मिनट और ३ सेकण्ड से कम पहले +१ घंटा से कम from now +१ घंटा और २ मिनट से कम from now +१ घंटा, २ मिनट और ३ सेकण्ड से कम from now +१ घंटा से ज़्यादा +१ घंटा और २ मिनट से ज़्यादा +१ घंटा, २ मिनट और ३ सेकण्ड से ज़्यादा +१ घंटा से ज़्यादा ago +१ घंटा और २ मिनट से ज़्यादा ago +१ घंटा, २ मिनट और ३ सेकण्ड से ज़्यादा ago +१ घंटा से ज़्यादा from now +१ घंटा और २ मिनट से ज़्यादा from now +१ घंटा, २ मिनट और ३ सेकण्ड से ज़्यादा from now +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +½ साल +१½ साल +२½ साल +५½ साल +१०½ साल +११½ साल +१२½ साल +२०½ साल +२१½ साल +२२½ साल +½ महीने +१½ महीने +२½ महीने +५½ महीने +१०½ महीने +११½ महीने +१२½ महीने +२०½ महीने +२१½ महीने +२२½ महीने +½ सप्ताह +१½ सप्ताह +२½ सप्ताह +५½ सप्ताह +१०½ सप्ताह +११½ सप्ताह +१२½ सप्ताह +२०½ सप्ताह +२१½ सप्ताह +२२½ सप्ताह +½ दिन +१½ दिन +२½ दिन +५½ दिन +१०½ दिन +११½ दिन +१२½ दिन +२०½ दिन +२१½ दिन +२२½ दिन +½ घंटे +१½ घंटे +२½ घंटे +५½ घंटे +१०½ घंटे +११½ घंटे +१२½ घंटे +२०½ घंटे +२१½ घंटे +२२½ घंटे +½ मिनट +१½ मिनट +२½ मिनट +५½ मिनट +१०½ मिनट +११½ मिनट +१२½ मिनट +२०½ मिनट +२१½ मिनट +२२½ मिनट +½ सेकण्ड +१½ सेकण्ड +२½ सेकण्ड +५½ सेकण्ड +१०½ सेकण्ड +११½ सेकण्ड +१२½ सेकण्ड +२०½ सेकण्ड +२१½ सेकण्ड +२२½ सेकण्ड +½ मिली सेकण्ड +१½ मिली सेकण्ड +२½ मिली सेकण्ड +५½ मिली सेकण्ड +१०½ मिली सेकण्ड +११½ मिली सेकण्ड +१२½ मिली सेकण्ड +२०½ मिली सेकण्ड +२१½ मिली सेकण्ड +२२½ मिली सेकण्ड +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +०.०२ साल +१.०० साल +१.२० साल +२.१२ साल +१२.०५ साल +०.०२ महीने +१.०० महीने +१.२० महीने +२.१२ महीने +१२.०५ महीने +०.०२ सप्ताह +१.०० सप्ताह +१.२० सप्ताह +२.१२ सप्ताह +१२.०५ सप्ताह +०.०२ दिन +१.०० दिन +१.२० दिन +२.१२ दिन +१२.०५ दिन +०.०२ घंटे +१.०० घंटे +१.२० घंटे +२.१२ घंटे +१२.०५ घंटे +०.०२ मिनट +१.०० मिनट +१.२० मिनट +२.१२ मिनट +१२.०५ मिनट +०.०२ सेकण्ड +१.०० सेकण्ड +१.२० सेकण्ड +२.१२ सेकण्ड +१२.०५ सेकण्ड +०.०२ मिली सेकण्ड +१.०० मिली सेकण्ड +१.२० मिली सेकण्ड +२.१२ मिली सेकण्ड +१२.०५ मिली सेकण्ड +=multipleUnitTargets +१ साल और २ महीने +१ साल और ३ सप्ताह +१ साल, २ महीने और ३ सप्ताह +१ महीना और २ सप्ताह +१ महीना और ३ दिन +१ महीना, २ सप्ताह और ३ दिन +१ सप्ताह और २ दिन +१ सप्ताह और ३ घंटे +१ सप्ताह, २ दिन और ३ घंटे +१ दिन और २ घंटे +१ दिन और ३ मिनट +१ दिन, २ घंटे और ३ मिनट +१ घंटा और २ मिनट +१ घंटा और ३ सेकण्ड +१ घंटा, २ मिनट और ३ सेकण्ड +१ मिनट और २ सेकण्ड +१ मिनट और ३ मिली सेकण्ड +१ मिनट, २ सेकण्ड और ३ मिली सेकण्ड +१ सेकण्ड और २ मिली सेकण्ड diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_it.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_it.txt new file mode 100644 index 00000000000..a705acb9197 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_it.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +tre anni fa +due anni fa +un anno fa +zero anni +fra un anno +fra due anni +fra tre anni +fra cinque anni +fra dieci anni +fra 11 anni +fra 12 anni +fra 20 anni +fra 21 anni +fra 22 anni +fra 23 anni +fra 25 anni +tre mesi fa +due mesi fa +un mese fa +zero mesi +fra un mese +fra due mesi +fra tre mesi +fra cinque mesi +fra dieci mesi +fra 11 mesi +fra 12 mesi +fra 20 mesi +fra 21 mesi +fra 22 mesi +fra 23 mesi +fra 25 mesi +tre settimane fa +due settimane fa +una settimana fa +zero settimane +fra una settimana +fra due settimane +fra tre settimane +fra cinque settimane +fra dieci settimane +fra 11 settimane +fra 12 settimane +fra 20 settimane +fra 21 settimane +fra 22 settimane +fra 23 settimane +fra 25 settimane +tre giorni fa +due giorni fa +un giorno fa +zero giorni +fra un giorno +fra due giorni +fra tre giorni +fra cinque giorni +fra dieci giorni +fra 11 giorni +fra 12 giorni +fra 20 giorni +fra 21 giorni +fra 22 giorni +fra 23 giorni +fra 25 giorni +tre ore fa +due ore fa +un'ora fa +zero ore +fra un'ora +fra due ore +fra tre ore +fra cinque ore +fra dieci ore +fra 11 ore +fra 12 ore +fra 20 ore +fra 21 ore +fra 22 ore +fra 23 ore +fra 25 ore +tre minuti fa +due minuti fa +un minuto fa +zero minuti +fra un minuto +fra due minuti +fra tre minuti +fra cinque minuti +fra dieci minuti +fra 11 minuti +fra 12 minuti +fra 20 minuti +fra 21 minuti +fra 22 minuti +fra 23 minuti +fra 25 minuti +tre secondi fa +due secondi fa +un secondo fa +zero secondi +fra un secondo +fra due secondi +fra tre secondi +fra cinque secondi +fra dieci secondi +fra 11 secondi +fra 12 secondi +fra 20 secondi +fra 21 secondi +fra 22 secondi +fra 23 secondi +fra 25 secondi +tre millisecondi fa +due millisecondi fa +un millisecondo fa +zero millisecondi +fra un millisecondo +fra due millisecondi +fra tre millisecondi +fra cinque millisecondi +fra dieci millisecondi +fra 11 millisecondi +fra 12 millisecondi +fra 20 millisecondi +fra 21 millisecondi +fra 22 millisecondi +fra 23 millisecondi +fra 25 millisecondi +=mediumFormTargets +tre ann. +tre mes. +tre sett. +tre gg. +tre or. +tre min. +tre sec. +tre msec. +=shortFormTargets +tre A +tre M +tre S +tre G +tre H +tre M +tre S +tre msec. +=customMinuteTargets +cinque minuti +un'ora e cinque minuti +dieci minuti +un'ora e dieci minuti +15 minuti +un'ora e 15 minuti +20 minuti +un'ora e 20 minuti +25 minuti +un'ora e 25 minuti +30 minuti +un'ora e 30 minuti +35 minuti +un'ora e 35 minuti +40 minuti +un'ora e 40 minuti +45 minuti +un'ora e 45 minuti +50 minuti +un'ora e 50 minuti +55 minuti +un'ora e 55 minuti +=limitedUnitTargets +un mese +un mese e due settimane +un mese, due settimane e tre giorni +un mese fa +un mese e due settimane fa +un mese, due settimane e tre giorni fa +fra un mese +fra un mese e due settimane +fra un mese, due settimane e tre giorni +meno di un mese +meno di un mese e due settimane +meno di un mese, due settimane e tre giorni +meno di un mese fa +meno di un mese e due settimane fa +meno di un mese, due settimane e tre giorni fa +fra meno di un mese +fra meno di un mese e due settimane +fra meno di un mese, due settimane e tre giorni +oltre un mese +oltre un mese e due settimane +oltre un mese, due settimane e tre giorni +oltre un mese fa +oltre un mese e due settimane fa +oltre un mese, due settimane e tre giorni fa +fra oltre un mese +fra oltre un mese e due settimane +fra oltre un mese, due settimane e tre giorni +un'ora +un'ora e due minuti +un'ora, due minuti e tre secondi +un'ora fa +un'ora e due minuti fa +un'ora, due minuti e tre secondi fa +fra un'ora +fra un'ora e due minuti +fra un'ora, due minuti e tre secondi +meno di un'ora +meno di un'ora e due minuti +meno di un'ora, due minuti e tre secondi +meno di un'ora fa +meno di un'ora e due minuti fa +meno di un'ora, due minuti e tre secondi fa +fra meno di un'ora +fra meno di un'ora e due minuti +fra meno di un'ora, due minuti e tre secondi +oltre un'ora +oltre un'ora e due minuti +oltre un'ora, due minuti e tre secondi +oltre un'ora fa +oltre un'ora e due minuti fa +oltre un'ora, due minuti e tre secondi fa +fra oltre un'ora +fra oltre un'ora e due minuti +fra oltre un'ora, due minuti e tre secondi +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +mezzo anno +un anno e mezzo +due anni e mezzo +cinque anni e mezzo +dieci anni e mezzo +11 anni e mezzo +12 anni e mezzo +20 anni e mezzo +21 anni e mezzo +22 anni e mezzo +mezzo mese +un mese e mezzo +due mesi e mezzo +cinque mesi e mezzo +dieci mesi e mezzo +11 mesi e mezzo +12 mesi e mezzo +20 mesi e mezzo +21 mesi e mezzo +22 mesi e mezzo +mezza settimana +una settimana e mezza +due settimane e mezza +cinque settimane e mezza +dieci settimane e mezza +11 settimane e mezza +12 settimane e mezza +20 settimane e mezza +21 settimane e mezza +22 settimane e mezza +mezzo giorno +un giorno e mezzo +due giorni e mezzo +cinque giorni e mezzo +dieci giorni e mezzo +11 giorni e mezzo +12 giorni e mezzo +20 giorni e mezzo +21 giorni e mezzo +22 giorni e mezzo +mezz'ora +un'ora e mezza +due ore e mezza +cinque ore e mezza +dieci ore e mezza +11 ore e mezza +12 ore e mezza +20 ore e mezza +21 ore e mezza +22 ore e mezza +mezzo minuto +un minuto e mezzo +due minuti e mezzo +cinque minuti e mezzo +dieci minuti e mezzo +11 minuti e mezzo +12 minuti e mezzo +20 minuti e mezzo +21 minuti e mezzo +22 minuti e mezzo +mezzo secondo +un secondo e mezzo +due secondi e mezzo +cinque secondi e mezzo +dieci secondi e mezzo +11 secondi e mezzo +12 secondi e mezzo +20 secondi e mezzo +21 secondi e mezzo +22 secondi e mezzo +mezzo millisecondo +un millisecondo e mezzo +due millisecondi e mezzo +cinque millisecondi e mezzo +dieci millisecondi e mezzo +11 millisecondi e mezzo +12 millisecondi e mezzo +20 millisecondi e mezzo +21 millisecondi e mezzo +22 millisecondi e mezzo +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0.02 anni +1.00 anni +1.20 anni +2.12 anni +12.05 anni +0.02 mesi +1.00 mesi +1.20 mesi +2.12 mesi +12.05 mesi +0.02 settimane +1.00 settimane +1.20 settimane +2.12 settimane +12.05 settimane +0.02 giorni +1.00 giorni +1.20 giorni +2.12 giorni +12.05 giorni +0.02 ore +1.00 ore +1.20 ore +2.12 ore +12.05 ore +0.02 minuti +1.00 minuti +1.20 minuti +2.12 minuti +12.05 minuti +0.02 secondi +1.00 secondi +1.20 secondi +2.12 secondi +12.05 secondi +0.02 millisecondi +1.00 millisecondi +1.20 millisecondi +2.12 millisecondi +12.05 millisecondi +=multipleUnitTargets +un anno e due mesi +un anno e tre settimane +un anno, due mesi e tre settimane +un mese e due settimane +un mese e tre giorni +un mese, due settimane e tre giorni +una settimana e due giorni +una settimana e tre ore +una settimana, due giorni e tre ore +un giorno e due ore +un giorno e tre minuti +un giorno, due ore e tre minuti +un'ora e due minuti +un'ora e tre secondi +un'ora, due minuti e tre secondi +un minuto e due secondi +un minuto e tre millisecondi +un minuto, due secondi e tre millisecondi +un secondo e due millisecondi diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ja.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ja.txt new file mode 100644 index 00000000000..ffa6d9bec2a --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ja.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +3年前 +2年前 +1年前 +null +今から1年後 +今から2年後 +今から3年後 +今から5年後 +今から10年後 +今から11年後 +今から12年後 +今から20年後 +今から21年後 +今から22年後 +今から23年後 +今から25年後 +3か月前 +2か月前 +1か月前 +null +今から1か月後 +今から2か月後 +今から3か月後 +今から5か月後 +今から10か月後 +今から11か月後 +今から12か月後 +今から20か月後 +今から21か月後 +今から22か月後 +今から23か月後 +今から25か月後 +3週間前 +2週間前 +1週間前 +null +今から1週間後 +今から2週間後 +今から3週間後 +今から5週間後 +今から10週間後 +今から11週間後 +今から12週間後 +今から20週間後 +今から21週間後 +今から22週間後 +今から23週間後 +今から25週間後 +3日前 +2日前 +1日前 +null +今から1日後 +今から2日後 +今から3日後 +今から5日後 +今から10日後 +今から11日後 +今から12日後 +今から20日後 +今から21日後 +今から22日後 +今から23日後 +今から25日後 +3時間前 +2時間前 +1時間前 +null +今から1時間後 +今から2時間後 +今から3時間後 +今から5時間後 +今から10時間後 +今から11時間後 +今から12時間後 +今から20時間後 +今から21時間後 +今から22時間後 +今から23時間後 +今から25時間後 +3分前 +2分前 +1分前 +null +今から1分後 +今から2分後 +今から3分後 +今から5分後 +今から10分後 +今から11分後 +今から12分後 +今から20分後 +今から21分後 +今から22分後 +今から23分後 +今から25分後 +3秒前 +2秒前 +1秒前 +null +今から1秒後 +今から2秒後 +今から3秒後 +今から5秒後 +今から10秒後 +今から11秒後 +今から12秒後 +今から20秒後 +今から21秒後 +今から22秒後 +今から23秒後 +今から25秒後 +3ミリ秒前 +2ミリ秒前 +1ミリ秒前 +null +今から1ミリ秒後 +今から2ミリ秒後 +今から3ミリ秒後 +今から5ミリ秒後 +今から10ミリ秒後 +今から11ミリ秒後 +今から12ミリ秒後 +今から20ミリ秒後 +今から21ミリ秒後 +今から22ミリ秒後 +今から23ミリ秒後 +今から25ミリ秒後 +=mediumFormTargets +3年 +3か月 +3週間 +3日 +3時間 +3分 +3秒 +3ミリ秒 +=shortFormTargets +3年 +3か月 +3週間 +3日 +3時間 +3分 +3秒 +3ミリ秒 +=customMinuteTargets +5分 +1時間5分 +10分 +1時間10分 +15分 +1時間15分 +20分 +1時間20分 +25分 +1時間25分 +30分 +1時間30分 +35分 +1時間35分 +40分 +1時間40分 +45分 +1時間45分 +50分 +1時間50分 +55分 +1時間55分 +=limitedUnitTargets +1か月 +1か月と2週間 +1か月2週間と3日 +1か月前 +1か月と2週間前 +1か月2週間と3日前 +今から1か月後 +今から1か月と2週間後 +今から1か月2週間と3日後 +1か月以内 +1か月と2週間以内 +1か月2週間と3日以内 +過去1か月以内 +過去1か月と2週間以内 +過去1か月2週間と3日以内 +今から1か月以内 +今から1か月と2週間以内 +今から1か月2週間と3日以内 +1か月以上 +1か月と2週間以上 +1か月2週間と3日以上 +1か月以上前 +1か月と2週間以上前 +1か月2週間と3日以上前 +今から1か月以上後 +今から1か月と2週間以上後 +今から1か月2週間と3日以上後 +1時間 +1時間2分 +1時間2分3秒 +1時間前 +1時間2分前 +1時間2分3秒前 +今から1時間後 +今から1時間2分後 +今から1時間2分3秒後 +1時間以内 +1時間2分以内 +1時間2分3秒以内 +過去1時間以内 +過去1時間2分以内 +過去1時間2分3秒以内 +今から1時間以内 +今から1時間2分以内 +今から1時間2分3秒以内 +1時間以上 +1時間2分以上 +1時間2分3秒以上 +1時間以上前 +1時間2分以上前 +1時間2分3秒以上前 +今から1時間以上後 +今から1時間2分以上後 +今から1時間2分3秒以上後 +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +半年 +1年半 +2年半 +5年半 +10年半 +11年半 +12年半 +20年半 +21年半 +22年半 +半か月 +1か月半 +2か月半 +5か月半 +10か月半 +11か月半 +12か月半 +20か月半 +21か月半 +22か月半 +0.5週間 +1.5週間 +2.5週間 +5.5週間 +10.5週間 +11.5週間 +12.5週間 +20.5週間 +21.5週間 +22.5週間 +半日 +1日半 +2日半 +5日半 +10日半 +11日半 +12日半 +20日半 +21日半 +22日半 +半時間 +1時間半 +2時間半 +5時間半 +10時間半 +11時間半 +12時間半 +20時間半 +21時間半 +22時間半 +0.5分 +1分半 +2分半 +5分半 +10分半 +11分半 +12分半 +20分半 +21分半 +22分半 +半秒 +1秒半 +2秒半 +5秒半 +10秒半 +11秒半 +12秒半 +20秒半 +21秒半 +22秒半 +0.5ミリ秒 +1.5ミリ秒 +2.5ミリ秒 +5.5ミリ秒 +10.5ミリ秒 +11.5ミリ秒 +12.5ミリ秒 +20.5ミリ秒 +21.5ミリ秒 +22.5ミリ秒 +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0.02年 +1.00年 +1.20年 +2.12年 +12.05年 +0.02か月 +1.00か月 +1.20か月 +2.12か月 +12.05か月 +0.02週間 +1.00週間 +1.20週間 +2.12週間 +12.05週間 +0.02日 +1.00日 +1.20日 +2.12日 +12.05日 +0.02時間 +1.00時間 +1.20時間 +2.12時間 +12.05時間 +0.02分 +1.00分 +1.20分 +2.12分 +12.05分 +0.02秒 +1.00秒 +1.20秒 +2.12秒 +12.05秒 +0.02ミリ秒 +1.00ミリ秒 +1.20ミリ秒 +2.12ミリ秒 +12.05ミリ秒 +=multipleUnitTargets +1年2か月 +1年と3週間 +1年2か月と3週間 +1か月と2週間 +1か月と3日 +1か月2週間と3日 +1週間と2日 +1週間と3時間 +1週間と2日3時間 +1日2時間 +1日と3分 +1日2時間3分 +1時間2分 +1時間と3秒 +1時間2分3秒 +1分2秒 +1分と3ミリ秒 +1分2.003秒 +1.002秒 diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ko.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ko.txt new file mode 100644 index 00000000000..68314593c38 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ko.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +3년전 +2년전 +1년전 +0년 +지금부터1년 +지금부터2년 +지금부터3년 +지금부터5년 +지금부터10년 +지금부터11년 +지금부터12년 +지금부터20년 +지금부터21년 +지금부터22년 +지금부터23년 +지금부터25년 +3개월전 +2개월전 +1개월전 +0개월 +지금부터1개월 +지금부터2개월 +지금부터3개월 +지금부터5개월 +지금부터10개월 +지금부터11개월 +지금부터12개월 +지금부터20개월 +지금부터21개월 +지금부터22개월 +지금부터23개월 +지금부터25개월 +3주전 +2주전 +1주전 +0주 +지금부터1주 +지금부터2주 +지금부터3주 +지금부터5주 +지금부터10주 +지금부터11주 +지금부터12주 +지금부터20주 +지금부터21주 +지금부터22주 +지금부터23주 +지금부터25주 +3일전 +2일전 +1일전 +0일 +지금부터1일 +지금부터2일 +지금부터3일 +지금부터5일 +지금부터10일 +지금부터11일 +지금부터12일 +지금부터20일 +지금부터21일 +지금부터22일 +지금부터23일 +지금부터25일 +3시간전 +2시간전 +1시간전 +0시간 +지금부터1시간 +지금부터2시간 +지금부터3시간 +지금부터5시간 +지금부터10시간 +지금부터11시간 +지금부터12시간 +지금부터20시간 +지금부터21시간 +지금부터22시간 +지금부터23시간 +지금부터25시간 +3분전 +2분전 +1분전 +0분 +지금부터1분 +지금부터2분 +지금부터3분 +지금부터5분 +지금부터10분 +지금부터11분 +지금부터12분 +지금부터20분 +지금부터21분 +지금부터22분 +지금부터23분 +지금부터25분 +3초전 +2초전 +1초전 +0초 +지금부터1초 +지금부터2초 +지금부터3초 +지금부터5초 +지금부터10초 +지금부터11초 +지금부터12초 +지금부터20초 +지금부터21초 +지금부터22초 +지금부터23초 +지금부터25초 +3밀리세컨드전 +2밀리세컨드전 +1밀리세컨드전 +0밀리세컨드 +지금부터1밀리세컨드 +지금부터2밀리세컨드 +지금부터3밀리세컨드 +지금부터5밀리세컨드 +지금부터10밀리세컨드 +지금부터11밀리세컨드 +지금부터12밀리세컨드 +지금부터20밀리세컨드 +지금부터21밀리세컨드 +지금부터22밀리세컨드 +지금부터23밀리세컨드 +지금부터25밀리세컨드 +=mediumFormTargets +3년 +3개월 +3주 +3일 +3시간 +3분 +3초 +3밀리세컨드 +=shortFormTargets +3년 +3개월 +3주 +3일 +3시간 +3분 +3초 +3밀리세컨드 +=customMinuteTargets +5분 +1시간 5분 +10분 +1시간 10분 +15분 +1시간 15분 +20분 +1시간 20분 +25분 +1시간 25분 +30분 +1시간 30분 +35분 +1시간 35분 +40분 +1시간 40분 +45분 +1시간 45분 +50분 +1시간 50분 +55분 +1시간 55분 +=limitedUnitTargets +1개월 +1개월 2주 +1개월 2주 3일 +1개월전 +1개월 2주전 +1개월 2주 3일전 +지금부터1개월 +지금부터1개월 2주 +지금부터1개월 2주 3일 +1개월 +1개월 2주 +1개월 2주 3일 +1개월전 +1개월 2주전 +1개월 2주 3일전 +지금부터1개월 +지금부터1개월 2주 +지금부터1개월 2주 3일 +1개월 +1개월 2주 +1개월 2주 3일 +1개월전 +1개월 2주전 +1개월 2주 3일전 +지금부터1개월 +지금부터1개월 2주 +지금부터1개월 2주 3일 +1시간 +1시간 2분 +1시간 2분 3초 +1시간전 +1시간 2분전 +1시간 2분 3초전 +지금부터1시간 +지금부터1시간 2분 +지금부터1시간 2분 3초 +1시간 +1시간 2분 +1시간 2분 3초 +1시간전 +1시간 2분전 +1시간 2분 3초전 +지금부터1시간 +지금부터1시간 2분 +지금부터1시간 2분 3초 +1시간 +1시간 2분 +1시간 2분 3초 +1시간전 +1시간 2분전 +1시간 2분 3초전 +지금부터1시간 +지금부터1시간 2분 +지금부터1시간 2분 3초 +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +½년 +1½년 +2½년 +5½년 +10½년 +11½년 +12½년 +20½년 +21½년 +22½년 +½개월 +1½개월 +2½개월 +5½개월 +10½개월 +11½개월 +12½개월 +20½개월 +21½개월 +22½개월 +½주 +1½주 +2½주 +5½주 +10½주 +11½주 +12½주 +20½주 +21½주 +22½주 +½일 +1½일 +2½일 +5½일 +10½일 +11½일 +12½일 +20½일 +21½일 +22½일 +½시간 +1½시간 +2½시간 +5½시간 +10½시간 +11½시간 +12½시간 +20½시간 +21½시간 +22½시간 +½분 +1½분 +2½분 +5½분 +10½분 +11½분 +12½분 +20½분 +21½분 +22½분 +½초 +1½초 +2½초 +5½초 +10½초 +11½초 +12½초 +20½초 +21½초 +22½초 +½밀리세컨드 +1½밀리세컨드 +2½밀리세컨드 +5½밀리세컨드 +10½밀리세컨드 +11½밀리세컨드 +12½밀리세컨드 +20½밀리세컨드 +21½밀리세컨드 +22½밀리세컨드 +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0.02년 +1.00년 +1.20년 +2.12년 +12.05년 +0.02개월 +1.00개월 +1.20개월 +2.12개월 +12.05개월 +0.02주 +1.00주 +1.20주 +2.12주 +12.05주 +0.02일 +1.00일 +1.20일 +2.12일 +12.05일 +0.02시간 +1.00시간 +1.20시간 +2.12시간 +12.05시간 +0.02분 +1.00분 +1.20분 +2.12분 +12.05분 +0.02초 +1.00초 +1.20초 +2.12초 +12.05초 +0.02밀리세컨드 +1.00밀리세컨드 +1.20밀리세컨드 +2.12밀리세컨드 +12.05밀리세컨드 +=multipleUnitTargets +1년 2개월 +1년 3주 +1년 2개월 3주 +1개월 2주 +1개월 3일 +1개월 2주 3일 +1주 2일 +1주 3시간 +1주 2일 3시간 +1일 2시간 +1일 3분 +1일 2시간 3분 +1시간 2분 +1시간 3초 +1시간 2분 3초 +1분 2초 +1분 3밀리세컨드 +1분 2초 3밀리세컨드 +1초 2밀리세컨드 diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ru.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ru.txt new file mode 100644 index 00000000000..28aeb7fe47b --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_ru.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +3 года назад +2 года назад +1 год назад +0 лет +через 1 год +через 2 года +через 3 года +через 5 лет +через 10 лет +через 11 лет +через 12 лет +через 20 лет +через 21 год +через 22 года +через 23 года +через 25 лет +3 месяца назад +2 месяца назад +1 месяц назад +0 месяцев +через 1 месяц +через 2 месяца +через 3 месяца +через 5 месяцев +через 10 месяцев +через 11 месяцев +через 12 месяцев +через 20 месяцев +через 21 месяц +через 22 месяца +через 23 месяца +через 25 месяцев +3 недели назад +2 недели назад +1 неделя назад +0 недель +через 1 неделя +через 2 недели +через 3 недели +через 5 недель +через 10 недель +через 11 недель +через 12 недель +через 20 недель +через 21 неделя +через 22 недели +через 23 недели +через 25 недель +3 дня назад +2 дня назад +1 день назад +0 дней +через 1 день +через 2 дня +через 3 дня +через 5 дней +через 10 дней +через 11 дней +через 12 дней +через 20 дней +через 21 день +через 22 дня +через 23 дня +через 25 дней +3 часа назад +2 часа назад +1 час назад +0 часов +через 1 час +через 2 часа +через 3 часа +через 5 часов +через 10 часов +через 11 часов +через 12 часов +через 20 часов +через 21 час +через 22 часа +через 23 часа +через 25 часов +3 минуты назад +2 минуты назад +1 минута назад +0 минут +через 1 минута +через 2 минуты +через 3 минуты +через 5 минут +через 10 минут +через 11 минут +через 12 минут +через 20 минут +через 21 минута +через 22 минуты +через 23 минуты +через 25 минут +3 секунды назад +2 секунды назад +1 секунда назад +0 секунд +через 1 секунда +через 2 секунды +через 3 секунды +через 5 секунд +через 10 секунд +через 11 секунд +через 12 секунд +через 20 секунд +через 21 секунда +через 22 секунды +через 23 секунды +через 25 секунд +3 миллисекунды назад +2 миллисекунды назад +1 миллисекунда назад +0 миллисекунд +через 1 миллисекунда +через 2 миллисекунды +через 3 миллисекунды +через 5 миллисекунд +через 10 миллисекунд +через 11 миллисекунд +через 12 миллисекунд +через 20 миллисекунд +через 21 миллисекунда +через 22 миллисекунды +через 23 миллисекунды +через 25 миллисекунд +=mediumFormTargets +3 г +3 мес +3 нед +3 дн +3 ч +3 мин +3 с +3 мс +=shortFormTargets +3 г +3 m +3 н +3 д +3 ч +3 м +3 с +3 x +=customMinuteTargets +5 минут +1 час и 5 минут +10 минут +1 час и 10 минут +15 минут +1 час и 15 минут +20 минут +1 час и 20 минут +25 минут +1 час и 25 минут +30 минут +1 час и 30 минут +35 минут +1 час и 35 минут +40 минут +1 час и 40 минут +45 минут +1 час и 45 минут +50 минут +1 час и 50 минут +55 минут +1 час и 55 минут +=limitedUnitTargets +1 месяц +1 месяц и 2 недели +1 месяц, 2 недели и 3 дня +1 месяц назад +1 месяц и 2 недели назад +1 месяц, 2 недели и 3 дня назад +через 1 месяц +через 1 месяц и 2 недели +через 1 месяц, 2 недели и 3 дня +меньше, чем 1 месяц +меньше, чем 1 месяц и 2 недели +меньше, чем 1 месяц, 2 недели и 3 дня +меньше, чем 1 месяц назад +меньше, чем 1 месяц и 2 недели назад +меньше, чем 1 месяц, 2 недели и 3 дня назад +через 1 месяц +через 1 месяц и 2 недели +через 1 месяц, 2 недели и 3 дня +больше, чем 1 месяц +больше, чем 1 месяц и 2 недели +больше, чем 1 месяц, 2 недели и 3 дня +больше, чем 1 месяц назад +больше, чем 1 месяц и 2 недели назад +больше, чем 1 месяц, 2 недели и 3 дня назад +через 1 месяц +через 1 месяц и 2 недели +через 1 месяц, 2 недели и 3 дня +1 час +1 час и 2 минуты +1 час, 2 минуты и 3 секунды +1 час назад +1 час и 2 минуты назад +1 час, 2 минуты и 3 секунды назад +через 1 час +через 1 час и 2 минуты +через 1 час, 2 минуты и 3 секунды +меньше, чем 1 час +меньше, чем 1 час и 2 минуты +меньше, чем 1 час, 2 минуты и 3 секунды +меньше, чем 1 час назад +меньше, чем 1 час и 2 минуты назад +меньше, чем 1 час, 2 минуты и 3 секунды назад +через 1 час +через 1 час и 2 минуты +через 1 час, 2 минуты и 3 секунды +больше, чем 1 час +больше, чем 1 час и 2 минуты +больше, чем 1 час, 2 минуты и 3 секунды +больше, чем 1 час назад +больше, чем 1 час и 2 минуты назад +больше, чем 1 час, 2 минуты и 3 секунды назад +через 1 час +через 1 час и 2 минуты +через 1 час, 2 минуты и 3 секунды +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +½ года +1½ года +2½ года +5½ лет +10½ лет +11½ лет +12½ лет +20½ лет +21½ год +22½ года +½ месяца +1½ месяца +2½ месяца +5½ месяцев +10½ месяцев +11½ месяцев +12½ месяцев +20½ месяцев +21½ месяц +22½ месяца +½ недели +1½ недели +2½ недели +5½ недель +10½ недель +11½ недель +12½ недель +20½ недель +21½ неделя +22½ недели +½ дня +1½ дня +2½ дня +5½ дней +10½ дней +11½ дней +12½ дней +20½ дней +21½ день +22½ дня +½ часа +1½ часа +2½ часа +5½ часов +10½ часов +11½ часов +12½ часов +20½ часов +21½ час +22½ часа +½ минуты +1½ минуты +2½ минуты +5½ минут +10½ минут +11½ минут +12½ минут +20½ минут +21½ минута +22½ минуты +½ секунды +1½ секунды +2½ секунды +5½ секунд +10½ секунд +11½ секунд +12½ секунд +20½ секунд +21½ секунда +22½ секунды +½ миллисекунды +1½ миллисекунды +2½ миллисекунды +5½ миллисекунд +10½ миллисекунд +11½ миллисекунд +12½ миллисекунд +20½ миллисекунд +21½ миллисекунда +22½ миллисекунды +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0.02 года +1.00 года +1.20 года +2.12 года +12.05 года +0.02 месяца +1.00 месяца +1.20 месяца +2.12 месяца +12.05 месяца +0.02 недели +1.00 недели +1.20 недели +2.12 недели +12.05 недели +0.02 дня +1.00 дня +1.20 дня +2.12 дня +12.05 дня +0.02 часа +1.00 часа +1.20 часа +2.12 часа +12.05 часа +0.02 минуты +1.00 минуты +1.20 минуты +2.12 минуты +12.05 минуты +0.02 секунды +1.00 секунды +1.20 секунды +2.12 секунды +12.05 секунды +0.02 миллисекунды +1.00 миллисекунды +1.20 миллисекунды +2.12 миллисекунды +12.05 миллисекунды +=multipleUnitTargets +1 год и 2 месяца +1 год и 3 недели +1 год, 2 месяца и 3 недели +1 месяц и 2 недели +1 месяц и 3 дня +1 месяц, 2 недели и 3 дня +1 неделя и 2 дня +1 неделя и 3 часа +1 неделя, 2 дня и 3 часа +1 день и 2 часа +1 день и 3 минуты +1 день, 2 часа и 3 минуты +1 час и 2 минуты +1 час и 3 секунды +1 час, 2 минуты и 3 секунды +1 минута и 2 секунды +1 минута и 3 миллисекунды +1 минута, 2 секунды и 3 миллисекунды +1 секунда и 2 миллисекунды diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_th.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_th.txt new file mode 100644 index 00000000000..50a81fecf51 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_th.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +3 ปีที่แล้ว +2 ปีที่แล้ว +1 ปีที่แล้ว +0 ปี +อีก 1 ปี +อีก 2 ปี +อีก 3 ปี +อีก 5 ปี +อีก 10 ปี +อีก 11 ปี +อีก 12 ปี +อีก 20 ปี +อีก 21 ปี +อีก 22 ปี +อีก 23 ปี +อีก 25 ปี +3 เดือนที่แล้ว +2 เดือนที่แล้ว +1 เดือนที่แล้ว +0 เดือน +อีก 1 เดือน +อีก 2 เดือน +อีก 3 เดือน +อีก 5 เดือน +อีก 10 เดือน +อีก 11 เดือน +อีก 12 เดือน +อีก 20 เดือน +อีก 21 เดือน +อีก 22 เดือน +อีก 23 เดือน +อีก 25 เดือน +3 อาทิตย์ที่แล้ว +2 อาทิตย์ที่แล้ว +1 อาทิตย์ที่แล้ว +0 อาทิตย์ +อีก 1 อาทิตย์ +อีก 2 อาทิตย์ +อีก 3 อาทิตย์ +อีก 5 อาทิตย์ +อีก 10 อาทิตย์ +อีก 11 อาทิตย์ +อีก 12 อาทิตย์ +อีก 20 อาทิตย์ +อีก 21 อาทิตย์ +อีก 22 อาทิตย์ +อีก 23 อาทิตย์ +อีก 25 อาทิตย์ +3 วันที่แล้ว +2 วันที่แล้ว +1 วันที่แล้ว +0 วัน +อีก 1 วัน +อีก 2 วัน +อีก 3 วัน +อีก 5 วัน +อีก 10 วัน +อีก 11 วัน +อีก 12 วัน +อีก 20 วัน +อีก 21 วัน +อีก 22 วัน +อีก 23 วัน +อีก 25 วัน +3 ชั่วโมงที่แล้ว +2 ชั่วโมงที่แล้ว +1 ชั่วโมงที่แล้ว +0 ชั่วโมง +อีก 1 ชั่วโมง +อีก 2 ชั่วโมง +อีก 3 ชั่วโมง +อีก 5 ชั่วโมง +อีก 10 ชั่วโมง +อีก 11 ชั่วโมง +อีก 12 ชั่วโมง +อีก 20 ชั่วโมง +อีก 21 ชั่วโมง +อีก 22 ชั่วโมง +อีก 23 ชั่วโมง +อีก 25 ชั่วโมง +3 นาทีที่แล้ว +2 นาทีที่แล้ว +1 นาทีที่แล้ว +0 นาที +อีก 1 นาที +อีก 2 นาที +อีก 3 นาที +อีก 5 นาที +อีก 10 นาที +อีก 11 นาที +อีก 12 นาที +อีก 20 นาที +อีก 21 นาที +อีก 22 นาที +อีก 23 นาที +อีก 25 นาที +3 วินาทีที่แล้ว +2 วินาทีที่แล้ว +1 วินาทีที่แล้ว +0 วินาที +อีก 1 วินาที +อีก 2 วินาที +อีก 3 วินาที +อีก 5 วินาที +อีก 10 วินาที +อีก 11 วินาที +อีก 12 วินาที +อีก 20 วินาที +อีก 21 วินาที +อีก 22 วินาที +อีก 23 วินาที +อีก 25 วินาที +0.003 วินาทีที่แล้ว +0.002 วินาทีที่แล้ว +0.001 วินาทีที่แล้ว +0.000 วินาที +อีก 0.001 วินาที +อีก 0.002 วินาที +อีก 0.003 วินาที +อีก 0.005 วินาที +อีก 0.010 วินาที +อีก 0.011 วินาที +อีก 0.012 วินาที +อีก 0.020 วินาที +อีก 0.021 วินาที +อีก 0.022 วินาที +อีก 0.023 วินาที +อีก 0.025 วินาที +=mediumFormTargets +3 ปี +3 เดือน +3 อาทิตย์ +3 วัน +3 ชม. +3 นาที +3 วินาที +0.003 วินาที +=shortFormTargets +3 ปี +3 เดือน +3 อาทิตย์ +3 วัน +3 ชม. +3 นาที +3 วินาที +0.003 วินาที +=customMinuteTargets +5 นาที +1 ชั่วโมง 5 นาที +10 นาที +1 ชั่วโมง 10 นาที +15 นาที +1 ชั่วโมง 15 นาที +20 นาที +1 ชั่วโมง 20 นาที +25 นาที +1 ชั่วโมง 25 นาที +30 นาที +1 ชั่วโมง 30 นาที +35 นาที +1 ชั่วโมง 35 นาที +40 นาที +1 ชั่วโมง 40 นาที +45 นาที +1 ชั่วโมง 45 นาที +50 นาที +1 ชั่วโมง 50 นาที +55 นาที +1 ชั่วโมง 55 นาที +=limitedUnitTargets +1 เดือน +1 เดือน 2 อาทิตย์ +1 เดือน 2 อาทิตย์ 3 วัน +1 เดือนที่แล้ว +1 เดือน 2 อาทิตย์ที่แล้ว +1 เดือน 2 อาทิตย์ 3 วันที่แล้ว +อีก 1 เดือน +อีก 1 เดือน 2 อาทิตย์ +อีก 1 เดือน 2 อาทิตย์ 3 วัน +น้อยกว่า 1 เดือน +น้อยกว่า 1 เดือน 2 อาทิตย์ +น้อยกว่า 1 เดือน 2 อาทิตย์ 3 วัน +น้อยกว่า 1 เดือนที่แล้ว +น้อยกว่า 1 เดือน 2 อาทิตย์ที่แล้ว +น้อยกว่า 1 เดือน 2 อาทิตย์ 3 วันที่แล้ว +ไม่ถึงอีก 1 เดือน +ไม่ถึงอีก 1 เดือน 2 อาทิตย์ +ไม่ถึงอีก 1 เดือน 2 อาทิตย์ 3 วัน +มากกว่า 1 เดือน +มากกว่า 1 เดือน 2 อาทิตย์ +มากกว่า 1 เดือน 2 อาทิตย์ 3 วัน +มากกว่า 1 เดือนที่แล้ว +มากกว่า 1 เดือน 2 อาทิตย์ที่แล้ว +มากกว่า 1 เดือน 2 อาทิตย์ 3 วันที่แล้ว +อีัก 1 เดือนกว่าๆ +อีัก 1 เดือน 2 อาทิตย์กว่าๆ +อีัก 1 เดือน 2 อาทิตย์ 3 วันกว่าๆ +1 ชั่วโมง +1 ชั่วโมง 2 นาที +1 ชั่วโมง 2 นาที 3 วินาที +1 ชั่วโมงที่แล้ว +1 ชั่วโมง 2 นาทีที่แล้ว +1 ชั่วโมง 2 นาที 3 วินาทีที่แล้ว +อีก 1 ชั่วโมง +อีก 1 ชั่วโมง 2 นาที +อีก 1 ชั่วโมง 2 นาที 3 วินาที +น้อยกว่า 1 ชั่วโมง +น้อยกว่า 1 ชั่วโมง 2 นาที +น้อยกว่า 1 ชั่วโมง 2 นาที 3 วินาที +น้อยกว่า 1 ชั่วโมงที่แล้ว +น้อยกว่า 1 ชั่วโมง 2 นาทีที่แล้ว +น้อยกว่า 1 ชั่วโมง 2 นาที 3 วินาทีที่แล้ว +ไม่ถึงอีก 1 ชั่วโมง +ไม่ถึงอีก 1 ชั่วโมง 2 นาที +ไม่ถึงอีก 1 ชั่วโมง 2 นาที 3 วินาที +มากกว่า 1 ชั่วโมง +มากกว่า 1 ชั่วโมง 2 นาที +มากกว่า 1 ชั่วโมง 2 นาที 3 วินาที +มากกว่า 1 ชั่วโมงที่แล้ว +มากกว่า 1 ชั่วโมง 2 นาทีที่แล้ว +มากกว่า 1 ชั่วโมง 2 นาที 3 วินาทีที่แล้ว +อีัก 1 ชั่วโมงกว่าๆ +อีัก 1 ชั่วโมง 2 นาทีกว่าๆ +อีัก 1 ชั่วโมง 2 นาที 3 วินาทีกว่าๆ +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +ครึ่งปี +1 ปีครึ่ง +2 ปีครึ่ง +5 ปีครึ่ง +10 ปีครึ่ง +11 ปีครึ่ง +12 ปีครึ่ง +20 ปีครึ่ง +21 ปีครึ่ง +22 ปีครึ่ง +ครึ่งเดือน +1 เดือนครึ่ง +2 เดือนครึ่ง +5 เดือนครึ่ง +10 เดือนครึ่ง +11 เดือนครึ่ง +12 เดือนครึ่ง +20 เดือนครึ่ง +21 เดือนครึ่ง +22 เดือนครึ่ง +ครึ่งอาทิตย์ +1 อาทิตย์ครึ่ง +2 อาทิตย์ครึ่ง +5 อาทิตย์ครึ่ง +10 อาทิตย์ครึ่ง +11 อาทิตย์ครึ่ง +12 อาทิตย์ครึ่ง +20 อาทิตย์ครึ่ง +21 อาทิตย์ครึ่ง +22 อาทิตย์ครึ่ง +ครึ่งวัน +1 วันครึ่ง +2 วันครึ่ง +5 วันครึ่ง +10 วันครึ่ง +11 วันครึ่ง +12 วันครึ่ง +20 วันครึ่ง +21 วันครึ่ง +22 วันครึ่ง +ครึ่งชั่วโมง +1 ชั่วโมงครึ่ง +2 ชั่วโมงครึ่ง +5 ชั่วโมงครึ่ง +10 ชั่วโมงครึ่ง +11 ชั่วโมงครึ่ง +12 ชั่วโมงครึ่ง +20 ชั่วโมงครึ่ง +21 ชั่วโมงครึ่ง +22 ชั่วโมงครึ่ง +ครึ่งนาที +1 นาทีครึ่ง +2 นาทีครึ่ง +5 นาทีครึ่ง +10 นาทีครึ่ง +11 นาทีครึ่ง +12 นาทีครึ่ง +20 นาทีครึ่ง +21 นาทีครึ่ง +22 นาทีครึ่ง +0.5 วินาที +1.5 วินาที +2.5 วินาที +5.5 วินาที +10.5 วินาที +11.5 วินาที +12.5 วินาที +20.5 วินาที +21.5 วินาที +22.5 วินาที +0.000 วินาที +0.001 วินาที +0.002 วินาที +0.005 วินาที +0.010 วินาที +0.011 วินาที +0.012 วินาที +0.020 วินาที +0.021 วินาที +0.022 วินาที +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0.02 ปี +1.00 ปี +1.20 ปี +2.12 ปี +12.05 ปี +0.02 เดือน +1.00 เดือน +1.20 เดือน +2.12 เดือน +12.05 เดือน +0.02 อาทิตย์ +1.00 อาทิตย์ +1.20 อาทิตย์ +2.12 อาทิตย์ +12.05 อาทิตย์ +0.02 วัน +1.00 วัน +1.20 วัน +2.12 วัน +12.05 วัน +0.02 ชั่วโมง +1.00 ชั่วโมง +1.20 ชั่วโมง +2.12 ชั่วโมง +12.05 ชั่วโมง +0.02 นาที +1.00 นาที +1.20 นาที +2.12 นาที +12.05 นาที +0.02 วินาที +1.00 วินาที +1.20 วินาที +2.12 วินาที +12.05 วินาที +0.000 วินาที +0.001 วินาที +0.001 วินาที +0.002 วินาที +0.012 วินาที +=multipleUnitTargets +1 ปี 2 เดือน +1 ปี 3 อาทิตย์ +1 ปี 2 เดือน 3 อาทิตย์ +1 เดือน 2 อาทิตย์ +1 เดือน 3 วัน +1 เดือน 2 อาทิตย์ 3 วัน +1 อาทิตย์ 2 วัน +1 อาทิตย์ 3 ชั่วโมง +1 อาทิตย์ 2 วัน 3 ชั่วโมง +1 วัน 2 ชั่วโมง +1 วัน 3 นาที +1 วัน 2 ชั่วโมง 3 นาที +1 ชั่วโมง 2 นาที +1 ชั่วโมง 3 วินาที +1 ชั่วโมง 2 นาที 3 วินาที +1 นาที 2 วินาที +1 นาที 0.003 วินาที +1 นาที 2.003 วินาที +1.002 วินาที diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hans.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hans.txt new file mode 100644 index 00000000000..fa5e42254fe --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hans.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +三年以前 +两年以前 +一年以前 +零年 +一年以后 +两年以后 +三年以后 +五年以后 +十年以后 +十一年以后 +十二年以后 +二十年以后 +二十一年以后 +二十二年以后 +二十三年以后 +二十五年以后 +三个月以前 +两个月以前 +一个月以前 +零个月 +一个月以后 +两个月以后 +三个月以后 +五个月以后 +十个月以后 +十一个月以后 +十二个月以后 +二十个月以后 +二十一个月以后 +二十二个月以后 +二十三个月以后 +二十五个月以后 +三周以前 +两周以前 +一周以前 +零周 +一周以后 +两周以后 +三周以后 +五周以后 +十周以后 +十一周以后 +十二周以后 +二十周以后 +二十一周以后 +二十二周以后 +二十三周以后 +二十五周以后 +三天以前 +两天以前 +一天以前 +零天 +一天以后 +两天以后 +三天以后 +五天以后 +十天以后 +十一天以后 +十二天以后 +二十天以后 +二十一天以后 +二十二天以后 +二十三天以后 +二十五天以后 +三个小时以前 +两个小时以前 +一个小时以前 +零个小时 +一个小时以后 +两个小时以后 +三个小时以后 +五个小时以后 +十个小时以后 +十一个小时以后 +十二个小时以后 +二十个小时以后 +二十一个小时以后 +二十二个小时以后 +二十三个小时以后 +二十五个小时以后 +三分钟以前 +两分钟以前 +一分钟以前 +零分钟 +一分钟以后 +两分钟以后 +三分钟以后 +五分钟以后 +十分钟以后 +十一分钟以后 +十二分钟以后 +二十分钟以后 +二十一分钟以后 +二十二分钟以后 +二十三分钟以后 +二十五分钟以后 +三秒钟以前 +两秒钟以前 +一秒钟以前 +零秒钟 +一秒钟以后 +两秒钟以后 +三秒钟以后 +五秒钟以后 +十秒钟以后 +十一秒钟以后 +十二秒钟以后 +二十秒钟以后 +二十一秒钟以后 +二十二秒钟以后 +二十三秒钟以后 +二十五秒钟以后 +三毫秒以前 +两毫秒以前 +一毫秒以前 +零毫秒 +一毫秒以后 +两毫秒以后 +三毫秒以后 +五毫秒以后 +十毫秒以后 +十一毫秒以后 +十二毫秒以后 +二十毫秒以后 +二十一毫秒以后 +二十二毫秒以后 +二十三毫秒以后 +二十五毫秒以后 +=mediumFormTargets +三年 +三个月 +三周 +三天 +三个小时 +三分钟 +三秒钟 +三毫秒 +=shortFormTargets +三年 +三个月 +三周 +三天 +三个小时 +三分钟 +三秒钟 +三毫秒 +=customMinuteTargets +五分钟 +一个小时五分钟 +十分钟 +一个小时十分钟 +一刻钟 +一个小时一刻钟 +二十分钟 +一个小时二十分钟 +二十五分钟 +一个小时二十五分钟 +三十分钟 +一个小时三十分钟 +三十五分钟 +一个小时三十五分钟 +四十分钟 +一个小时四十分钟 +三刻钟 +一个小时三刻钟 +五十分钟 +一个小时五十分钟 +五十五分钟 +一个小时五十五分钟 +=limitedUnitTargets +一个月 +一个月两周 +一个月两周三天 +一个月以前 +一个月两周以前 +一个月两周三天以前 +一个月以后 +一个月两周以后 +一个月两周三天以后 +不到一个月 +不到一个月两周 +不到一个月两周三天 +不到一个月以前 +不到一个月两周以前 +不到一个月两周三天以前 +不到一个月以后 +不到一个月两周以后 +不到一个月两周三天以后 +超过一个月 +超过一个月两周 +超过一个月两周三天 +超过一个月以前 +超过一个月两周以前 +超过一个月两周三天以前 +超过一个月以后 +超过一个月两周以后 +超过一个月两周三天以后 +一个小时 +一个小时两分钟 +一个小时两分三秒钟 +一个小时以前 +一个小时两分钟以前 +一个小时两分三秒钟以前 +一个小时以后 +一个小时两分钟以后 +一个小时两分三秒钟以后 +不到一个小时 +不到一个小时两分钟 +不到一个小时两分三秒钟 +不到一个小时以前 +不到一个小时两分钟以前 +不到一个小时两分三秒钟以前 +不到一个小时以后 +不到一个小时两分钟以后 +不到一个小时两分三秒钟以后 +超过一个小时 +超过一个小时两分钟 +超过一个小时两分三秒钟 +超过一个小时以前 +超过一个小时两分钟以前 +超过一个小时两分三秒钟以前 +超过一个小时以后 +超过一个小时两分钟以后 +超过一个小时两分三秒钟以后 +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +半年 +一年半 +两年半 +五年半 +十年半 +十一年半 +十二年半 +二十年半 +二十一年半 +二十二年半 +半个月 +一个半月 +两个半月 +五个半月 +十个半月 +十一个半月 +十二个半月 +二十个半月 +二十一个半月 +二十二个半月 +半周 +一周半 +两周半 +五周半 +十周半 +十一周半 +十二周半 +二十周半 +二十一周半 +二十二周半 +半天 +一天半 +两天半 +五天半 +十天半 +十一天半 +十二天半 +二十天半 +二十一天半 +二十二天半 +半个小时 +一个半小时 +两个半小时 +五个半小时 +十个半小时 +十一个半小时 +十二个半小时 +二十个半小时 +二十一个半小时 +二十二个半小时 +半分钟 +一分半钟 +两分半钟 +五分半钟 +十分半钟 +十一分半钟 +十二分半钟 +二十分半钟 +二十一分半钟 +二十二分半钟 +半秒钟 +一秒半钟 +两秒半钟 +五秒半钟 +十秒半钟 +十一秒半钟 +十二秒半钟 +二十秒半钟 +二十一秒半钟 +二十二秒半钟 +半毫秒 +一毫秒半 +两毫秒半 +五毫秒半 +十毫秒半 +十一毫秒半 +十二毫秒半 +二十毫秒半 +二十一毫秒半 +二十二毫秒半 +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0.02年 +1.00年 +1.20年 +2.12年 +12.05年 +0.02个月 +1.00个月 +1.20个月 +2.12个月 +12.05个月 +0.02周 +1.00周 +1.20周 +2.12周 +12.05周 +0.02天 +1.00天 +1.20天 +2.12天 +12.05天 +0.02个小时 +1.00个小时 +1.20个小时 +2.12个小时 +12.05个小时 +0.02分钟 +1.00分钟 +1.20分钟 +2.12分钟 +12.05分钟 +0.02秒钟 +1.00秒钟 +1.20秒钟 +2.12秒钟 +12.05秒钟 +0.02毫秒 +1.00毫秒 +1.20毫秒 +2.12毫秒 +12.05毫秒 +=multipleUnitTargets +一年两个月 +一年三周 +一年两个月三周 +一个月两周 +一个月三天 +一个月两周三天 +一周两天 +一周三个小时 +一周两天三个小时 +一天两个小时 +一天三分钟 +一天两个小时三分钟 +一个小时两分钟 +一个小时三秒钟 +一个小时两分三秒钟 +一分两秒钟 +一分三毫秒 +一分两秒三毫秒 +一秒两毫秒 diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hans_SG.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hans_SG.txt new file mode 100644 index 00000000000..039221eea64 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hans_SG.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +三年以前 +两年以前 +一年以前 +零年 +一年以后 +两年以后 +三年以后 +五年以后 +十年以后 +十一年以后 +十二年以后 +二十年以后 +二十一年以后 +二十二年以后 +二十三年以后 +二十五年以后 +三个月以前 +两个月以前 +一个月以前 +零个月 +一个月以后 +两个月以后 +三个月以后 +五个月以后 +十个月以后 +十一个月以后 +十二个月以后 +二十个月以后 +二十一个月以后 +二十二个月以后 +二十三个月以后 +二十五个月以后 +三周以前 +两周以前 +一周以前 +零周 +一周以后 +两周以后 +三周以后 +五周以后 +十周以后 +十一周以后 +十二周以后 +二十周以后 +二十一周以后 +二十二周以后 +二十三周以后 +二十五周以后 +三天以前 +两天以前 +一天以前 +零天 +一天以后 +两天以后 +三天以后 +五天以后 +十天以后 +十一天以后 +十二天以后 +二十天以后 +二十一天以后 +二十二天以后 +二十三天以后 +二十五天以后 +三个小时以前 +两个小时以前 +一个小时以前 +零个小时 +一个小时以后 +两个小时以后 +三个小时以后 +五个小时以后 +十个小时以后 +十一个小时以后 +十二个小时以后 +二十个小时以后 +二十一个小时以后 +二十二个小时以后 +二十三个小时以后 +二十五个小时以后 +三分钟以前 +两分钟以前 +一分钟以前 +零分钟 +一分钟以后 +两分钟以后 +三分钟以后 +五分钟以后 +十分钟以后 +十一分钟以后 +十二分钟以后 +二十分钟以后 +二十一分钟以后 +二十二分钟以后 +二十三分钟以后 +二十五分钟以后 +三秒钟以前 +两秒钟以前 +一秒钟以前 +零秒钟 +一秒钟以后 +两秒钟以后 +三秒钟以后 +五秒钟以后 +十秒钟以后 +十一秒钟以后 +十二秒钟以后 +二十秒钟以后 +二十一秒钟以后 +二十二秒钟以后 +二十三秒钟以后 +二十五秒钟以后 +三毫秒以前 +两毫秒以前 +一毫秒以前 +零毫秒 +一毫秒以后 +两毫秒以后 +三毫秒以后 +五毫秒以后 +十毫秒以后 +十一毫秒以后 +十二毫秒以后 +二十毫秒以后 +二十一毫秒以后 +二十二毫秒以后 +二十三毫秒以后 +二十五毫秒以后 +=mediumFormTargets +三年 +三个月 +三周 +三天 +三个小时 +三分钟 +三秒钟 +三毫秒 +=shortFormTargets +三年 +三个月 +三周 +三天 +三个小时 +三分钟 +三秒钟 +三毫秒 +=customMinuteTargets +一个字 +一个小时一个字 +两个字 +一个小时两个字 +三个字 +一个小时三个字 +四个字 +一个小时四个字 +五个字 +一个小时五个字 +六个字 +一个小时六个字 +七个字 +一个小时七个字 +八个字 +一个小时八个字 +九个字 +一个小时九个字 +十个字 +一个小时十个字 +十一个字 +一个小时十一个字 +=limitedUnitTargets +一个月 +一个月两周 +一个月两周三天 +一个月以前 +一个月两周以前 +一个月两周三天以前 +一个月以后 +一个月两周以后 +一个月两周三天以后 +不到一个月 +不到一个月两周 +不到一个月两周三天 +不到一个月以前 +不到一个月两周以前 +不到一个月两周三天以前 +不到一个月以后 +不到一个月两周以后 +不到一个月两周三天以后 +超过一个月 +超过一个月两周 +超过一个月两周三天 +超过一个月以前 +超过一个月两周以前 +超过一个月两周三天以前 +超过一个月以后 +超过一个月两周以后 +超过一个月两周三天以后 +一个小时 +一个小时两分钟 +一个小时两分三秒钟 +一个小时以前 +一个小时两分钟以前 +一个小时两分三秒钟以前 +一个小时以后 +一个小时两分钟以后 +一个小时两分三秒钟以后 +不到一个小时 +不到一个小时两分钟 +不到一个小时两分三秒钟 +不到一个小时以前 +不到一个小时两分钟以前 +不到一个小时两分三秒钟以前 +不到一个小时以后 +不到一个小时两分钟以后 +不到一个小时两分三秒钟以后 +超过一个小时 +超过一个小时两分钟 +超过一个小时两分三秒钟 +超过一个小时以前 +超过一个小时两分钟以前 +超过一个小时两分三秒钟以前 +超过一个小时以后 +超过一个小时两分钟以后 +超过一个小时两分三秒钟以后 +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +半年 +一年半 +两年半 +五年半 +十年半 +十一年半 +十二年半 +二十年半 +二十一年半 +二十二年半 +半个月 +一个半月 +两个半月 +五个半月 +十个半月 +十一个半月 +十二个半月 +二十个半月 +二十一个半月 +二十二个半月 +半周 +一周半 +两周半 +五周半 +十周半 +十一周半 +十二周半 +二十周半 +二十一周半 +二十二周半 +半天 +一天半 +两天半 +五天半 +十天半 +十一天半 +十二天半 +二十天半 +二十一天半 +二十二天半 +半个小时 +一个半小时 +两个半小时 +五个半小时 +十个半小时 +十一个半小时 +十二个半小时 +二十个半小时 +二十一个半小时 +二十二个半小时 +半分钟 +一分半钟 +两分半钟 +五分半钟 +十分半钟 +十一分半钟 +十二分半钟 +二十分半钟 +二十一分半钟 +二十二分半钟 +半秒钟 +一秒半钟 +两秒半钟 +五秒半钟 +十秒半钟 +十一秒半钟 +十二秒半钟 +二十秒半钟 +二十一秒半钟 +二十二秒半钟 +半毫秒 +一毫秒半 +两毫秒半 +五毫秒半 +十毫秒半 +十一毫秒半 +十二毫秒半 +二十毫秒半 +二十一毫秒半 +二十二毫秒半 +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0.02年 +1.00年 +1.20年 +2.12年 +12.05年 +0.02个月 +1.00个月 +1.20个月 +2.12个月 +12.05个月 +0.02周 +1.00周 +1.20周 +2.12周 +12.05周 +0.02天 +1.00天 +1.20天 +2.12天 +12.05天 +0.02个小时 +1.00个小时 +1.20个小时 +2.12个小时 +12.05个小时 +0.02分钟 +1.00分钟 +1.20分钟 +2.12分钟 +12.05分钟 +0.02秒钟 +1.00秒钟 +1.20秒钟 +2.12秒钟 +12.05秒钟 +0.02毫秒 +1.00毫秒 +1.20毫秒 +2.12毫秒 +12.05毫秒 +=multipleUnitTargets +一年两个月 +一年三周 +一年两个月三周 +一个月两周 +一个月三天 +一个月两周三天 +一周两天 +一周三个小时 +一周两天三个小时 +一天两个小时 +一天三分钟 +一天两个小时三分钟 +一个小时两分钟 +一个小时三秒钟 +一个小时两分三秒钟 +一分两秒钟 +一分三毫秒 +一分两秒三毫秒 +一秒两毫秒 diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hant.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hant.txt new file mode 100644 index 00000000000..49f5b007330 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hant.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +三年以前 +兩年以前 +一年以前 +零年 +一年以後 +兩年以後 +三年以後 +五年以後 +十年以後 +十一年以後 +十二年以後 +二十年以後 +二十一年以後 +二十二年以後 +二十三年以後 +二十五年以後 +三個月以前 +兩個月以前 +一個月以前 +零個月 +一個月以後 +兩個月以後 +三個月以後 +五個月以後 +十個月以後 +十一個月以後 +十二個月以後 +二十個月以後 +二十一個月以後 +二十二個月以後 +二十三個月以後 +二十五個月以後 +三週以前 +兩週以前 +一週以前 +零週 +一週以後 +兩週以後 +三週以後 +五週以後 +十週以後 +十一週以後 +十二週以後 +二十週以後 +二十一週以後 +二十二週以後 +二十三週以後 +二十五週以後 +三天以前 +兩天以前 +一天以前 +零天 +一天以後 +兩天以後 +三天以後 +五天以後 +十天以後 +十一天以後 +十二天以後 +二十天以後 +二十一天以後 +二十二天以後 +二十三天以後 +二十五天以後 +三個小時以前 +兩個小時以前 +一個小時以前 +零個小時 +一個小時以後 +兩個小時以後 +三個小時以後 +五個小時以後 +十個小時以後 +十一個小時以後 +十二個小時以後 +二十個小時以後 +二十一個小時以後 +二十二個小時以後 +二十三個小時以後 +二十五個小時以後 +三分鐘以前 +兩分鐘以前 +一分鐘以前 +零分鐘 +一分鐘以後 +兩分鐘以後 +三分鐘以後 +五分鐘以後 +十分鐘以後 +十一分鐘以後 +十二分鐘以後 +二十分鐘以後 +二十一分鐘以後 +二十二分鐘以後 +二十三分鐘以後 +二十五分鐘以後 +三秒鐘以前 +兩秒鐘以前 +一秒鐘以前 +零秒鐘 +一秒鐘以後 +兩秒鐘以後 +三秒鐘以後 +五秒鐘以後 +十秒鐘以後 +十一秒鐘以後 +十二秒鐘以後 +二十秒鐘以後 +二十一秒鐘以後 +二十二秒鐘以後 +二十三秒鐘以後 +二十五秒鐘以後 +三毫秒以前 +兩毫秒以前 +一毫秒以前 +零毫秒 +一毫秒以後 +兩毫秒以後 +三毫秒以後 +五毫秒以後 +十毫秒以後 +十一毫秒以後 +十二毫秒以後 +二十毫秒以後 +二十一毫秒以後 +二十二毫秒以後 +二十三毫秒以後 +二十五毫秒以後 +=mediumFormTargets +三年 +三個月 +三週 +三天 +三個小時 +三分鐘 +三秒鐘 +三毫秒 +=shortFormTargets +三年 +三個月 +三週 +三天 +三個小時 +三分鐘 +三秒鐘 +三毫秒 +=customMinuteTargets +五分鐘 +一個小時五分鐘 +十分鐘 +一個小時十分鐘 +一刻鐘 +一個小時一刻鐘 +二十分鐘 +一個小時二十分鐘 +二十五分鐘 +一個小時二十五分鐘 +三十分鐘 +一個小時三十分鐘 +三十五分鐘 +一個小時三十五分鐘 +四十分鐘 +一個小時四十分鐘 +三刻鐘 +一個小時三刻鐘 +五十分鐘 +一個小時五十分鐘 +五十五分鐘 +一個小時五十五分鐘 +=limitedUnitTargets +一個月 +一個月兩週 +一個月兩週三天 +一個月以前 +一個月兩週以前 +一個月兩週三天以前 +一個月以後 +一個月兩週以後 +一個月兩週三天以後 +不到一個月 +不到一個月兩週 +不到一個月兩週三天 +不到一個月以前 +不到一個月兩週以前 +不到一個月兩週三天以前 +不到一個月以後 +不到一個月兩週以後 +不到一個月兩週三天以後 +超過一個月 +超過一個月兩週 +超過一個月兩週三天 +超過一個月以前 +超過一個月兩週以前 +超過一個月兩週三天以前 +超過一個月以後 +超過一個月兩週以後 +超過一個月兩週三天以後 +一個小時 +一個小時兩分鐘 +一個小時兩分三秒鐘 +一個小時以前 +一個小時兩分鐘以前 +一個小時兩分三秒鐘以前 +一個小時以後 +一個小時兩分鐘以後 +一個小時兩分三秒鐘以後 +不到一個小時 +不到一個小時兩分鐘 +不到一個小時兩分三秒鐘 +不到一個小時以前 +不到一個小時兩分鐘以前 +不到一個小時兩分三秒鐘以前 +不到一個小時以後 +不到一個小時兩分鐘以後 +不到一個小時兩分三秒鐘以後 +超過一個小時 +超過一個小時兩分鐘 +超過一個小時兩分三秒鐘 +超過一個小時以前 +超過一個小時兩分鐘以前 +超過一個小時兩分三秒鐘以前 +超過一個小時以後 +超過一個小時兩分鐘以後 +超過一個小時兩分三秒鐘以後 +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +半年 +一年半 +兩年半 +五年半 +十年半 +十一年半 +十二年半 +二十年半 +二十一年半 +二十二年半 +半個月 +一個半月 +兩個半月 +五個半月 +十個半月 +十一個半月 +十二個半月 +二十個半月 +二十一個半月 +二十二個半月 +半週 +一週半 +兩週半 +五週半 +十週半 +十一週半 +十二週半 +二十週半 +二十一週半 +二十二週半 +半天 +一天半 +兩天半 +五天半 +十天半 +十一天半 +十二天半 +二十天半 +二十一天半 +二十二天半 +半個小時 +一個半小時 +兩個半小時 +五個半小時 +十個半小時 +十一個半小時 +十二個半小時 +二十個半小時 +二十一個半小時 +二十二個半小時 +半分鐘 +一分半鐘 +兩分半鐘 +五分半鐘 +十分半鐘 +十一分半鐘 +十二分半鐘 +二十分半鐘 +二十一分半鐘 +二十二分半鐘 +半秒鐘 +一秒半鐘 +兩秒半鐘 +五秒半鐘 +十秒半鐘 +十一秒半鐘 +十二秒半鐘 +二十秒半鐘 +二十一秒半鐘 +二十二秒半鐘 +半毫秒 +一毫秒半 +兩毫秒半 +五毫秒半 +十毫秒半 +十一毫秒半 +十二毫秒半 +二十毫秒半 +二十一毫秒半 +二十二毫秒半 +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0.02年 +1.00年 +1.20年 +2.12年 +12.05年 +0.02個月 +1.00個月 +1.20個月 +2.12個月 +12.05個月 +0.02週 +1.00週 +1.20週 +2.12週 +12.05週 +0.02天 +1.00天 +1.20天 +2.12天 +12.05天 +0.02個小時 +1.00個小時 +1.20個小時 +2.12個小時 +12.05個小時 +0.02分鐘 +1.00分鐘 +1.20分鐘 +2.12分鐘 +12.05分鐘 +0.02秒鐘 +1.00秒鐘 +1.20秒鐘 +2.12秒鐘 +12.05秒鐘 +0.02毫秒 +1.00毫秒 +1.20毫秒 +2.12毫秒 +12.05毫秒 +=multipleUnitTargets +一年兩個月 +一年三週 +一年兩個月三週 +一個月兩週 +一個月三天 +一個月兩週三天 +一週兩天 +一週三個小時 +一週兩天三個小時 +一天兩個小時 +一天三分鐘 +一天兩個小時三分鐘 +一個小時兩分鐘 +一個小時三秒鐘 +一個小時兩分三秒鐘 +一分兩秒鐘 +一分三毫秒 +一分兩秒三毫秒 +一秒兩毫秒 diff --git a/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hant_HK.txt b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hant_HK.txt new file mode 100644 index 00000000000..3dcd42523c5 --- /dev/null +++ b/icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hant_HK.txt @@ -0,0 +1,401 @@ +=fullPluralizedFormCounts +-3 +-2 +-1 +0 +1 +2 +3 +5 +10 +11 +12 +20 +21 +22 +23 +25 +=fullPluralizedFormTargets +3年之前 +2年之前 +1年之前 +0年 +1年之後 +2年之後 +3年之後 +5年之後 +10年之後 +11年之後 +12年之後 +20年之後 +21年之後 +22年之後 +23年之後 +25年之後 +3個月之前 +2個月之前 +1個月之前 +0個月 +1個月之後 +2個月之後 +3個月之後 +5個月之後 +10個月之後 +11個月之後 +12個月之後 +20個月之後 +21個月之後 +22個月之後 +23個月之後 +25個月之後 +3週之前 +2週之前 +1週之前 +0週 +1週之後 +2週之後 +3週之後 +5週之後 +10週之後 +11週之後 +12週之後 +20週之後 +21週之後 +22週之後 +23週之後 +25週之後 +3天之前 +2天之前 +1天之前 +0天 +1天之後 +2天之後 +3天之後 +5天之後 +10天之後 +11天之後 +12天之後 +20天之後 +21天之後 +22天之後 +23天之後 +25天之後 +3小時之前 +2小時之前 +1小時之前 +0小時 +1小時之後 +2小時之後 +3小時之後 +5小時之後 +10小時之後 +11小時之後 +12小時之後 +20小時之後 +21小時之後 +22小時之後 +23小時之後 +25小時之後 +3分鐘之前 +2分鐘之前 +1分鐘之前 +0分鐘 +1分鐘之後 +2分鐘之後 +3分鐘之後 +5分鐘之後 +10分鐘之後 +11分鐘之後 +12分鐘之後 +20分鐘之後 +21分鐘之後 +22分鐘之後 +23分鐘之後 +25分鐘之後 +3秒之前 +2秒之前 +1秒之前 +0秒 +1秒之後 +2秒之後 +3秒之後 +5秒之後 +10秒之後 +11秒之後 +12秒之後 +20秒之後 +21秒之後 +22秒之後 +23秒之後 +25秒之後 +3毫秒之前 +2毫秒之前 +1毫秒之前 +0毫秒 +1毫秒之後 +2毫秒之後 +3毫秒之後 +5毫秒之後 +10毫秒之後 +11毫秒之後 +12毫秒之後 +20毫秒之後 +21毫秒之後 +22毫秒之後 +23毫秒之後 +25毫秒之後 +=mediumFormTargets +3年 +3個月 +3週 +3天 +3小時 +3分鐘 +3秒 +3毫秒 +=shortFormTargets +3年 +3個月 +3週 +3天 +3小時 +3分鐘 +3秒 +3毫秒 +=customMinuteTargets +5分鐘 +1小時5分鐘 +10分鐘 +1小時10分鐘 +15分鐘 +1小時15分鐘 +20分鐘 +1小時20分鐘 +25分鐘 +1小時25分鐘 +30分鐘 +1小時30分鐘 +35分鐘 +1小時35分鐘 +40分鐘 +1小時40分鐘 +45分鐘 +1小時45分鐘 +50分鐘 +1小時50分鐘 +55分鐘 +1小時55分鐘 +=limitedUnitTargets +1個月 +1個月2週 +1個月2週3天 +1個月之前 +1個月2週之前 +1個月2週3天之前 +1個月之後 +1個月2週之後 +1個月2週3天之後 +少於1個月 +少於1個月2週 +少於1個月2週3天 +1個月以內 +1個月2週以內 +1個月2週3天以內 +即時起1個月以內 +即時起1個月2週以內 +即時起1個月2週3天以內 +超過1個月 +超過1個月2週 +超過1個月2週3天 +超過1個月之前 +超過1個月2週之前 +超過1個月2週3天之前 +即時起1個月之後 +即時起1個月2週之後 +即時起1個月2週3天之後 +1小時 +1小時2分鐘 +1小時2分3秒 +1小時之前 +1小時2分鐘之前 +1小時2分3秒之前 +1小時之後 +1小時2分鐘之後 +1小時2分3秒之後 +少於1小時 +少於1小時2分鐘 +少於1小時2分3秒 +1小時以內 +1小時2分鐘以內 +1小時2分3秒以內 +即時起1小時以內 +即時起1小時2分鐘以內 +即時起1小時2分3秒以內 +超過1小時 +超過1小時2分鐘 +超過1小時2分3秒 +超過1小時之前 +超過1小時2分鐘之前 +超過1小時2分3秒之前 +即時起1小時之後 +即時起1小時2分鐘之後 +即時起1小時2分3秒之後 +=halfUnitCounts +0 +1 +2 +5 +10 +11 +12 +20 +21 +22 +=halfUnitTargets +半年 +1年半 +2年半 +5年半 +10年半 +11年半 +12年半 +20年半 +21年半 +22年半 +半個月 +1個半月 +2個半月 +5個半月 +10個半月 +11個半月 +12個半月 +20個半月 +21個半月 +22個半月 +半週 +1週半 +2週半 +5週半 +10週半 +11週半 +12週半 +20週半 +21週半 +22週半 +半天 +1天半 +2天半 +5天半 +10天半 +11天半 +12天半 +20天半 +21天半 +22天半 +半小時 +1小時半 +2小時半 +5小時半 +10小時半 +11小時半 +12小時半 +20小時半 +21小時半 +22小時半 +半分鐘 +1分半鐘 +2分半鐘 +5分半鐘 +10分半鐘 +11分半鐘 +12分半鐘 +20分半鐘 +21分半鐘 +22分半鐘 +半秒 +1秒半 +2秒半 +5秒半 +10秒半 +11秒半 +12秒半 +20秒半 +21秒半 +22秒半 +半毫秒 +1毫秒半 +2毫秒半 +5毫秒半 +10毫秒半 +11毫秒半 +12毫秒半 +20毫秒半 +21毫秒半 +22毫秒半 +=fractionalUnitCounts +0.025 +1.0 +1.205 +2.125 +12.05 +=fractionalUnitTargets +0.02年 +1.00年 +1.20年 +2.12年 +12.05年 +0.02個月 +1.00個月 +1.20個月 +2.12個月 +12.05個月 +0.02週 +1.00週 +1.20週 +2.12週 +12.05週 +0.02天 +1.00天 +1.20天 +2.12天 +12.05天 +0.02小時 +1.00小時 +1.20小時 +2.12小時 +12.05小時 +0.02分鐘 +1.00分鐘 +1.20分鐘 +2.12分鐘 +12.05分鐘 +0.02秒 +1.00秒 +1.20秒 +2.12秒 +12.05秒 +0.02毫秒 +1.00毫秒 +1.20毫秒 +2.12毫秒 +12.05毫秒 +=multipleUnitTargets +1年2個月 +1年3週 +1年2個月3週 +1個月2週 +1個月3天 +1個月2週3天 +1週2天 +1週3小時 +1週2天3小時 +1天2小時 +1天3分鐘 +1天2小時3分鐘 +1小時2分鐘 +1小時3秒 +1小時2分3秒 +1分2秒 +1分3毫秒 +1分2秒3毫秒 +1秒2毫秒 diff --git a/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormat.java b/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormat.java new file mode 100644 index 00000000000..2c869c3a8ad --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormat.java @@ -0,0 +1,60 @@ +/* + ******************************************************************************* + * Copyright (C) 2007, International Business Machines Corporation and * + * others. All Rights Reserved. * + ******************************************************************************* + */ +package com.ibm.icu.impl.duration; + +import java.util.Date; + +import com.ibm.icu.text.DurationFormat; +import com.ibm.icu.util.ULocale; + +/** + * @author srl + * + */ +public class BasicDurationFormat extends DurationFormat { + + /** + * + */ + private static final long serialVersionUID = -3146984141909457700L; + + DurationFormatter formatter; + + public static DurationFormat getInstance(ULocale locale) { + return new BasicDurationFormat(locale); + } + + /** + * + */ + private BasicDurationFormat(ULocale locale) { + super(locale); + formatter = BasicPeriodFormatterService.getInstance().newDurationFormatterFactory().setLocale(locale.getName()).getFormatter(); + } + + /* (non-Javadoc) + * @see com.ibm.icu.text.DurationFormat#formatDurationFrom(long, long) + */ + public String formatDurationFrom(long duration, long referenceDate) { + return formatter.formatDurationFrom(duration, referenceDate); + } + + /* (non-Javadoc) + * @see com.ibm.icu.text.DurationFormat#formatDurationFromNow(long) + */ + public String formatDurationFromNow(long duration) { + return formatter.formatDurationFromNow(duration); + } + + /* (non-Javadoc) + * @see com.ibm.icu.text.DurationFormat#formatDurationFromNowTo(java.util.Date) + */ + public String formatDurationFromNowTo(Date targetDate) { + return formatter.formatDurationFromNowTo(targetDate); + } + +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormatter.java b/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormatter.java new file mode 100644 index 00000000000..74ffd5a5cbb --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormatter.java @@ -0,0 +1,118 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import java.util.Date; +import java.util.TimeZone; + +/** + * Core implementation class for DurationFormatter. + */ +class BasicDurationFormatter implements DurationFormatter { + private PeriodFormatter formatter; + private PeriodBuilder builder; + private DateFormatter fallback; + private long fallbackLimit; + private String localeName; + private TimeZone timeZone; + + /** + * Creates a basic duration formatter with the given formatter, + * builder, and fallback. It's up to the caller to ensure that + * the locales and timezones of these are in sync. + */ + public BasicDurationFormatter(PeriodFormatter formatter, + PeriodBuilder builder, + DateFormatter fallback, + long fallbackLimit) { + this.formatter = formatter; + this.builder = builder; + this.fallback = fallback; + this.fallbackLimit = fallbackLimit < 0 ? 0 : fallbackLimit; + } + + protected BasicDurationFormatter(PeriodFormatter formatter, + PeriodBuilder builder, + DateFormatter fallback, + long fallbackLimit, + String localeName, + TimeZone timeZone) { + this.formatter = formatter; + this.builder = builder; + this.fallback = fallback; + this.fallbackLimit = fallbackLimit; + this.localeName = localeName; + this.timeZone = timeZone; + } + + public String formatDurationFromNowTo(Date targetDate) { + long now = System.currentTimeMillis(); + long duration = now - targetDate.getTime(); + return formatDurationFrom(duration, now); + } + + public String formatDurationFromNow(long duration) { + return formatDurationFrom(duration, System.currentTimeMillis()); + } + + public String formatDurationFrom(long duration, long referenceDate) { + String s = doFallback(duration, referenceDate); + if (s == null) { + Period p = doBuild(duration, referenceDate); + s = doFormat(p); + } + return s; + } + + public DurationFormatter withLocale(String localeName) { + if (!localeName.equals(this.localeName)) { + PeriodFormatter newFormatter = formatter.withLocale(localeName); + PeriodBuilder newBuilder = builder.withLocale(localeName); + DateFormatter newFallback = fallback == null + ? null + : fallback.withLocale(localeName); + return new BasicDurationFormatter(newFormatter, newBuilder, + newFallback, fallbackLimit, + localeName, timeZone); + } + return this; + } + + public DurationFormatter withTimeZone(TimeZone timeZone) { + if (!timeZone.equals(this.timeZone)) { + PeriodBuilder newBuilder = builder.withTimeZone(timeZone); + DateFormatter newFallback = fallback == null + ? null + : fallback.withTimeZone(timeZone); + return new BasicDurationFormatter(formatter, newBuilder, + newFallback, fallbackLimit, + localeName, timeZone); + } + return this; + } + + protected String doFallback(long duration, long referenceDate) { + if (fallback != null + && fallbackLimit > 0 + && Math.abs(duration) >= fallbackLimit) { + return fallback.format(referenceDate + duration); + } + return null; + } + + protected Period doBuild(long duration, long referenceDate) { + return builder.createWithReferenceDate(duration, referenceDate); + } + + protected String doFormat(Period period) { + if (!period.isSet()) { + throw new IllegalArgumentException("period is not set"); + } + return formatter.format(period); + } +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormatterFactory.java b/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormatterFactory.java new file mode 100644 index 00000000000..6793feed1dd --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/BasicDurationFormatterFactory.java @@ -0,0 +1,236 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import java.util.Locale; +import java.util.TimeZone; + +/** + * Abstract factory object used to create DurationFormatters. + * DurationFormatters are immutable once created. + *

+ * Setters on the factory mutate the factory and return it, + * for chaining. + *

+ * Subclasses override getFormatter to return a custom + * DurationFormatter. + */ +class BasicDurationFormatterFactory implements DurationFormatterFactory { + private BasicPeriodFormatterService ps; + private PeriodFormatter formatter; + private PeriodBuilder builder; + private DateFormatter fallback; + private long fallbackLimit; + private String localeName; + private TimeZone timeZone; + private BasicDurationFormatter f; // cache + + /** + * Create a default formatter for the current locale and time zone. + */ + BasicDurationFormatterFactory(BasicPeriodFormatterService ps) { + this.ps = ps; + this.localeName = Locale.getDefault().toString(); + this.timeZone = TimeZone.getDefault(); + } + + /** + * Set the period formatter used by the factory. New formatters created + * with this factory will use the given period formatter. + * + * @param builder the builder to use + * @return this BasicDurationFormatterFactory + */ + public DurationFormatterFactory setPeriodFormatter( + PeriodFormatter formatter) { + if (formatter != this.formatter) { + this.formatter = formatter; + reset(); + } + return this; + } + + /** + * Set the builder used by the factory. New formatters created + * with this factory will use the given locale. + * + * @param builder the builder to use + * @return this BasicDurationFormatterFactory + */ + public DurationFormatterFactory setPeriodBuilder(PeriodBuilder builder) { + if (builder != this.builder) { + this.builder = builder; + reset(); + } + return this; + } + + /** + * Set a fallback formatter for durations over a given limit. + * + * @param fallback the fallback formatter to use, or null + * @return this BasicDurationFormatterFactory + */ + public DurationFormatterFactory setFallback(DateFormatter fallback) { + boolean doReset = fallback == null + ? this.fallback != null + : !fallback.equals(this.fallback); + if (doReset) { + this.fallback = fallback; + reset(); + } + return this; + } + + /** + * Set a fallback limit for durations over a given limit. + * + * @param fallbackLimit the fallback limit to use, or 0 if none is desired. + * @return this BasicDurationFormatterFactory + */ + public DurationFormatterFactory setFallbackLimit(long fallbackLimit) { + if (fallbackLimit < 0) { + fallbackLimit = 0; + } + if (fallbackLimit != this.fallbackLimit) { + this.fallbackLimit = fallbackLimit; + reset(); + } + return this; + } + + /** + * Set the name of the locale that will be used when + * creating new formatters. + * + * @param localeName the name of the Locale + * @return this BasicDurationFormatterFactory + */ + public DurationFormatterFactory setLocale(String localeName) { + if (!localeName.equals(this.localeName)) { + this.localeName = localeName; + reset(); + } + return this; + } + + /** + * Set the name of the locale that will be used when + * creating new formatters. + * + * @param localeName the name of the Locale + * @return this BasicDurationFormatterFactory + */ + public DurationFormatterFactory setTimeZone(TimeZone timeZone) { + if (!timeZone.equals(this.timeZone)) { + this.timeZone = timeZone; + reset(); + } + return this; + } + + /** + * Return a formatter based on this factory's current settings. + * + * @return a BasicDurationFormatter + */ + public DurationFormatter getFormatter() { + if (f == null) { + if (fallback != null) { + fallback = fallback.withLocale(localeName).withTimeZone(timeZone); + } + formatter = getPeriodFormatter() + .withLocale(localeName); + builder = getPeriodBuilder() + .withLocale(localeName) + .withTimeZone(timeZone); + + f = createFormatter(); + } + return f; + } + + /** + * Return the current period formatter. + * + * @return the current period formatter + */ + public PeriodFormatter getPeriodFormatter() { + if (formatter == null) { + formatter = ps.newPeriodFormatterFactory().getFormatter(); + } + return formatter; + } + + /** + * Return the current builder. + * + * @return the current builder + */ + public PeriodBuilder getPeriodBuilder() { + if (builder == null) { + builder = ps.newPeriodBuilderFactory().getSingleUnitBuilder(); + } + return builder; + } + + /** + * Return the current fallback formatter. + * + * @return the fallback formatter, or null if there is no fallback + * formatter + */ + public DateFormatter getFallback() { + return fallback; + } + + /** + * Return the current fallback formatter limit + * + * @return the limit, or 0 if there is no fallback. + */ + public long getFallbackLimit() { + return fallback == null ? 0 : fallbackLimit; + } + + /** + * Return the current locale name. + * + * @return the current locale name + */ + public String getLocaleName() { + return localeName; + } + + /** + * Return the current locale name. + * + * @return the current locale name + */ + public TimeZone getTimeZone() { + return timeZone; + } + + /** + * Create the formatter. All local fields are already initialized. + */ + protected BasicDurationFormatter createFormatter() { + return new BasicDurationFormatter(formatter, builder, fallback, + fallbackLimit, localeName, + timeZone); + } + + /** + * Clear the cached formatter. Subclasses must call this if their + * state has changed. This is automatically invoked by setBuilder, + * setFormatter, setFallback, setLocaleName, and setTimeZone + */ + protected void reset() { + f = null; + } +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/BasicPeriodBuilderFactory.java b/icu4j/src/com/ibm/icu/impl/duration/BasicPeriodBuilderFactory.java new file mode 100644 index 00000000000..7a4e6412972 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/BasicPeriodBuilderFactory.java @@ -0,0 +1,489 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import com.ibm.icu.impl.duration.impl.DataRecord; +import com.ibm.icu.impl.duration.impl.PeriodFormatterData; +import com.ibm.icu.impl.duration.impl.PeriodFormatterDataService; + +import java.util.Date; +import java.util.TimeZone; + +/** + * Default implementation of PeriodBuilderFactory. This creates builders that + * use approximate durations. + */ +class BasicPeriodBuilderFactory implements PeriodBuilderFactory { + private PeriodFormatterDataService ds; + private Settings settings; + + private static final short allBits = 0xff; + + BasicPeriodBuilderFactory(PeriodFormatterDataService ds) { + this.ds = ds; + this.settings = new Settings(); + } + + static long approximateDurationOf(TimeUnit unit) { + return TimeUnit.approxDurations[unit.ordinal]; + } + + class Settings { + boolean inUse; + short uset = allBits; + TimeUnit maxUnit = TimeUnit.YEAR; + TimeUnit minUnit = TimeUnit.MILLISECOND; + int maxLimit; + int minLimit; + boolean allowZero = true; + boolean weeksAloneOnly; + boolean useMilliseconds = true; + + Settings setUnits(int uset) { + if (this.uset == uset) { + return this; + } + Settings result = inUse ? copy() : this; + + result.uset = (short)uset; + + if ((uset & allBits) == allBits) { + result.uset = allBits; + result.maxUnit = TimeUnit.YEAR; + result.minUnit = TimeUnit.MILLISECOND; + } else { + int lastUnit = -1; + for (int i = 0; i < TimeUnit.units.length; ++i) { + if (0 != (uset & (1 << i))) { + if (lastUnit == -1) { + result.maxUnit = TimeUnit.units[i]; + } + lastUnit = i; + } + } + if (lastUnit == -1) { + // currently empty, but this might be transient so no fail + result.minUnit = result.maxUnit = null; + } else { + result.minUnit = TimeUnit.units[lastUnit]; + } + } + + return result; + } + + short effectiveSet() { + if (useMilliseconds) { + return uset; + } + return (short)(uset & ~(1 << TimeUnit.MILLISECOND.ordinal)); + } + + Settings setMaxLimit(float maxLimit) { + int val = maxLimit <= 0 ? 0 : (int)(maxLimit*1000); + if (maxLimit == val) { + return this; + } + Settings result = inUse ? copy() : this; + result.maxLimit = val; + return result; + } + + Settings setMinLimit(float minLimit) { + int val = minLimit <= 0 ? 0 : (int)(minLimit*1000); + if (minLimit == val) { + return this; + } + Settings result = inUse ? copy() : this; + result.minLimit = val; + return result; + } + + Settings setAllowZero(boolean allow) { + if (this.allowZero == allow) { + return this; + } + Settings result = inUse ? copy() : this; + result.allowZero = allow; + return result; + } + + Settings setWeeksAloneOnly(boolean weeksAlone) { + if (this.weeksAloneOnly == weeksAlone) { + return this; + } + Settings result = inUse ? copy() : this; + result.weeksAloneOnly = weeksAlone; + return result; + } + + Settings setAllowMilliseconds(boolean useMilliseconds) { + if (this.useMilliseconds == useMilliseconds) { + return this; + } + Settings result = inUse ? copy() : this; + result.useMilliseconds = useMilliseconds; + return result; + } + + Settings setLocale(String localeName) { + PeriodFormatterData data = ds.get(localeName); + return this + .setAllowZero(data.allowZero()) + .setWeeksAloneOnly(data.weeksAloneOnly()) + .setAllowMilliseconds(data.useMilliseconds() != DataRecord.EMilliSupport.NO); + } + + Settings setInUse() { + inUse = true; + return this; + } + + Period createLimited(long duration, boolean inPast) { + long maxUnitDuration = approximateDurationOf(maxUnit); + if (maxLimit > 0 && duration * 1000 > maxLimit * maxUnitDuration) { + return Period.moreThan(maxLimit/1000f, maxUnit).inPast(inPast); + } + long minUnitDuration = approximateDurationOf(minUnit); + if (minLimit > 0 && duration * 1000 < minLimit * minUnitDuration) { + return Period.lessThan(minLimit/1000f, minUnit).inPast(inPast); + } + return null; + } + + public Settings copy() { + Settings result = new Settings(); + result.inUse = inUse; + result.uset = uset; + result.maxUnit = maxUnit; + result.minUnit = minUnit; + result.maxLimit = maxLimit; + result.minLimit = minLimit; + result.allowZero = allowZero; + result.weeksAloneOnly = weeksAloneOnly; + result.useMilliseconds = useMilliseconds; + return result; + } + } + + public PeriodBuilderFactory setAvailableUnitRange(TimeUnit minUnit, + TimeUnit maxUnit) { + int uset = 0; + for (int i = maxUnit.ordinal; i <= minUnit.ordinal; ++i) { + uset |= 1 << i; + } + if (uset == 0) { + throw new IllegalArgumentException("range " + minUnit + " to " + maxUnit + " is empty"); + } + settings = settings.setUnits(uset); + return this; + } + + public PeriodBuilderFactory setUnitIsAvailable(TimeUnit unit, + boolean available) { + int uset = settings.uset; + if (available) { + uset |= 1 << unit.ordinal; + } else { + uset &= ~(1 << unit.ordinal); + } + settings = settings.setUnits(uset); + return this; + } + + public PeriodBuilderFactory setMaxLimit(float maxLimit) { + settings = settings.setMaxLimit(maxLimit); + return this; + } + + public PeriodBuilderFactory setMinLimit(float minLimit) { + settings = settings.setMinLimit(minLimit); + return this; + } + + public PeriodBuilderFactory setAllowZero(boolean allow) { + settings = settings.setAllowZero(allow); + return this; + } + + public PeriodBuilderFactory setWeeksAloneOnly(boolean aloneOnly) { + settings = settings.setWeeksAloneOnly(aloneOnly); + return this; + } + + public PeriodBuilderFactory setAllowMilliseconds(boolean useMilliseconds) { + settings = settings.setAllowMilliseconds(useMilliseconds); + return this; + } + + public PeriodBuilderFactory setLocale(String localeName) { + settings = settings.setLocale(localeName); + return this; + } + + private Settings getSettings() { + if (settings.effectiveSet() == 0) { + return null; + } + return settings.setInUse(); + } + + /** + * Return a builder that represents relative time in terms of the single + * given TimeUnit + * + * @param unit the single TimeUnit with which to represent times + * @return a builder + */ + public PeriodBuilder getFixedUnitBuilder(TimeUnit unit) { + return FixedUnitBuilder.get(unit, getSettings()); + } + + /** + * Return a builder that represents relative time in terms of the + * largest period less than or equal to the duration. + * + * @return a builder + */ + public PeriodBuilder getSingleUnitBuilder() { + return SingleUnitBuilder.get(getSettings()); + } + + /** + * Return a builder that formats the largest one or two periods, + * Starting with the largest period less than or equal to the duration. + * It formats two periods if the first period has a count < 2 + * and the next period has a count >= 1. + * + * @return a builder + */ + public PeriodBuilder getOneOrTwoUnitBuilder() { + return OneOrTwoUnitBuilder.get(getSettings()); + } + + /** + * Return a builder that formats the given number of periods, + * starting with the largest period less than or equal to the + * duration. + * + * @return a builder + */ + public PeriodBuilder getMultiUnitBuilder(int periodCount) { + return MultiUnitBuilder.get(periodCount, getSettings()); + } +} + +abstract class PeriodBuilderImpl implements PeriodBuilder { + + protected BasicPeriodBuilderFactory.Settings settings; + + public Period create(long duration) { + return createWithReferenceDate(duration, System.currentTimeMillis()); + } + + public long approximateDurationOf(TimeUnit unit) { + return BasicPeriodBuilderFactory.approximateDurationOf(unit); + } + + public Period createWithReferenceDate(long duration, long referenceDate) { + boolean inPast = duration < 0; + if (inPast) { + duration = -duration; + } + Period ts = settings.createLimited(duration, inPast); + if (ts == null) { + ts = handleCreate(duration, referenceDate, inPast); + if (ts == null) { + ts = Period.lessThan(1, settings.minUnit).inPast(inPast); + } + } + return ts; + } + + public PeriodBuilder withTimeZone(TimeZone timeZone) { + // ignore the time zone + return this; + } + + public PeriodBuilder withLocale(String localeName) { + BasicPeriodBuilderFactory.Settings newSettings = settings.setLocale(localeName); + if (newSettings != settings) { + return withSettings(newSettings); + } + return this; + } + + protected abstract PeriodBuilder withSettings(BasicPeriodBuilderFactory.Settings settings); + + protected abstract Period handleCreate(long duration, long referenceDate, + boolean inPast); + + protected PeriodBuilderImpl(BasicPeriodBuilderFactory.Settings settings) { + this.settings = settings; + } +} + +class FixedUnitBuilder extends PeriodBuilderImpl { + private TimeUnit unit; + + public static FixedUnitBuilder get(TimeUnit unit, BasicPeriodBuilderFactory.Settings settings) { + if (settings != null && (settings.effectiveSet() & (1 << unit.ordinal)) != 0) { + return new FixedUnitBuilder(unit, settings); + } + return null; + } + + FixedUnitBuilder(TimeUnit unit, BasicPeriodBuilderFactory.Settings settings) { + super(settings); + this.unit = unit; + } + + protected PeriodBuilder withSettings(BasicPeriodBuilderFactory.Settings settings) { + return get(unit, settings); + } + + protected Period handleCreate(long duration, long referenceDate, + boolean inPast) { + if (unit == null) { + return null; + } + long unitDuration = approximateDurationOf(unit); + return Period.at((float)((double)duration/unitDuration), unit) + .inPast(inPast); + } +} + +class SingleUnitBuilder extends PeriodBuilderImpl { + SingleUnitBuilder(BasicPeriodBuilderFactory.Settings settings) { + super(settings); + } + + public static SingleUnitBuilder get(BasicPeriodBuilderFactory.Settings settings) { + if (settings == null) { + return null; + } + return new SingleUnitBuilder(settings); + } + + protected PeriodBuilder withSettings(BasicPeriodBuilderFactory.Settings settings) { + return SingleUnitBuilder.get(settings); + } + + protected Period handleCreate(long duration, long referenceDate, + boolean inPast) { + short uset = settings.effectiveSet(); + for (int i = 0; i < TimeUnit.units.length; ++i) { + if (0 != (uset & (1 << i))) { + TimeUnit unit = TimeUnit.units[i]; + long unitDuration = approximateDurationOf(unit); + if (duration >= unitDuration) { + return Period.at((float)((double)duration/unitDuration), unit) + .inPast(inPast); + } + } + } + return null; + } +} + +class OneOrTwoUnitBuilder extends PeriodBuilderImpl { + OneOrTwoUnitBuilder(BasicPeriodBuilderFactory.Settings settings) { + super(settings); + } + + public static OneOrTwoUnitBuilder get(BasicPeriodBuilderFactory.Settings settings) { + if (settings == null) { + return null; + } + return new OneOrTwoUnitBuilder(settings); + } + + protected PeriodBuilder withSettings(BasicPeriodBuilderFactory.Settings settings) { + return OneOrTwoUnitBuilder.get(settings); + } + + protected Period handleCreate(long duration, long referenceDate, + boolean inPast) { + Period period = null; + short uset = settings.effectiveSet(); + for (int i = 0; i < TimeUnit.units.length; ++i) { + if (0 != (uset & (1 << i))) { + TimeUnit unit = TimeUnit.units[i]; + long unitDuration = approximateDurationOf(unit); + if (duration >= unitDuration || period != null) { + double count = (double)duration/unitDuration; + if (period == null) { + if (count >= 2) { + period = Period.at((float)count, unit); + break; + } + period = Period.at(1, unit).inPast(inPast); + duration -= unitDuration; + } else { + if (count >= 1) { + period.and((float)count, unit); + } + break; + } + } + } + } + return period; + } +} + +class MultiUnitBuilder extends PeriodBuilderImpl { + private int nPeriods; + + MultiUnitBuilder(int nPeriods, BasicPeriodBuilderFactory.Settings settings) { + super(settings); + this.nPeriods = nPeriods; + } + + public static MultiUnitBuilder get(int nPeriods, BasicPeriodBuilderFactory.Settings settings) { + if (nPeriods > 0 && settings != null) { + return new MultiUnitBuilder(nPeriods, settings); + } + return null; + } + + protected PeriodBuilder withSettings(BasicPeriodBuilderFactory.Settings settings) { + return MultiUnitBuilder.get(nPeriods, settings); + } + + protected Period handleCreate(long duration, long referenceDate, + boolean inPast) { + Period period = null; + int n = 0; + short uset = settings.effectiveSet(); + for (int i = 0; i < TimeUnit.units.length; ++i) { + if (0 != (uset & (1 << i))) { + TimeUnit unit = TimeUnit.units[i]; + if (n == nPeriods) { + break; + } + long unitDuration = approximateDurationOf(unit); + if (duration >= unitDuration || n > 0) { + ++n; + double count = (double)duration / unitDuration; + if (n < nPeriods) { + count = Math.floor(count); + duration -= (long)(count * unitDuration); + } + if (period == null) { + period = Period.at((float)count, unit).inPast(inPast); + } else { + period.and((float)count, unit); + } + } + } + } + return period; + } +} + diff --git a/icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatter.java b/icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatter.java new file mode 100644 index 00000000000..cbd7de73cea --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatter.java @@ -0,0 +1,199 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import com.ibm.icu.impl.duration.BasicPeriodFormatterFactory.Customizations; + +import com.ibm.icu.impl.duration.impl.DataRecord.ETimeLimit; +import com.ibm.icu.impl.duration.impl.DataRecord.ETimeDirection; +import com.ibm.icu.impl.duration.impl.DataRecord.EUnitVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.ECountVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.ESeparatorVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.EMilliSupport; +import com.ibm.icu.impl.duration.impl.PeriodFormatterData; + +import java.util.Date; + +/** + * Core implementation class for PeriodFormatter. + */ +class BasicPeriodFormatter implements PeriodFormatter { + private BasicPeriodFormatterFactory factory; + private String localeName; + private PeriodFormatterData data; + private Customizations customs; + + BasicPeriodFormatter(BasicPeriodFormatterFactory factory, + String localeName, + PeriodFormatterData data, + Customizations customs) { + this.factory = factory; + this.localeName = localeName; + this.data = data; + this.customs = customs; + } + + public String format(Period period) { + if (!period.isSet()) { + throw new IllegalArgumentException("period is not set"); + } + return format(period.timeLimit, period.inFuture, period.counts); + } + + public PeriodFormatter withLocale(String localeName) { + if (!this.localeName.equals(localeName)) { + PeriodFormatterData newData = factory.getData(localeName); + return new BasicPeriodFormatter(factory, localeName, newData, + customs); + } + return this; + } + + private String format(int tl, boolean inFuture, int[] counts) { + int mask = 0; + for (int i = 0; i < counts.length; ++i) { + if (counts[i] > 0) { + mask |= 1 << i; + } + } + + // if the data does not allow formatting of zero periods, + // remove these from consideration. If the result has no + // periods set, return null to indicate we could not format + // the duration. + if (!data.allowZero()) { + for (int i = 0, m = 1; i < counts.length; ++i, m <<= 1) { + if ((mask & m) != 0 && counts[i] == 1) { + mask &= ~m; + } + } + if (mask == 0) { + return null; + } + } + + // if the data does not allow milliseconds but milliseconds are + // set, merge them with seconds and force display of seconds to + // decimal with 3 places. + boolean forceD3Seconds = false; + if (data.useMilliseconds() != EMilliSupport.YES && + (mask & (1 << TimeUnit.MILLISECOND.ordinal)) != 0) { + int sx = TimeUnit.SECOND.ordinal; + int mx = TimeUnit.MILLISECOND.ordinal; + int sf = 1 << sx; + int mf = 1 << mx; + switch (data.useMilliseconds()) { + case EMilliSupport.WITH_SECONDS: { + // if there are seconds, merge with seconds, otherwise leave alone + if ((mask & sf) != 0) { + counts[sx] += (counts[mx]-1)/1000; + mask &= ~mf; + forceD3Seconds = true; + } + } break; + case EMilliSupport.NO: { + // merge with seconds, reset seconds before use just in case + if ((mask & sf) == 0) { + mask |= sf; + counts[sx] = 1; + } + counts[sx] += (counts[mx]-1)/1000; + mask &= ~mf; + forceD3Seconds = true; + } break; + } + } + + // get the first and last units that are set. + int first = 0; + int last = counts.length - 1; + while (first < counts.length && (mask & (1 << first)) == 0) ++first; + while (last > first && (mask & (1 << last)) == 0) --last; + + // determine if there is any non-zero unit + boolean isZero = true; + for (int i = first; i <= last; ++i) { + if (((mask & (1 << i)) != 0) && counts[i] > 1) { + isZero = false; + break; + } + } + + StringBuilder sb = new StringBuilder(); + + // if we've been requested to not display a limit, or there are + // no non-zero units, do not display the limit. + if (!customs.displayLimit || isZero) { + tl = ETimeLimit.NOLIMIT; + } + + // if we've been requested to not display the direction, or there + // are no non-zero units, do not display the direction. + int td; + if (!customs.displayDirection || isZero) { + td = ETimeDirection.NODIRECTION; + } else { + td = inFuture ? ETimeDirection.FUTURE : ETimeDirection.PAST; + } + + // format the initial portion of the string before the units. + // record whether we need to use a digit prefix (because the + // initial portion forces it) + boolean useDigitPrefix = data.appendPrefix(tl, td, sb); + + // determine some formatting params and initial values + boolean multiple = first != last; + boolean wasSkipped = true; // no initial skip marker + boolean skipped = false; + boolean countSep = customs.separatorVariant != ESeparatorVariant.NONE; + + // loop for formatting the units + for (int i = first, j = i; i <= last; i = j) { + if (skipped) { + // we didn't format the previous unit + data.appendSkippedUnit(sb); + skipped = false; + wasSkipped = true; + } + + while (++j < last && (mask & (1 << j)) == 0) { + skipped = true; // skip + } + + TimeUnit unit = TimeUnit.units[i]; + int count = counts[i] - 1; + + int cv = customs.countVariant; + if (i == last) { + if (forceD3Seconds) { + cv = ECountVariant.DECIMAL3; + } + // else leave unchanged + } else { + cv = ECountVariant.INTEGER; + } + boolean isLast = i == last; + boolean mustSkip = data.appendUnit(unit, count, cv, customs.unitVariant, + countSep, useDigitPrefix, multiple, isLast, wasSkipped, sb); + skipped |= mustSkip; + wasSkipped = false; + + if (customs.separatorVariant != ESeparatorVariant.NONE && j <= last) { + boolean afterFirst = i == first; + boolean beforeLast = j == last; + boolean fullSep = customs.separatorVariant == ESeparatorVariant.FULL; + useDigitPrefix = data.appendUnitSeparator(unit, fullSep, afterFirst, beforeLast, sb); + } else { + useDigitPrefix = false; + } + } + data.appendSuffix(tl, td, sb); + + return sb.toString(); + } +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatterFactory.java b/icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatterFactory.java new file mode 100644 index 00000000000..f5862ff402c --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatterFactory.java @@ -0,0 +1,234 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import com.ibm.icu.impl.duration.impl.PeriodFormatterData; +import com.ibm.icu.impl.duration.impl.PeriodFormatterDataService; + +import com.ibm.icu.impl.duration.impl.DataRecord.EUnitVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.ECountVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.ESeparatorVariant; + +import java.util.Locale; + +/** + * An implementation of PeriodFormatterFactory that provides customization of + * formatting behavior. Instances of this factory are created by + * BasicPeriodFormatterService. + * + * The settings on BasicPeriodFormatterFactory are: + *

    + * + *
  • setDisplayLimit controls whether phrases like 'more than' + * or 'less than' will be displayed when the Period has a defined + * limit. Default is to display them.
  • + * + *
  • setDisplayPastFuture controls whether phrases like 'ago' + * or 'from now' will be displayed to indicate past or future + * time. Default is to display them.
  • + * + *
  • setSeparatorVariant controls how separators (between + * count and period, and multiple periods) will be displayed, when + * appropriate for the language. Default is to use full + * separators.
  • + * + *
  • setUnitVariant controls which of various types of + * unit names to use. PLURALIZED indicates that full names will be + * used. MEDIUM indicates that medium-length (usually 2-3 character) + * names will be used. SHORT indicates that short (usually single + * character) names will be used. If there is no localization data + * available for either the SHORT or MEDIUM names, the other will be + * used, if neither is available, the PLURALIZED names will be used. + * Default is PLURALIZED.
  • + * + *
  • setCountVariant controls how the count for the smallest + * unit will be formatted: either as an integer, a fraction to the + * smallest half, or as a decimal with 1, 2, or 3 decimal points.
  • + * Counts for higher units will be formatted as integers. + * + *
+ */ +public class BasicPeriodFormatterFactory implements PeriodFormatterFactory { + private final PeriodFormatterDataService ds; + private PeriodFormatterData data; + private Customizations customizations; + private boolean customizationsInUse; + private String localeName; + + // package-only constructor + BasicPeriodFormatterFactory(PeriodFormatterDataService ds) { + this.ds = ds; + this.customizations = new Customizations(); + this.localeName = Locale.getDefault().toString(); + } + + /** + * Return the default rdf factory as a BasicPeriodFormatterFactory. + * + * @return a default BasicPeriodFormatterFactory + */ + public static BasicPeriodFormatterFactory getDefault() { + return (BasicPeriodFormatterFactory) + BasicPeriodFormatterService.getInstance().newPeriodFormatterFactory(); + } + + /** + * Set the locale for this factory. + */ + public PeriodFormatterFactory setLocale(String localeName) { + data = null; + this.localeName = localeName; + return this; + } + + /** + * Set whether limits will be displayed. + * + * @param display true if limits will be displayed + * @return this PeriodFormatterFactory + */ + public PeriodFormatterFactory setDisplayLimit(boolean display) { + updateCustomizations().displayLimit = display; + return this; + } + + /** + * Return true if limits will be displayed. + * + * @return true if limits will be displayed + */ + public boolean getDisplayLimit() { + return customizations.displayLimit; + } + + /** + * Set whether past and future will be displayed. + * + * @param display true if past and future will be displayed + * @return this PeriodFormatterFactory + */ + public PeriodFormatterFactory setDisplayPastFuture(boolean display) { + updateCustomizations().displayDirection = display; + return this; + } + + /** + * Return true if past and future will be displayed. + * + * @return true if past and future will be displayed + */ + public boolean getDisplayPastFuture() { + return customizations.displayDirection; + } + + /** + * Set how separators will be displayed. + * + * @param variant the variant indicating separators will be displayed + * @return this PeriodFormatterFactory + */ + public PeriodFormatterFactory setSeparatorVariant(int variant) { + updateCustomizations().separatorVariant = (byte) variant; + return this; + } + + /** + * Return the variant indicating how separators will be displayed. + * + * @return the variant + */ + public int getSeparatorVariant() { + return customizations.separatorVariant; + } + + /** + * Set the variant of the time unit names to use. + * + * @param variant the variant to use + * @return this PeriodFormatterFactory + */ + public PeriodFormatterFactory setUnitVariant(int variant) { + updateCustomizations().unitVariant = (byte) variant; + return this; + } + + /** + * Return the unit variant. + * + * @return the unit variant + */ + public int getUnitVariant() { + return customizations.unitVariant; + } + + /** + * Set the variant of the count to use. + * + * @param variant the variant to use + * @return this PeriodFormatterFactory + */ + public PeriodFormatterFactory setCountVariant(int variant) { + updateCustomizations().countVariant = (byte) variant; + return this; + } + + /** + * Return the count variant. + * + * @return the count variant + */ + public int getCountVariant() { + return customizations.countVariant; + } + + public PeriodFormatter getFormatter() { + customizationsInUse = true; + return new BasicPeriodFormatter(this, localeName, getData(), + customizations); + } + + private Customizations updateCustomizations() { + if (customizationsInUse) { + customizations = customizations.copy(); + customizationsInUse = false; + } + return customizations; + } + + // package access only + PeriodFormatterData getData() { + if (data == null) { + data = ds.get(localeName); + } + return data; + } + + // package access for use by BasicPeriodFormatter + PeriodFormatterData getData(String localeName) { + return ds.get(localeName); + } + + // package access for use by BasicPeriodFormatter + static class Customizations { + boolean displayLimit = true; + boolean displayDirection = true; + byte separatorVariant = ESeparatorVariant.FULL; + byte unitVariant = EUnitVariant.PLURALIZED; + byte countVariant = ECountVariant.INTEGER; + + public Customizations copy() { + Customizations result = new Customizations(); + result.displayLimit = displayLimit; + result.displayDirection = displayDirection; + result.separatorVariant = separatorVariant; + result.unitVariant = unitVariant; + result.countVariant = countVariant; + return result; + } + } +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatterService.java b/icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatterService.java new file mode 100644 index 00000000000..a9dca28e2de --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/BasicPeriodFormatterService.java @@ -0,0 +1,63 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import com.ibm.icu.impl.duration.impl.PeriodFormatterDataService; +import com.ibm.icu.impl.duration.impl.ResourceBasedPeriodFormatterDataService; + +import java.util.Collection; + +/** + * An implementation of PeriodFormatterService that constructs a + * BasicPeriodFormatterFactory. + */ +public class BasicPeriodFormatterService implements PeriodFormatterService { + private static BasicPeriodFormatterService instance; + private PeriodFormatterDataService ds; + + /** + * Return the default service instance. This uses the + * default data service. + * + * @return an BasicPeriodFormatterService + */ + public static BasicPeriodFormatterService getInstance() { + if (instance == null) { + PeriodFormatterDataService ds = + ResourceBasedPeriodFormatterDataService.getInstance(); + instance = new BasicPeriodFormatterService(ds); + } + return instance; + } + + /** + * Construct a BasicPeriodFormatterService using the given + * PeriodFormatterDataService. + * + * @param ds the data service to use + */ + public BasicPeriodFormatterService(PeriodFormatterDataService ds) { + this.ds = ds; + } + + public DurationFormatterFactory newDurationFormatterFactory() { + return new BasicDurationFormatterFactory(this); + } + + public PeriodFormatterFactory newPeriodFormatterFactory() { + return new BasicPeriodFormatterFactory(ds); + } + + public PeriodBuilderFactory newPeriodBuilderFactory() { + return new BasicPeriodBuilderFactory(ds); + } + + public Collection getAvailableLocaleNames() { + return ds.getAvailableLocales(); + } +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/DateFormatter.java b/icu4j/src/com/ibm/icu/impl/duration/DateFormatter.java new file mode 100644 index 00000000000..9f04d29430c --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/DateFormatter.java @@ -0,0 +1,52 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +/** + * Abstract formatter for dates. Differs from DateFormat in that it + * provides withLocale and withTimeZone methods. + */ +public interface DateFormatter { + + /** + * Format the date, provided as a java Date object. + * + * @param date the date + * @return the formatted time + */ + String format(Date date); + + /** + * Format the date, provided as milliseconds. + * + * @param date the date in milliseconds + * @return the formatted time + */ + String format(long date); + + /** + * Returns a new DateFormatter that uses data for a new locale. + * + * @param locale the new locale to use + * @return a new formatter for the given locale + */ + DateFormatter withLocale(String localeName); + + /** + * Returns a new DateFormatter that uses the new time zone. + * + * @param tz the new time zone + * @return a new formatter for the given time zone + */ + DateFormatter withTimeZone(TimeZone tz); +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/DurationFormatter.java b/icu4j/src/com/ibm/icu/impl/duration/DurationFormatter.java new file mode 100644 index 00000000000..d78d80c7976 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/DurationFormatter.java @@ -0,0 +1,76 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import java.util.Date; +import java.util.TimeZone; + +/** + * Formatter for durations in milliseconds. + */ +public interface DurationFormatter { + + /** + * Formats the duration between now and a target date. + *

+ * This is a convenience method that calls + * formatDurationFrom(long, long) using now + * as the reference date, and the difference between now and + * targetDate.getTime() as the duration. + * + * @param targetDate the ending date + * @return the formatted time + */ + String formatDurationFromNowTo(Date targetDate); + + /** + * Formats a duration expressed in milliseconds. + *

+ * This is a convenience method that calls formatDurationFrom + * using the current system time as the reference date. + * + * @param duration the duration in milliseconds + * @param tz the time zone + * @return the formatted time + */ + String formatDurationFromNow(long duration); + + /** + * Formats a duration expressed in milliseconds from a reference date. + *

+ * The reference date allows formatters to use actual durations of + * variable-length periods (like months) if they wish. + *

+ * The duration is expressed as the number of milliseconds in the + * past (negative values) or future (positive values) with respect + * to a reference date (expressed as milliseconds in epoch). + * + * @param duration the duration in milliseconds + * @param referenceDate the date from which to compute the duration + * @return the formatted time + */ + String formatDurationFrom(long duration, long referenceDate); + + /** + * Returns a new DurationFormatter that's the same as this one + * but formats for a new locale. + * + * @param localeName the name of the new locale + * @return a new formatter for the given locale + */ + DurationFormatter withLocale(String localeName); + + /** + * Returns a new DurationFormatter that's the same as this one but + * uses a different time zone. + * + * @param tz the time zone in which to compute durations. + * @return a new formatter for the given locale + */ + DurationFormatter withTimeZone(TimeZone tz); +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/DurationFormatterFactory.java b/icu4j/src/com/ibm/icu/impl/duration/DurationFormatterFactory.java new file mode 100644 index 00000000000..38a2de4d910 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/DurationFormatterFactory.java @@ -0,0 +1,79 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import java.util.TimeZone; + +/** + * Factory used to construct DurationFormatters. + * Formatters are immutable once created. + *

+ * Setters on the factory mutate the factory and return it, + * for chaining. + */ +public interface DurationFormatterFactory { + + /** + * Set the period formatter used by the factory. New formatters created + * with this factory will use the given period formatter. + * + * @param builder the builder to use + * @return this DurationFormatterFactory + */ + public DurationFormatterFactory setPeriodFormatter(PeriodFormatter formatter); + + /** + * Set the builder used by the factory. New formatters created + * with this factory will use the given locale. + * + * @param builder the builder to use + * @return this DurationFormatterFactory + */ + public DurationFormatterFactory setPeriodBuilder(PeriodBuilder builder); + + /** + * Set a fallback formatter for durations over a given limit. + * + * @param fallback the fallback formatter to use, or null + * @return this DurationFormatterFactory + */ + public DurationFormatterFactory setFallback(DateFormatter fallback); + + /** + * Set a fallback limit for durations over a given limit. + * + * @param fallbackLimit the fallback limit to use, or 0 if none is desired. + * @return this DurationFormatterFactory + */ + public DurationFormatterFactory setFallbackLimit(long fallbackLimit); + + /** + * Set the name of the locale that will be used when + * creating new formatters. + * + * @param localeName the name of the Locale + * @return this DurationFormatterFactory + */ + public DurationFormatterFactory setLocale(String localeName); + + /** + * Set the name of the locale that will be used when + * creating new formatters. + * + * @param localeName the name of the Locale + * @return this DurationFormatterFactory + */ + public DurationFormatterFactory setTimeZone(TimeZone timeZone); + + /** + * Return a formatter based on this factory's current settings. + * + * @return a DurationFormatter + */ + public DurationFormatter getFormatter(); +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/Period.java b/icu4j/src/com/ibm/icu/impl/duration/Period.java new file mode 100644 index 00000000000..427de068644 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/Period.java @@ -0,0 +1,373 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import com.ibm.icu.impl.duration.impl.DataRecord.ETimeLimit; + +/** + * Represents an approximate duration in multiple TimeUnits. Each unit, + * if set, has a count (which can be fractional and must be non-negative). + * In addition Period can either represent the duration as being into the past + * or future, and as being more or less than the defined value. + *

+ * Use a PeriodFormatter to convert a Period to a String. + *

+ * Periods are immutable. Mutating operations return the new + * result leaving the original unchanged. + *

+ * Example:

+ * Period p1 = Period.at(3, WEEK).and(2, DAY).inFuture();
+ * Period p2 = p1.and(12, HOUR);
+ */ +public final class Period { + final byte timeLimit; + final boolean inFuture; + final int[] counts; + + /** + * Constructs a Period representing a duration of + * count units extending into the past. + * @param count the number of units, must be non-negative + * @param unit the unit + * @return the new Period + */ + public static Period at(float count, TimeUnit unit) { + checkCount(count); + return new Period(ETimeLimit.NOLIMIT, false, count, unit); + } + + /** + * Constructs a Period representing a duration more than + * count units extending into the past. + * @param count the number of units. must be non-negative + * @param unit the unit + * @return the new Period + */ + public static Period moreThan(float count, TimeUnit unit) { + checkCount(count); + return new Period(ETimeLimit.MT, false, count, unit); + } + + /** + * Constructs a Period representing a duration + * less than count units extending into the past. + * @param count the number of units. must be non-negative + * @param unit the unit + * @return the new Period + */ + public static Period lessThan(float count, TimeUnit unit) { + checkCount(count); + return new Period(ETimeLimit.LT, false, count, unit); + } + + /** + * Set the given unit to have the given count. Marks the + * unit as having been set. This can be used to set + * multiple units, or to reset a unit to have a new count. + * This does not add the count to an existing count + * for this unit. + * + * @param count the number of units. must be non-negative + * @param unit the unit + * @return the new Period + */ + public Period and(float count, TimeUnit unit) { + checkCount(count); + return setTimeUnitValue(unit, count); + } + + /** + * Mark the given unit as not being set. + * + * @param unit the unit to unset + * @return the new Period + */ + public Period omit(TimeUnit unit) { + return setTimeUnitInternalValue(unit, 0); + } + + /** + * Mark the duration as being at the defined duration. + * + * @return the new Period + */ + public Period at() { + return setTimeLimit(ETimeLimit.NOLIMIT); + } + + /** + * Mark the duration as being more than the defined duration. + * + * @return the new Period + */ + public Period moreThan() { + return setTimeLimit(ETimeLimit.MT); + } + + /** + * Mark the duration as being less than the defined duration. + * + * @return the new Period + */ + public Period lessThan() { + return setTimeLimit(ETimeLimit.LT); + } + + /** + * Mark the time as being in the future. + * + * @return the new Period + */ + public Period inFuture() { + return setFuture(true); + } + + /** + * Mark the duration as extending into the past. + * + * @return the new Period + */ + public Period inPast() { + return setFuture(false); + } + + /** + * Mark the duration as extending into the future if + * future is true, and into the past otherwise. + * + * @param future true if the time is in the future + * @return the new Period + */ + public Period inFuture(boolean future) { + return setFuture(future); + } + + /** + * Mark the duration as extending into the past if + * past is true, and into the future otherwise. + * + * @param past true if the time is in the past + * @return the new Period + */ + public Period inPast(boolean past) { + return setFuture(!past); + } + + /** + * Returns true if any unit is set. + * @return true if any unit is set + */ + public boolean isSet() { + for (int i = 0; i < counts.length; ++i) { + if (counts[i] != 0) { + return true; + } + } + return false; + } + + /** + * Returns true if the given unit is set. + * @param unit the unit to test + * @return true if the given unit is set. + */ + public boolean isSet(TimeUnit unit) { + return counts[unit.ordinal] > 0; + } + + /** + * Returns the count for the specified unit. If the + * unit is not set, returns 0. + * @param unit the unit to test + * @return the count + */ + public float getCount(TimeUnit unit) { + int ord = unit.ordinal; + if (counts[ord] == 0) { + return 0; + } + return (counts[ord] - 1)/1000f; + } + + /** + * Returns true if this represents a + * duration into the future. + * @return true if this represents a + * duration into the future. + */ + public boolean isInFuture() { + return inFuture; + } + + /** + * Returns true if this represents a + * duration into the past + * @return true if this represents a + * duration into the past + */ + public boolean isInPast () { + return !inFuture; + } + + /** + * Returns true if this represents a duration in + * excess of the defined duration. + * @return true if this represents a duration in + * excess of the defined duration. + */ + public boolean isMoreThan() { + return timeLimit == ETimeLimit.MT; + } + + /** + * Returns true if this represents a duration + * less than the defined duration. + * @return true if this represents a duration + * less than the defined duration. + */ + public boolean isLessThan() { + return timeLimit == ETimeLimit.LT; + } + + /** + * Returns true if rhs extends Period and + * the two Periods are equal. + * @param rhs the object to compare to + * @return true if rhs is a Period and is equal to this + */ + public boolean equals(Object rhs) { + try { + return equals((Period)rhs); + } + catch (ClassCastException e) { + return false; + } + } + + /** + * Returns true if the same units are defined with + * the same counts, both extend into the future or both into the + * past, and if the limits (at, more than, less than) are the same. + * Note that this means that a period of 1000ms and a period of 1sec + * will not compare equal. + * + * @param rhs the period to compare to + * @return true if the two periods are equal + */ + public boolean equals(Period rhs) { + if (rhs != null && + this.timeLimit == rhs.timeLimit && + this.inFuture == rhs.inFuture) { + for (int i = 0; i < counts.length; ++i) { + if (counts[i] != rhs.counts[i]) { + return false; + } + } + return true; + } + return false; + } + + /** + * Returns the hashCode. + * @return the hashCode + */ + public int hashCode() { + int hc = (timeLimit << 1) | (inFuture ? 1 : 0); + for (int i = 0; i < counts.length; ++i) { + hc = (hc << 2) ^ counts[i]; + } + return hc; + } + + /** + * Private constructor used by static factory methods. + */ + private Period(int limit, boolean future, float count, TimeUnit unit) { + this.timeLimit = (byte) limit; + this.inFuture = future; + this.counts = new int[TimeUnit.units.length]; + this.counts[unit.ordinal] = (int)(count * 1000) + 1; + } + + /** + * Package private constructor used by setters and factory. + */ + Period(int timeLimit, boolean inFuture, int[] counts) { + this.timeLimit = (byte) timeLimit; + this.inFuture = inFuture; + this.counts = counts; + } + + /** + * Set the unit's internal value, converting from float to int. + */ + private Period setTimeUnitValue(TimeUnit unit, float value) { + if (value < 0) { + throw new IllegalArgumentException("value: " + value); + } + return setTimeUnitInternalValue(unit, (int)(value * 1000) + 1); + } + + /** + * Sets the period to have the provided value, 1/1000 of the + * unit plus 1. Thus unset values are '0', 1' is the set value '0', + * 2 is the set value '1/1000', 3 is the set value '2/1000' etc. + * @param p the period to change + * @param value the int value as described above. + * @eturn the new Period object. + */ + private Period setTimeUnitInternalValue(TimeUnit unit, int value) { + int ord = unit.ordinal; + if (counts[ord] != value) { + int[] newCounts = new int[counts.length]; + for (int i = 0; i < counts.length; ++i) { + newCounts[i] = counts[i]; + } + newCounts[ord] = value; + return new Period(timeLimit, inFuture, newCounts); + } + return this; + } + + /** + * Sets whether this defines a future time. + * @param future true if the time is in the future + * @return the new Period + */ + private Period setFuture(boolean future) { + if (this.inFuture != future) { + return new Period(timeLimit, future, counts); + } + return this; + } + + /** + * Sets whether this is more than, less than, or + * 'about' the specified time. + * @param limit the kind of limit + * @return the new Period + */ + private Period setTimeLimit(byte limit) { + if (this.timeLimit != limit) { + return new Period(limit, inFuture, counts); + + } + return this; + } + + /** + * Validate count. + */ + private static void checkCount(float count) { + if (count < 0) { + throw new IllegalArgumentException("count (" + count + + ") cannot be negative"); + } + } +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/PeriodBuilder.java b/icu4j/src/com/ibm/icu/impl/duration/PeriodBuilder.java new file mode 100644 index 00000000000..72b9a8ff32b --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/PeriodBuilder.java @@ -0,0 +1,54 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import java.util.Date; +import java.util.TimeZone; + +/** + * Constructs a Period given a base time and a duration in milliseconds. + *

+ * PeriodBuilder may be used alone or be set on a DurationFormatter + * to customize how that formatter constructs a Period for formatting. + *

+ * None of the operations on PeriodBuilder change the current builder. + */ +public interface PeriodBuilder { + /** + * Create a period of the given duration using the current system + * time as the reference time. + * + * @param duration the duration in milliseconds from the current time + * to the target time. A negative duration indicates a time in the past + * @return a Period that represents the duration + */ + Period create(long duration); + + /** + * Create a period of the given duration using the provided reference date. + * + * @param duration the duration in milliseconds from the referenct time + * to the target time. A negative duration indicates a time before the + * reference time + * @param referenceDate the reference date from which to compute the period + * @return a Period that represents the duration + */ + Period createWithReferenceDate(long duration, long referenceDate); + + /** + * Returns a new PeriodBuilder that uses the provided locale to + * determine what periods are available for use. + */ + PeriodBuilder withLocale(String localeName); + + /** + * Returns a new PeriodBuilder that computes periods starting at + * dates in the provided time zone. + */ + PeriodBuilder withTimeZone(TimeZone tz); +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/PeriodBuilderFactory.java b/icu4j/src/com/ibm/icu/impl/duration/PeriodBuilderFactory.java new file mode 100644 index 00000000000..fb60a99d059 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/PeriodBuilderFactory.java @@ -0,0 +1,112 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import java.util.Date; +import java.util.TimeZone; + +/** + */ +public interface PeriodBuilderFactory { + + /** + * Sets the time units available for use. Default is all units. + * @param minUnit the smallest time unit available for use + * @param maxUnit the largest time unit available for use + * @return this factory + */ + PeriodBuilderFactory setAvailableUnitRange(TimeUnit minUnit, + TimeUnit maxUnit); + + /** + * Sets whether the time unit is available for use. + * @param unit the time unit + * @param available true if the unit is available for use + * @return this factory + */ + PeriodBuilderFactory setUnitIsAvailable(TimeUnit unit, boolean available); + + /** + * Sets the maximum value for the largest available time unit (as + * set in setUnits). Periods that represent a longer duration than + * this will be pinned to this value of that time unit and return + * true for 'isMoreThan'. Default is no limit. Setting a value of + * zero restores the default. + */ + PeriodBuilderFactory setMaxLimit(float maxLimit); + + /** + * Sets the minimum value for the smallest available time unit (as + * set in setUnits). Periods that represent a shorter duration than + * this will be pinned to this value of that time unit and return + * true for 'isLessThan'. Default is no limit. Setting a value of + * zero restores the default. + */ + PeriodBuilderFactory setMinLimit(float minLimit); + + /** + * Sets whether units with a value of zero are represented in a + * period when 'gaps' appear between time units, e.g. + * '2 hours, 0 minutes, and 33 seconds'. Default is to + * not represent these explicitly ('2 hours and 33 seconds'). + */ + PeriodBuilderFactory setAllowZero(boolean allow); + + /** + * Set whether weeks are used with other units, or only when + * weeks are the only unit. For example '3 weeks and 2 days' + * versus '23 days'. Default is to use them alone only. + */ + PeriodBuilderFactory setWeeksAloneOnly(boolean aloneOnly); + + /** + * Sets the locale for the factory. Setting the locale can adjust + * the values for some or all of the other properties to reflect + * language or cultural conventions. Default is to use + * the default locale. + */ + PeriodBuilderFactory setLocale(String localeName); + + /** + * Returns a builder that represents durations in terms of the single + * given TimeUnit. If the factory settings don't make the given unit + * available, this will return null. + * + * @param unit the single TimeUnit with which to represent times + * @return a builder + */ + PeriodBuilder getFixedUnitBuilder(TimeUnit unit); + + /** + * Returns a builder that represents durations in terms of the + * single largest period less than or equal to the duration. + * + * @return a builder + */ + PeriodBuilder getSingleUnitBuilder(); + + /** + * Returns a builder that formats the largest one or two time units, + * starting with the largest period less than or equal to the duration. + * It formats two periods if the first period has a count < 2 + * and the next period has a count >= 1. + * + * @return a builder + */ + PeriodBuilder getOneOrTwoUnitBuilder(); + + /** + * Returns a builder that formats up to the given number of time units, + * starting with the largest unit less than or equal to the + * duration. + * + * @return a builder + */ + PeriodBuilder getMultiUnitBuilder(int unitCount); +} + diff --git a/icu4j/src/com/ibm/icu/impl/duration/PeriodFormatter.java b/icu4j/src/com/ibm/icu/impl/duration/PeriodFormatter.java new file mode 100644 index 00000000000..ac7dea9e7fc --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/PeriodFormatter.java @@ -0,0 +1,43 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import java.util.Date; + +/** + * Formats a Period, such as '2 hours 23 minutes'. + * The Period defines the fields to format and their + * values, and the formatter defines how to format them. + *

+ * PeriodFormatters are immutable. + *

+ * PeriodFormatter can be instantiated using a PeriodFormatterFactory. + * + * @see Period + * @see PeriodBuilder + * @see PeriodFormatterFactory + */ +public interface PeriodFormatter { + /** + * Format a Period. + * + * @param ts the Period to format + * @return the formatted time + */ + String format(Period period); + + /** + * Return a new PeriodFormatter with the same customizations but + * using data for a new locale. Some locales impose limits on the + * fields that can be directly formatter. + * + * @param localeName the name of the new locale + * @return a new formatter for the given locale + */ + PeriodFormatter withLocale(String localeName); +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/PeriodFormatterFactory.java b/icu4j/src/com/ibm/icu/impl/duration/PeriodFormatterFactory.java new file mode 100644 index 00000000000..2110d454360 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/PeriodFormatterFactory.java @@ -0,0 +1,74 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +/** + * Abstract factory interface used to create PeriodFormatters. + * PeriodFormatters are immutable once created. + *

+ * Setters on the factory mutate the factory and return it, + * for chaining. + */ +public interface PeriodFormatterFactory { + + /** + * Set the name of the locale that will be used when + * creating new formatters. + * + * @param localeName the name of the Locale + * @return this PeriodFormatterFactory + */ + public PeriodFormatterFactory setLocale(String localeName); + + /** + * Set whether limits will be displayed. + * + * @param display true if limits will be displayed + * @return this PeriodFormatterFactory + */ + public PeriodFormatterFactory setDisplayLimit(boolean display); + + /** + * Set whether past and future will be displayed. + * + * @param display true if past and future will be displayed + * @return this PeriodFormatterFactory + */ + public PeriodFormatterFactory setDisplayPastFuture(boolean display); + + /** + * Set how separators will be displayed. + * + * @param variant the variant indicating how separators will be displayed + * @return this PeriodFormatterFactory + */ + public PeriodFormatterFactory setSeparatorVariant(int variant); + + /** + * Set the variant of the time unit names to use. + * + * @param variant the variant to use + * @return this PeriodFormatterFactory + */ + public PeriodFormatterFactory setUnitVariant(int variant); + + /** + * Set the variant of the count to use. + * + * @param variant the variant to use + * @return this PeriodFormatterFactory + */ + public PeriodFormatterFactory setCountVariant(int variant); + + /** + * Return a formatter based on this factory's current settings. + * + * @return a PeriodFormatter + */ + public PeriodFormatter getFormatter(); +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/PeriodFormatterService.java b/icu4j/src/com/ibm/icu/impl/duration/PeriodFormatterService.java new file mode 100644 index 00000000000..c433c73ce7a --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/PeriodFormatterService.java @@ -0,0 +1,45 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +import java.util.Collection; + +/** + * Provider of Factory instances for building PeriodBuilders, PeriodFormatters, + * and DurationFormatters. + */ +public interface PeriodFormatterService { + + /** + * Creates a new factory for creating DurationFormatters. + * + * @return a new DurationFormatterFactory. + */ + DurationFormatterFactory newDurationFormatterFactory(); + + /** + * Creates a new factory for creating PeriodFormatters. + * + * @return a new PeriodFormatterFactory + */ + PeriodFormatterFactory newPeriodFormatterFactory(); + + /** + * Creates a new factory for creating PeriodBuilders. + * + * @return a new PeriodBuilderFactory + */ + PeriodBuilderFactory newPeriodBuilderFactory(); + + /** + * Return the names of locales supported by factories produced by + * this service. + * @return a collection of String (locale names) + */ + Collection getAvailableLocaleNames(); +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/TimeUnit.java b/icu4j/src/com/ibm/icu/impl/duration/TimeUnit.java new file mode 100644 index 00000000000..a9f1e01d920 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/TimeUnit.java @@ -0,0 +1,85 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +/** + * 'Enum' for individual time units. Not an actual enum so that it can be + * used by Java 1.4. + */ +public final class TimeUnit { + /** The name of this unit, a key, not for localization. */ + final String name; + + /** The ordinal of the unit, in order from largest to smallest. */ + final byte ordinal; + + /** Private constructor */ + private TimeUnit(String name, int ordinal) { + this.name = name; + this.ordinal = (byte) ordinal; + } + + public String toString() { + return name; + } + + /** Represents a year. */ + public static final TimeUnit YEAR = new TimeUnit("year", 0); + + /** Represents a month. */ + public static final TimeUnit MONTH = new TimeUnit("month", 1); + + /** Represents a week. */ + public static final TimeUnit WEEK = new TimeUnit("week", 2); + + /** Represents a day. */ + public static final TimeUnit DAY = new TimeUnit("day", 3); + + /** Represents an hour. */ + public static final TimeUnit HOUR = new TimeUnit("hour", 4); + + /** Represents a minute. */ + public static final TimeUnit MINUTE = new TimeUnit("minute", 5); + + /** Represents a second. */ + public static final TimeUnit SECOND = new TimeUnit("second", 6); + + /** Represents a millisecond. */ + public static final TimeUnit MILLISECOND = new TimeUnit("millisecond", 7); + + /** Returns the next larger time unit, or null if this is the largest. */ + public TimeUnit larger() { + return ordinal == 0 ? null : units[ordinal - 1]; + } + + /** Returns the next smaller time unit, or null if this is the smallest. */ + public TimeUnit smaller() { + return ordinal == units.length - 1 ? null : units[ordinal + 1]; + } + + /** The list of units, in order from largest to smallest. */ + static final TimeUnit[] units = { + YEAR, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND + }; + + /** Returns the ordinal value of this time unit, largest is 0. **/ + public int ordinal() { + return ordinal; + } + + /** Approximate, durations for the units independent of the time at which + they are measured */ + + // hack, initialization long array using expressions with 'L' at end doesn't + // compute entire expression using 'long'. differs from initializtion of + // a single constant + static final long[] approxDurations = { + 36525L*24*60*60*10, 3045*24*60*60*10L, 7*24*60*60*1000L, 24*60*60*1000L, + 60*60*1000L, 60*1000L, 1000L, 1L + }; +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/TimeUnitConstants.java b/icu4j/src/com/ibm/icu/impl/duration/TimeUnitConstants.java new file mode 100644 index 00000000000..9de023b1850 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/TimeUnitConstants.java @@ -0,0 +1,37 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration; + +/** + * Easy access to time units for Java 1.4, which doesn't have static imports. + */ +public interface TimeUnitConstants { + /** Represents a year. */ + public static final TimeUnit YEAR = TimeUnit.YEAR; + + /** Represents a month. */ + public static final TimeUnit MONTH = TimeUnit.MONTH; + + /** Represents a week. */ + public static final TimeUnit WEEK = TimeUnit.WEEK; + + /** Represents a day. */ + public static final TimeUnit DAY = TimeUnit.DAY; + + /** Represents an hour. */ + public static final TimeUnit HOUR = TimeUnit.HOUR; + + /** Represents a minute. */ + public static final TimeUnit MINUTE = TimeUnit.MINUTE; + + /** Represents a second. */ + public static final TimeUnit SECOND = TimeUnit.SECOND; + + /** Represents a millisecond. */ + public static final TimeUnit MILLISECOND = TimeUnit.MILLISECOND; +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/DataRecord.java b/icu4j/src/com/ibm/icu/impl/duration/impl/DataRecord.java new file mode 100644 index 00000000000..62644179568 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/DataRecord.java @@ -0,0 +1,317 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration.impl; + +import java.util.*; + +/** + * DataRecord contains the data used by PeriodFormatterData. Fields + * are package-private for ease of access. This is a struct, it knows + * how to read and write itself to/from simple XML, that's all. + */ +public class DataRecord { + byte pl; + String[][] pluralNames; + byte[] genders; // EGender + String[] singularNames; + String[] halfNames; + String[] numberNames; + String[] mediumNames; + String[] shortNames; + String[] measures; + String[] rqdSuffixes; + String[] optSuffixes; + String[] halves; + byte[] halfPlacements; // EHalfPlacement + byte[] halfSupport; // EHalfSupport + String fifteenMinutes; + String fiveMinutes; + boolean requiresDigitSeparator; + String digitPrefix; + String countSep; + String shortUnitSep; + String[] unitSep; + boolean[] unitSepRequiresDP; + boolean[] requiresSkipMarker; + byte numberSystem; // ENumberSystem + char zero; + char decimalSep; + boolean omitSingularCount; + boolean omitDualCount; + byte zeroHandling; // EZeroHandling + byte decimalHandling; // EDecimalHandling + byte fractionHandling; // EFractionHandling + String skippedUnitMarker; + boolean allowZero; + boolean weeksAloneOnly; + byte useMilliseconds; // EMilliSupport + ScopeData[] scopeData; + + public static DataRecord read(String ln, RecordReader in) { + if (in.open("DataRecord")) { + DataRecord record = new DataRecord(); + record.pl = in.namedIndex("pl", EPluralization.names); + record.pluralNames = in.stringTable("pluralName"); + record.genders = in.namedIndexArray("gender", EGender.names); + record.singularNames = in.stringArray("singularName"); + record.halfNames = in.stringArray("halfName"); + record.numberNames = in.stringArray("numberName"); + record.mediumNames = in.stringArray("mediumName"); + record.shortNames = in.stringArray("shortName"); + record.measures = in.stringArray("measure"); + record.rqdSuffixes = in.stringArray("rqdSuffix"); + record.optSuffixes = in.stringArray("optSuffix"); + record.halves = in.stringArray("halves"); + record.halfPlacements = in.namedIndexArray("halfPlacement", EHalfPlacement.names); + record.halfSupport = in.namedIndexArray("halfSupport", EHalfSupport.names); + record.fifteenMinutes = in.string("fifteenMinutes"); + record.fiveMinutes = in.string("fiveMinutes"); + record.requiresDigitSeparator = in.bool("requiresDigitSeparator"); + record.digitPrefix = in.string("digitPrefix"); + record.countSep = in.string("countSep"); + record.shortUnitSep = in.string("shortUnitSep"); + record.unitSep = in.stringArray("unitSep"); + record.unitSepRequiresDP = in.boolArray("unitSepRequiresDP"); + record.requiresSkipMarker = in.boolArray("requiresSkipMarker"); + record.numberSystem = in.namedIndex("numberSystem", ENumberSystem.names); + record.zero = in.character("zero"); + record.decimalSep = in.character("decimalSep"); + record.omitSingularCount = in.bool("omitSingularCount"); + record.omitDualCount = in.bool("omitDualCount"); + record.zeroHandling = in.namedIndex("zeroHandling", EZeroHandling.names); + record.decimalHandling = in.namedIndex("decimalHandling", EDecimalHandling.names); + record.fractionHandling = in.namedIndex("fractionHandling", EFractionHandling.names); + record.skippedUnitMarker = in.string("skippedUnitMarker"); + record.allowZero = in.bool("allowZero"); + record.weeksAloneOnly = in.bool("weeksAloneOnly"); + record.useMilliseconds = in.namedIndex("useMilliseconds", EMilliSupport.names); + if (in.open("ScopeDataList")) { + List list = new ArrayList(); // of ScopeData + ScopeData data; + while (null != (data = ScopeData.read(in))) { + list.add(data); + } + if (in.close()) { + record.scopeData = (ScopeData[]) list.toArray(new ScopeData[list.size()]); + } + } + + if (in.close()) { + return record; + } + } else { + throw new InternalError("did not find DataRecord while reading " + ln); + } + throw new InternalError("null data read while reading "+ln); +// Thread.dumpStack(); +// return null; + } + + public void write(RecordWriter out) { + out.open("DataRecord"); + out.namedIndex("pl", EPluralization.names, pl); + out.stringTable("pluralName", pluralNames); + out.namedIndexArray("gender", EGender.names, genders); + out.stringArray("singularName", singularNames); + out.stringArray("halfName", halfNames); + out.stringArray("numberName", numberNames); + out.stringArray("mediumName", mediumNames); + out.stringArray("shortName", shortNames); + out.stringArray("measure", measures); + out.stringArray("rqdSuffix", rqdSuffixes); + out.stringArray("optSuffix", optSuffixes); + out.stringArray("halves", halves); + out.namedIndexArray("halfPlacement", EHalfPlacement.names, halfPlacements); + out.namedIndexArray("halfSupport", EHalfSupport.names, halfSupport); + out.string("fifteenMinutes", fifteenMinutes); + out.string("fiveMinutes", fiveMinutes); + out.bool("requiresDigitSeparator", requiresDigitSeparator); + out.string("digitPrefix", digitPrefix); + out.string("countSep", countSep); + out.string("shortUnitSep", shortUnitSep); + out.stringArray("unitSep", unitSep); + out.boolArray("unitSepRequiresDP", unitSepRequiresDP); + out.boolArray("requiresSkipMarker", requiresSkipMarker); + out.namedIndex("numberSystem", ENumberSystem.names, numberSystem); + out.character("zero", zero); + out.character("decimalSep", decimalSep); + out.bool("omitSingularCount", omitSingularCount); + out.bool("omitDualCount", omitDualCount); + out.namedIndex("zeroHandling", EZeroHandling.names, zeroHandling); + out.namedIndex("decimalHandling", EDecimalHandling.names, decimalHandling); + out.namedIndex("fractionHandling", EFractionHandling.names, fractionHandling); + out.string("skippedUnitMarker", skippedUnitMarker); + out.bool("allowZero", allowZero); + out.bool("weeksAloneOnly", weeksAloneOnly); + out.namedIndex("useMilliseconds", EMilliSupport.names, useMilliseconds); + if (scopeData != null) { + out.open("ScopeDataList"); + for (int i = 0; i < scopeData.length; ++i) { + scopeData[i].write(out); + } + out.close(); + } + out.close(); + } + + public static class ScopeData { + String prefix; + boolean requiresDigitPrefix; + String suffix; + + public void write(RecordWriter out) { + out.open("ScopeData"); + out.string("prefix", prefix); + out.bool("requiresDigitPrefix", requiresDigitPrefix); + out.string("suffix", suffix); + out.close(); + } + + public static ScopeData read(RecordReader in) { + if (in.open("ScopeData")) { + ScopeData scope = new ScopeData(); + scope.prefix = in.string("prefix"); + scope.requiresDigitPrefix = in.bool("requiresDigitPrefix"); + scope.suffix = in.string("suffix"); + if (in.close()) { + return scope; + } + } + return null; + } + } + + public static interface ETimeLimit { + public static final byte NOLIMIT = 0; + public static final byte LT = 1; + public static final byte MT = 2; + public static final String[] names = { "NOLIMIT", "LT", "MT" }; + } + + public static interface ETimeDirection { + public static final byte NODIRECTION = 0; + public static final byte PAST = 1; + public static final byte FUTURE = 2; + public static final String[] names = { "NODIRECTION", "PAST", "FUTURE" }; + } + + public static interface EUnitVariant { + public static final byte PLURALIZED = 0; + public static final byte MEDIUM = 1; + public static final byte SHORT = 2; + public static final String[] names = { "PLURALIZED", "MEDIUM", "SHORT" }; + } + + public static interface ECountVariant { + public static final byte INTEGER = 0; + public static final byte INTEGER_CUSTOM = 1; + public static final byte HALF_FRACTION = 2; + public static final byte DECIMAL1 = 3; + public static final byte DECIMAL2 = 4; + public static final byte DECIMAL3 = 5; + public static final String[] names = { + "INTEGER", "INTEGER_CUSTOM", "HALF_FRACTION", "DECIMAL1", + "DECIMAL2", "DECIMAL3" }; + } + + public static interface EPluralization { + public static final byte NONE = 0; + public static final byte PLURAL = 1; + public static final byte DUAL = 2; + public static final byte PAUCAL = 3; + public static final byte HEBREW = 4; + public static final byte ARABIC = 5; + public static final String[] names = { + "NONE", "PLURAL", "DUAL", "PAUCAL", "HEBREW", "ARABIC" + }; + } + + public static interface EHalfPlacement { + public static final byte PREFIX = 0; + public static final byte AFTER_FIRST = 1; + public static final byte LAST = 2; + public static final String[] names = { + "PREFIX", "AFTER_FIRST", "LAST" + }; + } + + public static interface ENumberSystem { + public static final byte DEFAULT = 0; + public static final byte CHINESE_TRADITIONAL = 1; + public static final byte CHINESE_SIMPLIFIED = 2; + public static final byte KOREAN = 3; + public static final String[] names = { + "DEFAULT", "CHINESE_TRADITIONAL", "CHINESE_SIMPLIFIED", "KOREAN" + }; + } + + public static interface EZeroHandling { + public static final byte ZPLURAL = 0; + public static final byte ZSINGULAR = 1; + public static final String[] names = { + "ZPLURAL", "ZSINGULAR" + }; + } + + public static interface EDecimalHandling { + public static final byte DPLURAL = 0; + public static final byte DSINGULAR = 1; + public static final byte DSINGULAR_SUBONE = 2; + public static final byte DPAUCAL = 3; + public static final String[] names = { + "DPLURAL", "DSINGULAR", "DSINGULAR_SUBONE", "DPAUCAL" + }; + } + + public static interface EFractionHandling { + public static final byte FPLURAL = 0; + public static final byte FSINGULAR_PLURAL = 1; + public static final byte FSINGULAR_PLURAL_ANDAHALF = 2; + public static final byte FPAUCAL = 3; + public static final String[] names = { + "FPLURAL", "FSINGULAR_PLURAL", "FSINGULAR_PLURAL_ANDAHALF", + "FPAUCAL" + }; + } + + public static interface EHalfSupport { + public static final byte YES = 0; + public static final byte NO = 1; + public static final byte ONE_PLUS = 2; + public static final String[] names = { + "YES", "NO", "ONE_PLUS" + }; + } + + public static interface EMilliSupport { + public static final byte YES = 0; + public static final byte NO = 1; + public static final byte WITH_SECONDS = 2; + public static final String[] names = { + "YES", "NO", "WITH_SECONDS" + }; + } + + public static interface ESeparatorVariant { + public static final byte NONE = 0; + public static final byte SHORT = 1; + public static final byte FULL = 2; + public static final String[] names = { + "NONE", "SHORT", "FULL" + }; + } + + public static interface EGender { + public static final byte M = 0; + public static final byte F = 1; + public static final byte N = 2; + public static final String[] names = { + "M", "F", "N" + }; + } +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/PeriodFormatterData.java b/icu4j/src/com/ibm/icu/impl/duration/impl/PeriodFormatterData.java new file mode 100644 index 00000000000..d91ac933d59 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/PeriodFormatterData.java @@ -0,0 +1,678 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration.impl; + +import com.ibm.icu.impl.duration.TimeUnit; + +import com.ibm.icu.impl.duration.impl.DataRecord.ScopeData; +import com.ibm.icu.impl.duration.impl.DataRecord.ECountVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.EDecimalHandling; +import com.ibm.icu.impl.duration.impl.DataRecord.EFractionHandling; +import com.ibm.icu.impl.duration.impl.DataRecord.EGender; +import com.ibm.icu.impl.duration.impl.DataRecord.EHalfPlacement; +import com.ibm.icu.impl.duration.impl.DataRecord.EHalfSupport; +import com.ibm.icu.impl.duration.impl.DataRecord.ENumberSystem; +import com.ibm.icu.impl.duration.impl.DataRecord.EPluralization; +import com.ibm.icu.impl.duration.impl.DataRecord.EUnitVariant; +import com.ibm.icu.impl.duration.impl.DataRecord.EZeroHandling; +import com.ibm.icu.util.ULocale; + +import java.io.InputStreamReader; +import java.io.FileInputStream; +import java.io.File; +import java.io.StringReader; +import java.lang.reflect.*; +import java.util.*; + + +/** + * PeriodFormatterData provides locale-specific data used to format + * relative dates and times, and convenience api to access it. + * + * An instance of PeriodFormatterData is usually created by requesting + * data for a given locale from an PeriodFormatterDataService. + */ +public class PeriodFormatterData { + final DataRecord dr; + String localeName; + + // debug + public static boolean trace = false; + + public PeriodFormatterData(String localeName, DataRecord dr) { + this.dr = dr; + this.localeName = localeName; + if(localeName == null) { + throw new NullPointerException("localename is null"); + } +// System.err.println("** localeName is " + localeName); + if (dr == null) { +// Thread.dumpStack(); + throw new NullPointerException("data record is null"); + } + } + + // none - chinese (all forms the same) + // plural - english, special form for 1 + // dual - special form for 1 and 2 + // paucal - russian, special form for 1, for 2-4 and n > 20 && n % 10 == 2-4 + // rpt_dual_few - slovenian, special form for 1, 2, 3-4 and n as above + // hebrew, dual plus singular form for years > 11 + // arabic, dual, plus singular form for all terms > 10 + + /** + * Return the pluralization format used by this locale. + * @return the pluralization format + */ + public int pluralization() { + return dr.pl; + } + + /** + * Return true if zeros are allowed in the display. + * @return true if zeros should be allowed + */ + public boolean allowZero() { + return dr.allowZero; + } + + public boolean weeksAloneOnly() { + return dr.weeksAloneOnly; + } + + public int useMilliseconds() { + return dr.useMilliseconds; + } + + /** + * Append the appropriate prefix to the string builder, depending on whether and + * how a limit and direction are to be displayed. + * + * @param tl how and whether to display the time limit + * @param td how and whether to display the time direction + * @param sb the string builder to which to append the text + * @return true if a following digit will require a digit prefix + */ + public boolean appendPrefix(int tl, int td, StringBuilder sb) { + if (dr.scopeData != null) { + int ix = tl * 3 + td; + ScopeData sd = dr.scopeData[ix]; + if (sd != null) { + String prefix = sd.prefix; + if (prefix != null) { + sb.append(prefix); + return sd.requiresDigitPrefix; + } + } + } + return false; + } + + /** + * Append the appropriate suffix to the string builder, depending on whether and + * how a limit and direction are to be displayed. + * + * @param tl how and whether to display the time limit + * @param td how and whether to display the time direction + * @param sb the string builder to which to append the text + */ + public void appendSuffix(int tl, int td, StringBuilder sb) { + if (dr.scopeData != null) { + int ix = tl * 3 + td; + ScopeData sd = dr.scopeData[ix]; + if (sd != null) { + String suffix = sd.suffix; + if (suffix != null) { + if (trace) { + System.out.println("appendSuffix '" + suffix + "'"); + } + sb.append(suffix); + } + } + } + } + + /** + * Append the count and unit to the string builder. + * + * @param unit the unit to append + * @param count the count of units, * 1000 + * @param cv the format to use for displaying the count + * @param uv the format to use for displaying the unit + * @param useCountSep if false, force no separator between count and unit + * @param useDigitPrefix if true, use the digit prefix + * @param multiple true if there are multiple units in this string + * @param last true if this is the last unit + * @param wasSkipped true if the unit(s) before this were skipped + * @param sb the string builder to which to append the text + * @param return true if will require skip marker + */ + public boolean appendUnit(TimeUnit unit, int count, int cv, + int uv, boolean useCountSep, + boolean useDigitPrefix, boolean multiple, + boolean last, boolean wasSkipped, + StringBuilder sb) { + int px = unit.ordinal(); + + boolean willRequireSkipMarker = false; + if (dr.requiresSkipMarker != null && dr.requiresSkipMarker[px] && + dr.skippedUnitMarker != null) { + if (!wasSkipped && last) { + sb.append(dr.skippedUnitMarker); + } + willRequireSkipMarker = true; + } + + if (uv != EUnitVariant.PLURALIZED) { + boolean useMedium = uv == EUnitVariant.MEDIUM; + String[] names = useMedium ? dr.mediumNames : dr.shortNames; + if (names == null || names[px] == null) { + names = useMedium ? dr.shortNames : dr.mediumNames; + } + if (names != null && names[px] != null) { + appendCount(unit, false, false, count, cv, useCountSep, + names[px], last, sb); // omit suffix, ok? + return false; // omit skip marker + } + } + + // check cv + if (cv == ECountVariant.HALF_FRACTION && dr.halfSupport != null) { + switch (dr.halfSupport[px]) { + case EHalfSupport.YES: break; + case EHalfSupport.ONE_PLUS: + if (count > 1000) { + break; + } + // else fall through to decimal + case EHalfSupport.NO: { + count = (count / 500) * 500; // round to 1/2 + cv = ECountVariant.DECIMAL1; + } break; + } + } + + String name = null; + int form = computeForm(unit, count, cv, multiple && last); + if (form == FORM_SINGULAR_SPELLED) { + if (dr.singularNames == null) { + form = FORM_SINGULAR; + name = dr.pluralNames[px][form]; + } else { + name = dr.singularNames[px]; + } + } else if (form == FORM_SINGULAR_NO_OMIT) { + name = dr.pluralNames[px][FORM_SINGULAR]; + } else if (form == FORM_HALF_SPELLED) { + name = dr.halfNames[px]; + } else { + try { + name = dr.pluralNames[px][form]; + } catch (NullPointerException e) { + System.out.println("Null Pointer in PeriodFormatterData["+localeName+"].au px: " + px + " form: " + form + " pn: " + dr.pluralNames); + throw e; + } + } + if (name == null) { + form = FORM_PLURAL; + name = dr.pluralNames[px][form]; + } + + boolean omitCount = + (form == FORM_SINGULAR_SPELLED || form == FORM_HALF_SPELLED) || + (dr.omitSingularCount && form == FORM_SINGULAR) || + (dr.omitDualCount && form == FORM_DUAL); + + int suffixIndex = appendCount(unit, omitCount, useDigitPrefix, count, cv, + useCountSep, name, last, sb); + if (last && suffixIndex >= 0) { + String suffix = null; + if (dr.rqdSuffixes != null && suffixIndex < dr.rqdSuffixes.length) { + suffix = dr.rqdSuffixes[suffixIndex]; + } + if (suffix == null && dr.optSuffixes != null && + suffixIndex < dr.optSuffixes.length) { + suffix = dr.optSuffixes[suffixIndex]; + } + if (suffix != null) { + sb.append(suffix); + } + } + return willRequireSkipMarker; + } + + /** + * Append a count to the string builder. + * + * @param unit the unit + * @param count the count + * @param cv the format to use for displaying the count + * @param useSep whether to use the count separator, if available + * @param name the term name + * @param last true if this is the last unit to be formatted + * @param sb the string builder to which to append the text + * @return index to use if might have required or optional suffix, or -1 if none required + */ + public int appendCount(TimeUnit unit, boolean omitCount, + boolean useDigitPrefix, + int count, int cv, boolean useSep, + String name, boolean last, StringBuilder sb) { + if (cv == ECountVariant.HALF_FRACTION && dr.halves == null) { + cv = ECountVariant.INTEGER; + } + + if (!omitCount && useDigitPrefix && dr.digitPrefix != null) { + sb.append(dr.digitPrefix); + } + + int index = unit.ordinal(); + switch (cv) { + case ECountVariant.INTEGER: { + if (!omitCount) { + appendInteger(count/1000, 1, 10, sb); + } + } break; + + case ECountVariant.INTEGER_CUSTOM: { + int val = count / 1000; + // only custom names we have for now + if (unit == TimeUnit.MINUTE && + (dr.fiveMinutes != null || dr.fifteenMinutes != null)) { + if (val != 0 && val % 5 == 0) { + if (dr.fifteenMinutes != null && (val == 15 || val == 45)) { + val = val == 15 ? 1 : 3; + if (!omitCount) appendInteger(val, 1, 10, sb); + name = dr.fifteenMinutes; + index = 8; // hack + break; + } + if (dr.fiveMinutes != null) { + val = val / 5; + if (!omitCount) appendInteger(val, 1, 10, sb); + name = dr.fiveMinutes; + index = 9; // hack + break; + } + } + } + if (!omitCount) appendInteger(val, 1, 10, sb); + } break; + + case ECountVariant.HALF_FRACTION: { + // 0, 1/2, 1, 1-1/2... + int v = count / 500; + if (v != 1) { + if (!omitCount) appendCountValue(count, 1, 0, sb); + } + if ((v & 0x1) == 1) { + // hack, using half name + if (v == 1 && dr.halfNames != null && dr.halfNames[index] != null) { + sb.append(name); + return last ? index : -1; + } + + int solox = v == 1 ? 0 : 1; + if (dr.genders != null && dr.halves.length > 2) { + if (dr.genders[index] == EGender.F) { + solox += 2; + } + } + int hp = dr.halfPlacements == null + ? EHalfPlacement.PREFIX + : dr.halfPlacements[solox & 0x1]; + String half = dr.halves[solox]; + String measure = dr.measures == null ? null : dr.measures[index]; + switch (hp) { + case EHalfPlacement.PREFIX: + sb.append(half); + break; + case EHalfPlacement.AFTER_FIRST: { + if (measure != null) { + sb.append(measure); + sb.append(half); + if (useSep && !omitCount) { + sb.append(dr.countSep); + } + sb.append(name); + } else { // ignore sep completely + sb.append(name); + sb.append(half); + return last ? index : -1; // might use suffix + } + } return -1; // exit early + case EHalfPlacement.LAST: { + if (measure != null) { + sb.append(measure); + } + if (useSep && !omitCount) { + sb.append(dr.countSep); + } + sb.append(name); + sb.append(half); + } return last ? index : -1; // might use suffix + } + } + } break; + default: { + int decimals = 1; + switch (cv) { + case ECountVariant.DECIMAL2: decimals = 2; break; + case ECountVariant.DECIMAL3: decimals = 3; break; + default: break; + } + if (!omitCount) appendCountValue(count, 1, decimals, sb); + } break; + } + if (!omitCount && useSep) { + sb.append(dr.countSep); + } + if (!omitCount && dr.measures != null && index < dr.measures.length) { + String measure = dr.measures[index]; + if (measure != null) { + sb.append(measure); + } + } + sb.append(name); + return last ? index : -1; + } + + /** + * Append a count value to the builder. + * + * @param count the count + * @param integralDigits the number of integer digits to display + * @param decimalDigits the number of decimal digits to display, <= 3 + * @param sb the string builder to which to append the text + */ + public void appendCountValue(int count, int integralDigits, + int decimalDigits, StringBuilder sb) { + int ival = count / 1000; + if (decimalDigits == 0) { + appendInteger(ival, integralDigits, 10, sb); + return; + } + + if (dr.requiresDigitSeparator && sb.length() > 0) { + sb.append(' '); + } + appendDigits(ival, integralDigits, 10, sb); + int dval = count % 1000; + if (decimalDigits == 1) { + dval /= 100; + } else if (decimalDigits == 2) { + dval /= 10; + } + sb.append(dr.decimalSep); + appendDigits(dval, decimalDigits, decimalDigits, sb); + if (dr.requiresDigitSeparator) { + sb.append(' '); + } + } + + public void appendInteger(int num, int mindigits, int maxdigits, + StringBuilder sb) { + if (dr.numberNames != null && num < dr.numberNames.length) { + String name = dr.numberNames[num]; + if (name != null) { + sb.append(name); + return; + } + } + + if (dr.requiresDigitSeparator && sb.length() > 0) { + sb.append(' '); + } + switch (dr.numberSystem) { + case ENumberSystem.DEFAULT: appendDigits(num, mindigits, maxdigits, sb); break; + case ENumberSystem.CHINESE_TRADITIONAL: sb.append( + Utils.chineseNumber(num, Utils.ChineseDigits.TRADITIONAL)); break; + case ENumberSystem.CHINESE_SIMPLIFIED: sb.append( + Utils.chineseNumber(num, Utils.ChineseDigits.SIMPLIFIED)); break; + case ENumberSystem.KOREAN: sb.append( + Utils.chineseNumber(num, Utils.ChineseDigits.KOREAN)); break; + } + if (dr.requiresDigitSeparator) { + sb.append(' '); + } + } + + /** + * Append digits to the string builder, using this.zero for '0' etc. + * + * @param num the integer to append + * @param mindigits the minimum number of digits to append + * @param maxdigits the maximum number of digits to append + * @param sb the string builder to which to append the text + */ + public void appendDigits(long num, int mindigits, int maxdigits, + StringBuilder sb) { + char[] buf = new char[maxdigits]; + int ix = maxdigits; + while (ix > 0 && num > 0) { + buf[--ix] = (char)(dr.zero + (num % 10)); + num /= 10; + } + for (int e = maxdigits - mindigits; ix > e;) { + buf[--ix] = dr.zero; + } + sb.append(buf, ix, maxdigits - ix); + } + + /** + * Append a marker for skipped units internal to a string. + * @param sb the string builder to which to append the text + */ + public void appendSkippedUnit(StringBuilder sb) { + if (dr.skippedUnitMarker != null) { + sb.append(dr.skippedUnitMarker); + } + } + + /** + * Append the appropriate separator between units + * + * @param unit the unit to which to append the separator + * @param afterFirst true if this is the first unit formatted + * @param beforeLast true if this is the next-to-last unit to be formatted + * @param sb the string builder to which to append the text + * @return true if a prefix will be required before a following unit + */ + public boolean appendUnitSeparator(TimeUnit unit, boolean longSep, + boolean afterFirst, boolean beforeLast, + StringBuilder sb) { + // long seps + // false, false "...b', '...d" + // false, true "...', and 'c" + // true, false - "a', '...c" + // true, true - "a' and 'b" + if ((longSep && dr.unitSep != null) || dr.shortUnitSep != null) { + if (longSep && dr.unitSep != null) { + int ix = (afterFirst ? 2 : 0) + (beforeLast ? 1 : 0); + sb.append(dr.unitSep[ix]); + return dr.unitSepRequiresDP != null && dr.unitSepRequiresDP[ix]; + } + sb.append(dr.shortUnitSep); // todo: investigate whether DP is required + } + return false; + } + + private static final int + FORM_PLURAL = 0, + FORM_SINGULAR = 1, + FORM_DUAL = 2, + FORM_PAUCAL = 3, + FORM_SINGULAR_SPELLED = 4, // following are not in the pluralization list + FORM_SINGULAR_NO_OMIT = 5, // a hack + FORM_HALF_SPELLED = 6; + + private int computeForm(TimeUnit unit, int count, int cv, + boolean lastOfMultiple) { + // first check if a particular form is forced by the countvariant. if + // SO, just return that. otherwise convert the count to an integer + // and use pluralization rules to determine which form to use. + // careful, can't assume any forms but plural exist. + + if (trace) { + System.err.println("pfd.cf unit: " + unit + " count: " + count + " cv: " + cv + " dr.pl: " + dr.pl); + Thread.dumpStack(); + } + if (dr.pl == EPluralization.NONE) { + return FORM_PLURAL; + } + // otherwise, assume we have at least a singular and plural form + + int val = count/1000; + + switch (cv) { + case ECountVariant.INTEGER: + case ECountVariant.INTEGER_CUSTOM: { + // do more analysis based on floor of count + } break; + case ECountVariant.HALF_FRACTION: { + switch (dr.fractionHandling) { + case EFractionHandling.FPLURAL: + return FORM_PLURAL; + + case EFractionHandling.FSINGULAR_PLURAL_ANDAHALF: + case EFractionHandling.FSINGULAR_PLURAL: { + // if half-floor is 1/2, use singular + // else if half-floor is not integral, use plural + // else do more analysis + int v = (int)(count / 500); + if (v == 1) { + if (dr.halfNames != null && dr.halfNames[unit.ordinal()] != null) { + return FORM_HALF_SPELLED; + } + return FORM_SINGULAR_NO_OMIT; + } + if ((v & 0x1) == 1) { + if (dr.pl == EPluralization.ARABIC && v > 21) { // hack + return FORM_SINGULAR_NO_OMIT; + } + if (v == 3 && dr.pl == EPluralization.PLURAL && + dr.fractionHandling != EFractionHandling.FSINGULAR_PLURAL_ANDAHALF) { + return FORM_PLURAL; + } + } + + // it will display like an integer, so do more analysis + } break; + + case EFractionHandling.FPAUCAL: { + int v = (int)(count / 500); + if (v == 1 || v == 3) { + return FORM_PAUCAL; + } + // else use integral form + } break; + + default: + throw new IllegalStateException(); + } + } break; + default: { // for all decimals + switch (dr.decimalHandling) { + case EDecimalHandling.DPLURAL: break; + case EDecimalHandling.DSINGULAR: return FORM_SINGULAR_NO_OMIT; + case EDecimalHandling.DSINGULAR_SUBONE: + if (count < 1000) { + return FORM_SINGULAR_NO_OMIT; + } + break; + case EDecimalHandling.DPAUCAL: + if (dr.pl == EPluralization.PAUCAL) { + return FORM_PAUCAL; + } + break; + default: + break; + } + return FORM_PLURAL; + } + } + + // select among pluralization forms + if (trace && count == 0) { + System.err.println("EZeroHandling = " + dr.zeroHandling); + } + if (count == 0 && dr.zeroHandling == EZeroHandling.ZSINGULAR) { + return FORM_SINGULAR_SPELLED; + } + + int form = FORM_PLURAL; + switch(dr.pl) { + case EPluralization.NONE: break; // never get here + case EPluralization.PLURAL: { + if (val == 1) { + form = FORM_SINGULAR_SPELLED; // defaults to form_singular if no spelled forms + } + } break; + case EPluralization.DUAL: { + if (val == 2) { + form = FORM_DUAL; + } else if (val == 1) { + form = FORM_SINGULAR; + } + } break; + case EPluralization.PAUCAL: { + int v = val; + v = v % 100; + if (v > 20) { + v = v % 10; + } + if (v == 1) { + form = FORM_SINGULAR; + } else if (v > 1 && v < 5) { + form = FORM_PAUCAL; + } + } break; + /* + case EPluralization.RPT_DUAL_FEW: { + int v = val; + if (v > 20) { + v = v % 10; + } + if (v == 1) { + form = FORM_SINGULAR; + } else if (v == 2) { + form = FORM_DUAL; + } else if (v > 2 && v < 5) { + form = FORM_PAUCAL; + } + } break; + */ + case EPluralization.HEBREW: { + if (val == 2) { + form = FORM_DUAL; + } else if (val == 1) { + if (lastOfMultiple) { + form = FORM_SINGULAR_SPELLED; + } else { + form = FORM_SINGULAR; + } + } else if (unit == TimeUnit.YEAR && val > 11) { + form = FORM_SINGULAR_NO_OMIT; + } + } break; + case EPluralization.ARABIC: { + if (val == 2) { + form = FORM_DUAL; + } else if (val == 1) { + form = FORM_SINGULAR; + } else if (val > 10) { + form = FORM_SINGULAR_NO_OMIT; + } + } break; + default: + System.err.println("dr.pl is " + dr.pl); + throw new IllegalStateException(); + } + + return form; + } +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/PeriodFormatterDataService.java b/icu4j/src/com/ibm/icu/impl/duration/impl/PeriodFormatterDataService.java new file mode 100644 index 00000000000..3bb3ff8bd01 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/PeriodFormatterDataService.java @@ -0,0 +1,32 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration.impl; + +import java.util.Collection; + +/** + * Abstract service for PeriodFormatterData, which defines the + * localization data used by period formatters. + */ +public abstract class PeriodFormatterDataService { + /** + * Returns a PeriodFormatterData for the given locale name. + * + * @param localeName the name of the locale + * @return a PeriodFormatterData object + */ + public abstract PeriodFormatterData get(String localeName); + + /** + * Returns a collection of all the locale names supported by this + * service. + * + * @return a collection of locale names, as String + */ + public abstract Collection getAvailableLocales(); +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/RecordReader.java b/icu4j/src/com/ibm/icu/impl/duration/impl/RecordReader.java new file mode 100644 index 00000000000..64e3fee550e --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/RecordReader.java @@ -0,0 +1,23 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration.impl; + +interface RecordReader { + boolean open(String title); + boolean close(); + + boolean bool(String name); + boolean[] boolArray(String name); + char character(String name); + char[] characterArray(String name); + byte namedIndex(String name, String[] names); + byte[] namedIndexArray(String name, String[] names); + String string(String name); + String[] stringArray(String name); + String[][] stringTable(String name); +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/RecordWriter.java b/icu4j/src/com/ibm/icu/impl/duration/impl/RecordWriter.java new file mode 100644 index 00000000000..bb94d761a54 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/RecordWriter.java @@ -0,0 +1,23 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration.impl; + +interface RecordWriter { + boolean open(String title); + boolean close(); + + void bool(String name, boolean value); + void boolArray(String name, boolean[] values); + void character(String name, char value); + void characterArray(String name, char[] values); + void namedIndex(String name, String[] names, int value); + void namedIndexArray(String name, String[] names, byte[] values); + void string(String name, String value); + void stringArray(String name, String[] values); + void stringTable(String name, String[][] values); +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/ResourceBasedPeriodFormatterDataService.java b/icu4j/src/com/ibm/icu/impl/duration/impl/ResourceBasedPeriodFormatterDataService.java new file mode 100644 index 00000000000..839424f2f6f --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/ResourceBasedPeriodFormatterDataService.java @@ -0,0 +1,145 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration.impl; + +import java.util.*; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +import java.io.OutputStreamWriter; + +/** + * A PeriodFormatterDataService that serves PeriodFormatterData + * objects based on data files stored as resources in this directory. + * These are text files named after the locale, for example, + * 'pfd_he_IL.txt' specifies an period formatter data file for Hebrew + * as spoken in Israel. Data is in a JSON-like format. + */ +public class ResourceBasedPeriodFormatterDataService + extends PeriodFormatterDataService { + private Collection availableLocales; // of String + + private PeriodFormatterData lastData = null; + private String lastLocale = null; + private Map cache = new HashMap(); // String -> PeriodFormatterData + private PeriodFormatterData fallbackFormatterData; + + private static final String PATH = "data/"; + + private static final ResourceBasedPeriodFormatterDataService singleton = + new ResourceBasedPeriodFormatterDataService(); + + /** + * Returns the singleton instance of this class. + */ + public static ResourceBasedPeriodFormatterDataService getInstance() { + return singleton; + } + + /** + * Constructs the service. + */ + private ResourceBasedPeriodFormatterDataService() { + List localeNames = new ArrayList(); // of String + try { + InputStream is = getClass().getResourceAsStream(PATH + "index.txt"); + if (is == null) { + System.err.println("could not load index.txt"); + } else { + BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8")); + String string = null; + while (null != (string = br.readLine())) { + string = string.trim(); + if(string.startsWith("#") || string.length()==0) { + continue; + } + localeNames.add(string); + } + } + } + catch (Exception e) { + System.err.println(e.getMessage()); + } + availableLocales = Collections.unmodifiableList(localeNames); + } + + public PeriodFormatterData get(String localeName) { + synchronized(this) { + if (lastLocale != null && lastLocale.equals(localeName)) { + return lastData; + } + + PeriodFormatterData ld = (PeriodFormatterData)cache.get(localeName); + if (ld == null) { + String ln = localeName; + while (!availableLocales.contains(ln)) { + int ix = ln.lastIndexOf("_"); + if (ix > -1) { + ln = ln.substring(0, ix); + } else if (!"test".equals(ln)) { + ln = "test"; + } else { + ln = null; + break; + } + } + if (ln != null) { + try { + String name = PATH + "pfd_" + ln + ".xml"; + InputStream is = getClass().getResourceAsStream(name); + if (is == null) { + System.err.println("no resource named " + name); + } else { + DataRecord dr = DataRecord.read(ln, + new XMLRecordReader( + new InputStreamReader(is, "UTF-8"))); + if (dr != null) { + // debug + if (false && ln.equals("ar_EG")) { + OutputStreamWriter osw = new OutputStreamWriter(System.out, "UTF-8"); + XMLRecordWriter xrw = new XMLRecordWriter(osw); + dr.write(xrw); + osw.flush(); + } + ld = new PeriodFormatterData(localeName,dr); + } + } + } + catch (Exception e) { + System.err.println(e); + } + } + + if (ld == null) { + ld = getFallbackFormatterData(); + } + cache.put(localeName, ld); + } + lastData = ld; + lastLocale = localeName; + + return ld; + } + } + + public Collection getAvailableLocales() { + return availableLocales; + } + + PeriodFormatterData getFallbackFormatterData() { + synchronized (this) { + if (fallbackFormatterData == null) { + DataRecord dr = new DataRecord(); // hack, no default, will die if used + fallbackFormatterData = new PeriodFormatterData(null, dr); + } + return fallbackFormatterData; + } + } +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/Utils.java b/icu4j/src/com/ibm/icu/impl/duration/impl/Utils.java new file mode 100644 index 00000000000..cca3b710b84 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/Utils.java @@ -0,0 +1,225 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration.impl; + +import java.util.Locale; +import java.lang.reflect.Array; + +public class Utils { + public static final Locale localeFromString(String s) { + String language = s; + String region = ""; + String variant = ""; + + int x = language.indexOf("_"); + if (x != -1) { + region = language.substring(x+1); + language = language.substring(0, x); + } + x = region.indexOf("_"); + if (x != -1) { + variant = region.substring(x+1); + region = region.substring(0, x); + } + return new Locale(language, region, variant); + } + /* + public static T[] arraycopy(T[] src) { + T[] result = (T[])Array.newInstance(src.getClass().getComponentType(), src.length); // can we do this without casting? + for (int i = 0; i < src.length; ++i) { + result[i] = src[i]; + } + return result; + } + */ + + /** + * Interesting features of chinese numbers: + * - Each digit is followed by a unit symbol (10's, 100's, 1000's). + * - Units repeat in levels of 10,000, there are symbols for each level too (except 1's). + * - The digit 2 has a special form before the 10 symbol and at the end of the number. + * - If the first digit in the number is 1 and its unit is 10, the 1 is omitted. + * - Sequences of 0 digits and their units are replaced by a single 0 and no unit. + * - If there are two such sequences of 0 digits in a level (1000's and 10's), the 1000's 0 is also omitted. + * - The 1000's 0 is also omitted in alternating levels, such that it is omitted in the rightmost + * level with a 10's 0, or if none, in the rightmost level. + * - Level symbols are omitted if all of their units are omitted + */ + public static String chineseNumber(long n, ChineseDigits zh) { + if (n < 0) { + n = -n; + } + if (n <= 10) { + if (n == 2) { + return String.valueOf(zh.liang); + } + return String.valueOf(zh.digits[(int)n]); + } + + // 9223372036854775807 + char[] buf = new char[40]; // as long as we get, and actually we can't get this high, no units past zhao + char[] digits = String.valueOf(n).toCharArray(); + + // first, generate all the digits in place + // convert runs of zeros into a single zero, but keep places + // + boolean inZero = true; // true if we should zap zeros in this block, resets at start of block + boolean forcedZero = false; // true if we have a 0 in tens's place + int x = buf.length; + for (int i = digits.length, u = -1, l = -1; --i >= 0;) { + if (u == -1) { + if (l != -1) { + buf[--x] = zh.levels[l]; + inZero = true; + forcedZero = false; + } + ++u; + } else { + buf[--x] = zh.units[u++]; + if (u == 3) { + u = -1; + ++l; + } + } + int d = digits[i] - '0'; + if (d == 0) { + if (x < buf.length-1 && u != 0) { + buf[x] = '*'; + } + if (inZero || forcedZero) { + buf[--x] = '*'; + } else { + buf[--x] = zh.digits[0]; + inZero = true; + forcedZero = u == 1; + } + } else { + inZero = false; + buf[--x] = zh.digits[d]; + } + } + + // scanning from right, find first required 'ling' + // we only care if n > 101,0000 as this is the first case where + // it might shift. remove optional lings in alternating blocks. + if (n > 1000000) { + boolean last = true; + int i = buf.length - 3; + do { + if (buf[i] == '0') { + break; + } + i -= 8; + last = !last; + } while (i > x); + + i = buf.length - 7; + do { + if (buf[i] == zh.digits[0] && !last) { + buf[i] = '*'; + } + i -= 8; + last = !last; + } while (i > x); + + // remove levels for empty blocks + if (n >= 100000000) { + i = buf.length - 8; + do { + boolean empty = true; + for (int j = i-1, e = Math.max(x-1, i-8); j > e; --j) { + if (buf[j] != '*') { + empty = false; + break; + } + } + if (empty) { + if (buf[i+1] != '*' && buf[i+1] != zh.digits[0]) { + buf[i] = zh.digits[0]; + } else { + buf[i] = '*'; + } + } + i -= 8; + } while (i > x); + } + } + + // replace er by liang except before or after shi or after ling + for (int i = x; i < buf.length; ++i) { + if (buf[i] != zh.digits[2]) continue; + if (i < buf.length - 1 && buf[i+1] == zh.units[0]) continue; + if (i > x && (buf[i-1] == zh.units[0] || buf[i-1] == zh.digits[0] || buf[i-1] == '*')) continue; + + buf[i] = zh.liang; + } + + // eliminate leading 1 if following unit is shi + if (buf[x] == zh.digits[1] && (zh.ko || buf[x+1] == zh.units[0])) { + ++x; + } + + // now, compress out the '*' + int w = x; + for (int r = x; r < buf.length; ++r) { + if (buf[r] != '*') { + buf[w++] = buf[r]; + } + } + return new String(buf, x, w-x); + } + + public static void main(String[] args) { + for (int i = 0; i < args.length; ++i) { + String arg = args[i]; + System.out.print(arg); + System.out.print(" > "); + long n = Long.parseLong(arg); + System.out.println(chineseNumber(n, ChineseDigits.DEBUG)); + } + } + + public static class ChineseDigits { + final char[] digits; + final char[] units; + final char[] levels; + final char liang; + final boolean ko; + + ChineseDigits(String digits, String units, String levels, char liang, boolean ko) { + this.digits = digits.toCharArray(); + this.units = units.toCharArray(); + this.levels = levels.toCharArray(); + this.liang = liang; + this.ko = ko; + } + + public static final ChineseDigits DEBUG = + new ChineseDigits("0123456789s", "sbq", "WYZ", 'L', false); + + public static final ChineseDigits TRADITIONAL = + new ChineseDigits("\u96f6\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\u5341", // to shi + "\u5341\u767e\u5343", // shi, bai, qian + "\u842c\u5104\u5146", // wan, yi, zhao + '\u5169', false); // liang + + public static final ChineseDigits SIMPLIFIED = + new ChineseDigits("\u96f6\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\u5341", // to shi + "\u5341\u767e\u5343", // shi, bai, qian + "\u4e07\u4ebf\u5146", // wan, yi, zhao + '\u4e24', false); // liang + + // no 1 before first unit no matter what it is + // not sure if there are 'ling' units + public static final ChineseDigits KOREAN = + new ChineseDigits("\uc601\uc77c\uc774\uc0bc\uc0ac\uc624\uc721\uce60\ud314\uad6c\uc2ed", // to ten + "\uc2ed\ubc31\ucc9c", // 10, 100, 1000 + "\ub9cc\uc5b5?", // 10^4, 10^8, 10^12 + '\uc774', true); + } +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/XMLRecordReader.java b/icu4j/src/com/ibm/icu/impl/duration/impl/XMLRecordReader.java new file mode 100644 index 00000000000..a51bbda77dd --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/XMLRecordReader.java @@ -0,0 +1,303 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration.impl; + +import java.io.IOException; +import java.io.Reader; +import java.util.ArrayList; +import java.util.List; + +public class XMLRecordReader implements RecordReader { + private Reader r; + private List nameStack; + private boolean atTag; + private String tag; // cache + + public XMLRecordReader(Reader r) { + this.r = r; + this.nameStack = new ArrayList(); + + // skip XML prologue + if (getTag().startsWith("?xml")) { + advance(); + } + + // skip FIRST comment + if(getTag().startsWith("!--")) { + advance(); + } + } + + public boolean open(String title) { + if (getTag().equals(title)) { + nameStack.add(title); + advance(); + return true; + } + return false; + } + + public boolean close() { + int ix = nameStack.size() - 1; + String name = (String)nameStack.get(ix); + if (getTag().equals("/" + name)) { + nameStack.remove(ix); + advance(); + return true; + } + return false; + } + + + public boolean bool(String name) { + String s = string(name); + if (s != null) { + return "true".equals(s); + } + return false; + } + + public boolean[] boolArray(String name) { + String[] sa = stringArray(name); + if (sa != null) { + boolean[] result = new boolean[sa.length]; + for (int i = 0; i < sa.length; ++i) { + result[i] = "true".equals(sa[i]); + } + return result; + } + return null; + } + + public char character(String name) { + String s = string(name); + if (s != null) { + return s.charAt(0); + } + return '\uffff'; + } + + public char[] characterArray(String name) { + String[] sa = stringArray(name); + if (sa != null) { + char[] result = new char[sa.length]; + for (int i = 0; i < sa.length; ++i) { + result[i] = sa[i].charAt(0); + } + return result; + } + return null; + } + + public byte namedIndex(String name, String[] names) { + String sa = string(name); + if (sa != null) { + for (int i = 0; i < names.length; ++i) { + if (sa.equals(names[i])) { + return (byte) i; + } + } + } + return (byte)-1; + } + + public byte[] namedIndexArray(String name, String[] names) { + String[] sa = stringArray(name); + if (sa != null) { + byte[] result = new byte[sa.length]; + loop: + for (int i = 0; i < sa.length; ++i) { + String s = sa[i]; + for (int j = 0; j < names.length; ++j) { + if (names[j].equals(s)) { + result[i] = (byte) j; + continue loop; + } + } + result[i] = (byte) -1; + } + return result; + } + return null; + } + + public String string(String name) { + if (match(name)) { + String result = readData(); + if (match("/" + name)) { + return result; + } + } + return null; + } + + public String[] stringArray(String name) { + if (match(name + "List")) { + List list = new ArrayList(); + String s; + while (null != (s = string(name))) { + if ("Null".equals(s)) { + s = null; + } + list.add(s); + } + if (match("/" + name + "List")) { + return (String[])list.toArray(new String[list.size()]); + } + } + return null; + } + + public String[][] stringTable(String name) { + if (match(name + "Table")) { + List list = new ArrayList(); + String[] sa; + while (null != (sa = stringArray(name))) { + list.add(sa); + } + if (match("/" + name + "Table")) { + return (String[][])list.toArray(new String[list.size()][]); + } + } + return null; + } + + private boolean match(String target) { + if (getTag().equals(target)) { + //System.out.println("match '" + target + "'"); + advance(); + return true; + } + return false; + } + + private String getTag() { + if (tag == null) { + tag = readNextTag(); + } + return tag; + } + + private void advance() { + tag = null; + } + + private String readData() { + StringBuilder sb = new StringBuilder(); + boolean inWhitespace = false; + boolean inAmp = false; + while (true) { + int c = readChar(); + if (c == -1 || c == '<') { + atTag = c == '<'; + break; + } + if (c == '&') { + c = readChar(); + if (c == '#') { + StringBuilder numBuf = new StringBuilder(); + int radix = 10; + c = readChar(); + if (c == 'x') { + radix = 16; + c = readChar(); + } + while (c != ';' && c != -1) { + numBuf.append((char)c); + c = readChar(); + } + try { + int num = Integer.parseInt(numBuf.toString(), radix); + c = (char)num; + } catch (NumberFormatException ex) { + System.err.println("numbuf: " + numBuf.toString() + " radix: " + radix); + throw ex; + } + } else { + StringBuilder charBuf = new StringBuilder(); + while (c != ';' && c != -1) { + charBuf.append((char)c); + c = readChar(); + } + String charName = charBuf.toString(); + if (charName.equals("lt")) { + c = '<'; + } else if (charName.equals("gt")) { + c = '>'; + } else if (charName.equals("quot")) { + c = '"'; + } else if (charName.equals("apos")) { + c = '\''; + } else if (charName.equals("amp")) { + c = '&'; + } else { + System.err.println("unrecognized character entity: '" + charName + + "'"); + continue; + } + } + } + + if (Character.isWhitespace(c)) { + if (inWhitespace) { + continue; + } + c = ' '; + inWhitespace = true; + } else { + inWhitespace = false; + } + sb.append((char)c); + } + //System.err.println("read data: '" + sb.toString() + "'"); + return sb.toString(); + } + + private String readNextTag() { + int c = '\0'; + while (!atTag) { + c = readChar(); + if (c == '<' || c == -1) { + if (c == '<') { + atTag = true; + } + break; + } + if (!Character.isWhitespace(c)) { + System.err.println("Unexpected non-whitespace character " + + Integer.toHexString(c)); + break; + } + } + + if (atTag) { + atTag = false; + StringBuilder sb = new StringBuilder(); + while (true) { + c = readChar(); + if (c == '>' || c == -1) { + break; + } + sb.append((char) c); + } + // System.err.println("read tag: '" + sb.toString() + "'"); + return sb.toString(); + } + return null; + } + + int readChar() { + try { + return r.read(); + } + catch (IOException e) { + // assume end of input + } + return -1; + } +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/XMLRecordWriter.java b/icu4j/src/com/ibm/icu/impl/duration/impl/XMLRecordWriter.java new file mode 100644 index 00000000000..64f7818e286 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/XMLRecordWriter.java @@ -0,0 +1,257 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration.impl; + +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; + +public class XMLRecordWriter implements RecordWriter { + private Writer w; + private List nameStack; + + public XMLRecordWriter(Writer w) { + this.w = w; + this.nameStack = new ArrayList(); + } + + public boolean open(String title) { + newline(); + writeString("<" + title + ">"); + nameStack.add(title); + return true; + } + + public boolean close() { + int ix = nameStack.size() - 1; + if (ix >= 0) { + String name = (String) nameStack.remove(ix); + newline(); + writeString(""); + return true; + } + return false; + } + + public void flush() { + try { + w.flush(); + } + catch (IOException e) { + } + } + + public void bool(String name, boolean value) { + internalString(name, String.valueOf(value)); + } + + public void boolArray(String name, boolean[] values) { + if (values != null) { + String[] stringValues = new String[values.length]; + for (int i = 0; i < values.length; ++i) { + stringValues[i] = String.valueOf(values[i]); + } + stringArray(name, stringValues); + } + } + + private static String ctos(char value) { + if (value == '<') { + return "<"; + } + if (value == '&') { + return "&"; + } + return String.valueOf(value); + } + + public void character(String name, char value) { + if (value != '\uffff') { + internalString(name, ctos(value)); + } + } + + public void characterArray(String name, char[] values) { + if (values != null) { + String[] stringValues = new String[values.length]; + for (int i = 0; i < values.length; ++i) { + char value = values[i]; + if (value == '\uffff') { + stringValues[i] = NULL_NAME; + } else { + stringValues[i] = ctos(value); + } + } + internalStringArray(name, stringValues); + } + } + + public void namedIndex(String name, String[] names, int value) { + if (value >= 0) { + internalString(name, names[value]); + } + } + + public void namedIndexArray(String name, String[] names, byte[] values) { + if (values != null) { + String[] stringValues = new String[values.length]; + for (int i = 0; i < values.length; ++i) { + int value = values[i]; + if (value < 0) { + stringValues[i] = NULL_NAME; + } else { + stringValues[i] = names[value]; + } + } + internalStringArray(name, stringValues); + } + } + + public static String normalize(String str) { + if (str == null) { + return null; + } + StringBuilder sb = null; + boolean inWhitespace = false; + char c = '\0'; + boolean special = false; + for (int i = 0; i < str.length(); ++i) { + c = str.charAt(i); + if (Character.isWhitespace(c)) { + if (sb == null && (inWhitespace || c != ' ')) { + sb = new StringBuilder(str.substring(0, i)); + } + if (inWhitespace) { + continue; + } + inWhitespace = true; + special = false; + c = ' '; + } else { + inWhitespace = false; + special = c == '<' || c == '&'; + if (special && sb == null) { + sb = new StringBuilder(str.substring(0, i)); + } + } + if (sb != null) { + if (special) { + sb.append(c == '<' ? "<" : "&"); + } else { + sb.append(c); + } + } + } + if (sb != null) { + /* + if (c == ' ') { + int len = sb.length(); + if (len == 0) { + return " "; + } + if (len > 1 && c == ' ') { + sb.deleteCharAt(len - 1); + } + } + */ + return sb.toString(); + } + return str; + } + + private void internalString(String name, String normalizedValue) { + if (normalizedValue != null) { + newline(); + writeString("<" + name + ">" + normalizedValue + ""); + } + } + + private void internalStringArray(String name, String[] normalizedValues) { + if (normalizedValues != null) { + push(name + "List"); + for (int i = 0; i < normalizedValues.length; ++i) { + String value = normalizedValues[i]; + if (value == null) { + value = NULL_NAME; + } + string(name, value); + } + pop(); + } + } + + public void string(String name, String value) { + internalString(name, normalize(value)); + } + + public void stringArray(String name, String[] values) { + if (values != null) { + push(name + "List"); + for (int i = 0; i < values.length; ++i) { + String value = normalize(values[i]); + if (value == null) { + value = NULL_NAME; + } + internalString(name, value); + } + pop(); + } + } + + public void stringTable(String name, String[][] values) { + if (values != null) { + push(name + "Table"); + for (int i = 0; i < values.length; ++i) { + String[] rowValues = values[i]; + if (rowValues == null) { + internalString(name + "List", NULL_NAME); + } else { + stringArray(name, rowValues); + } + } + pop(); + } + } + + private void push(String name) { + newline(); + writeString("<" + name + ">"); + nameStack.add(name); + } + + private void pop() { + int ix = nameStack.size() - 1; + String name = (String) nameStack.remove(ix); + newline(); + writeString(""); + } + + private void newline() { + writeString("\n"); + for (int i = 0; i < nameStack.size(); ++i) { + writeString(INDENT); + } + } + + private void writeString(String str) { + if (w != null) { + try { + w.write(str); + } + catch (IOException e) { + // if there's a problem, record it and stop writing + System.err.println(e.getMessage()); + w = null; + } + } + } + + static final String NULL_NAME = "Null"; + private static final String INDENT = " "; +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/YMDDateFormatter.java b/icu4j/src/com/ibm/icu/impl/duration/impl/YMDDateFormatter.java new file mode 100644 index 00000000000..d6a0955f68a --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/YMDDateFormatter.java @@ -0,0 +1,98 @@ +/* +****************************************************************************** +* Copyright (C) 2007, International Business Machines Corporation and * +* others. All Rights Reserved. * +****************************************************************************** +*/ + +package com.ibm.icu.impl.duration.impl; + +import com.ibm.icu.impl.duration.DateFormatter; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +/** + * A DateFormatter that formats the requested date fields. + */ +public class YMDDateFormatter implements DateFormatter { + private String requestedFields; + private String localeName; + private TimeZone timeZone; + private SimpleDateFormat df; // cache + + /** + * Creates a new formatter that formats the requested + * fields. The formatter defaults to the current locale + * and time zone. + * + * @param requestedFields the requested fields + */ + public YMDDateFormatter(String requestedFields) { + this(requestedFields, Locale.getDefault().toString(), + TimeZone.getDefault()); + } + + /** + * Creates a new formatter that formats the requested + * fields using the provided locale and time zone. + * + * @param requestedFields the requested fields + * @param localeName the locale to use + * @param timeZone the time zone to use + */ + public YMDDateFormatter(String requestedFields, String localeName, + TimeZone timeZone) { + this.requestedFields = requestedFields; + this.localeName = localeName; + this.timeZone = timeZone; + + Locale locale = Utils.localeFromString(localeName); + this.df = new SimpleDateFormat("yyyy/mm/dd", locale); + this.df.setTimeZone(timeZone); + } + + /** + * Returns a string representing the formatted date. + * @param date the date in milliseconds + */ + public String format(long date) { + return format(new Date(date)); + } + + /** + * Returns a string representing the formatted date. + * @param date the date + */ + public String format(Date date) { + synchronized (this) { + if (df == null) { + // ignores requested fields + // todo: make this really work + } + } + return df.format(date); + } + + /** + * Returns a version of this formatter customized to the provided locale. + */ + public DateFormatter withLocale(String localeName) { + if (!localeName.equals(this.localeName)) { + return new YMDDateFormatter(requestedFields, localeName, timeZone); + } + return this; + } + + /** + * Returns a version of this formatter customized to the provided time zone. + */ + public DateFormatter withTimeZone(TimeZone timeZone) { + if (!timeZone.equals(this.timeZone)) { + return new YMDDateFormatter(requestedFields, localeName, timeZone); + } + return this; + } +} diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/index.txt b/icu4j/src/com/ibm/icu/impl/duration/impl/data/index.txt new file mode 100644 index 00000000000..6a0b83c3a15 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/index.txt @@ -0,0 +1,19 @@ +#****************************************************************************** +#* Copyright (C) 2007, International Business Machines Corporation and * +#* others. All Rights Reserved. * +#****************************************************************************** +ar_EG +en +es +fr +he_IL +hi +it +ja +ko +ru +th +zh_Hans +zh_Hans_SG +zh_Hant +zh_Hant_HK diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ar_EG.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ar_EG.xml new file mode 100644 index 00000000000..a177781e370 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ar_EG.xml @@ -0,0 +1,118 @@ + + + + ARABIC + + + سنوات + سنة + سنتين + + + شهور + شهر + شهرين + + + أسابيع + أسبوع + أسبوعين + + + أيام + يوم + يومين + + + ساعات + ساعة + ساعتين + + + دقائق + دقيقة + دقيقتين + + + ثواني + ثانية + ثانيتين + + + أجزاء من الثانية + جزء من الثانية + جزئين من الثانية + + + + نصف + ونصف + + + PREFIX + LAST + + false + + + + ، و + ، و + ، و + و + + DEFAULT + ٠ + ٫ + true + true + DSINGULAR + FSINGULAR_PLURAL + true + false + YES + + + false + + + منذ + false + + + false + بعد الآن + + + أقل من + false + + + منذ أقل من + false + + + أقل من + false + بعد الآن + + + أكثر من + false + + + منذ أكثر من + false + + + أكثر من + false + بعد الآن + + + diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ar_EG.xml.escaped b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ar_EG.xml.escaped new file mode 100644 index 00000000000..80c284af763 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ar_EG.xml.escaped @@ -0,0 +1,118 @@ + + + + ARABIC + + + \u0633\u0646\u0648\u0627\u062a + \u0633\u0646\u0629 + \u0633\u0646\u062a\u064a\u0646 + + + \u0634\u0647\u0648\u0631 + \u0634\u0647\u0631 + \u0634\u0647\u0631\u064a\u0646 + + + \u0623\u0633\u0627\u0628\u064a\u0639 + \u0623\u0633\u0628\u0648\u0639 + \u0623\u0633\u0628\u0648\u0639\u064a\u0646 + + + \u0623\u064a\u0627\u0645 + \u064a\u0648\u0645 + \u064a\u0648\u0645\u064a\u0646 + + + \u0633\u0627\u0639\u0627\u062a + \u0633\u0627\u0639\u0629 + \u0633\u0627\u0639\u062a\u064a\u0646 + + + \u062f\u0642\u0627\u0626\u0642 + \u062f\u0642\u064a\u0642\u0629 + \u062f\u0642\u064a\u0642\u062a\u064a\u0646 + + + \u062b\u0648\u0627\u0646\u064a + \u062b\u0627\u0646\u064a\u0629 + \u062b\u0627\u0646\u064a\u062a\u064a\u0646 + + + \u0623\u062c\u0632\u0627\u0621 \u0645\u0646 \u0627\u0644\u062b\u0627\u0646\u064a\u0629 + \u062c\u0632\u0621 \u0645\u0646 \u0627\u0644\u062b\u0627\u0646\u064a\u0629 + \u062c\u0632\u0626\u064a\u0646 \u0645\u0646 \u0627\u0644\u062b\u0627\u0646\u064a\u0629 + + + + \u0646\u0635\u0641 + \u0648\u0646\u0635\u0641 + + + PREFIX + LAST + + false + + + + \u060c \u0648 + \u060c \u0648 + \u060c \u0648 + \u0648 + + DEFAULT + \u0660 + \u066b + true + true + DSINGULAR + FSINGULAR_PLURAL + true + false + YES + + + false + + + \u0645\u0646\u0630 + false + + + false + \u0628\u0639\u062f \u0627\u0644\u0622\u0646 + + + \u0623\u0642\u0644 \u0645\u0646 + false + + + \u0645\u0646\u0630 \u0623\u0642\u0644 \u0645\u0646 + false + + + \u0623\u0642\u0644 \u0645\u0646 + false + \u0628\u0639\u062f \u0627\u0644\u0622\u0646 + + + \u0623\u0643\u062b\u0631 \u0645\u0646 + false + + + \u0645\u0646\u0630 \u0623\u0643\u062b\u0631 \u0645\u0646 + false + + + \u0623\u0643\u062b\u0631 \u0645\u0646 + false + \u0628\u0639\u062f \u0627\u0644\u0622\u0646 + + + diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_en.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_en.xml new file mode 100644 index 00000000000..5ac58d6125f --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_en.xml @@ -0,0 +1,128 @@ + + + + PLURAL + + + years + year + + + months + month + + + weeks + week + + + days + day + + + hours + hour + + + minutes + minute + + + seconds + second + + + milliseconds + millisecond + + + + yr + mnth + wk + dy + hr + min + sec + ms + + + y + m + w + d + h + m + s + x + + + ½ + ½ + + false + + + + , + , and + , + and + + DEFAULT + 0 + . + false + false + DPLURAL + FSINGULAR_PLURAL + true + false + YES + + + false + + + false + ago + + + false + from now + + + less than + false + + + less than + false + ago + + + less than + false + from now + + + more than + false + + + more than + false + ago + + + more than + false + from now + + + diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_es.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_es.xml new file mode 100644 index 00000000000..a8f99f440a0 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_es.xml @@ -0,0 +1,150 @@ + + + + PLURAL + + + años + año + + + meses + mes + + + semanas + semana + + + días + día + + + horas + hora + + + minutos + minuto + + + segundos + segundo + + + milisegundos + milisegundo + + + + M + M + F + M + F + M + M + M + + + un año + un mes + una semana + un día + una hora + un minuto + un segundo + un milisegundo + + + Null + Null + Null + d + hr + min + seg + mseg + + + a + m + s + d + h + m + s + ms + + + medio + y medio + media + y media + + + PREFIX + LAST + + false + + + + , + y + , + y + + DEFAULT + 0 + , + false + false + DPLURAL + FSINGULAR_PLURAL_ANDAHALF + true + false + YES + + + false + + + hace + false + + + dentro de + false + + + menos de + false + + + hace menos de + false + + + dentro de menos de + false + + + más de + false + + + hace más de + false + + + dentro más de + false + + + diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_fr.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_fr.xml new file mode 100644 index 00000000000..f8d616508ee --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_fr.xml @@ -0,0 +1,105 @@ + + + + PLURAL + + + ans + an + + + mois + mois + + + semaines + semaine + + + jours + jour + + + heures + heure + + + minutes + minute + + + secondes + seconde + + + millisecondes + milliseconde + + + + ½ + ½ + + false + + + + , + et + , + et + + DEFAULT + 0 + . + false + false + ZSINGULAR + DPLURAL + FSINGULAR_PLURAL + true + false + YES + + + false + + + il y a + false + + + dans + false + + + moins de + false + + + il y a moins de + false + + + dans moins de + false + + + plus de + false + + + il y a plus de + false + + + dans plus de + false + + + diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_he_IL.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_he_IL.xml new file mode 100644 index 00000000000..1fd20fef462 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_he_IL.xml @@ -0,0 +1,129 @@ + + + + HEBREW + + + שנים + שנה + שנתיים + + + חודשים + חודש + חודשיים + + + שבועות + שבוע + שבועיים + + + ימים + יום + יומיים + + + שעות + שעה + שעתיים + + + דקות + דקה + Null + + + שניות + שנייה + Null + + + מילישניות + מילישניה + Null + + + + שנה אחת + חודש אחד + שבוע אחד + יום אחד + שעה אחת + דקה אחת + שנייה אחת + מילישניה אחת + + + ½ + ½ + + false + ־ + + + + , + ו + , + ו + + + false + true + false + true + + DEFAULT + 0 + . + true + true + DSINGULAR_SUBONE + FSINGULAR_PLURAL + true + false + YES + + + false + + + לפני + false + + + אחרי + false + + + יותר מ + true + + + לפני יותר מ + true + + + אחרי יותר מ + true + + + פחות מ + true + + + לפני פחות מ + true + + + אחרי פחות מ + true + + + diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_hi.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_hi.xml new file mode 100644 index 00000000000..e2668fa5514 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_hi.xml @@ -0,0 +1,105 @@ + + + + PLURAL + + + साल + साल + + + महीने + महीना + + + सप्ताह + सप्ताह + + + दिन + दिन + + + घंटे + घंटा + + + मिनट + मिनट + + + सेकण्ड + सेकण्ड + + + मिली सेकण्ड + मिली सेकण्ड + + + + ½ + ½ + + false + + + + , + और + , + और + + DEFAULT + + . + false + false + DPLURAL + FPLURAL + true + false + YES + + + false + + + false + पहले + + + अभी से + false + बाद + + + false + से कम + + + false + से कम पहले + + + false + से कम from now + + + false + से ज़्यादा + + + false + से ज़्यादा ago + + + false + से ज़्यादा from now + + + diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_it.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_it.xml new file mode 100644 index 00000000000..e16398fa846 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_it.xml @@ -0,0 +1,175 @@ + + + + PLURAL + + + anni + anno + + + mesi + mese + + + settimane + settimana + + + giorni + giorno + + + ore + ora + + + minuti + minuto + + + secondi + secondo + + + millisecondi + millisecondo + + + + M + M + F + M + F + M + M + M + + + un anno + un mese + una settimana + un giorno + un'ora + un minuto + un secondo + un millisecondo + + + Null + Null + Null + Null + mezz'ora + Null + Null + Null + + + zero + Null + due + tre + quattro + cinque + sei + sette + otto + nove + dieci + + + ann. + mes. + sett. + gg. + or. + min. + sec. + msec. + + + A + M + S + G + H + M + S + Null + + + mezzo + e mezzo + mezza + e mezza + + + PREFIX + LAST + + false + + + + , + e + , + e + + DEFAULT + 0 + . + false + false + DPLURAL + FSINGULAR_PLURAL_ANDAHALF + true + false + YES + + + false + + + false + fa + + + fra + false + + + meno di + false + + + meno di + false + fa + + + fra meno di + false + + + oltre + false + + + oltre + false + fa + + + fra oltre + false + + + diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ja.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ja.xml new file mode 100644 index 00000000000..dd887e09b0b --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ja.xml @@ -0,0 +1,128 @@ + + + + NONE + + + + + + + + + 週間 + + + + + + 時間 + + + + + + + + + ミリ秒 + + + + Null + + Null + Null + Null + Null + Null + Null + + + + + + + PREFIX + LAST + + + YES + YES + NO + YES + YES + ONE_PLUS + YES + NO + + false + + + false + false + true + false + false + false + false + false + + DEFAULT + 0 + . + false + true + DPLURAL + FSINGULAR_PLURAL + + false + true + WITH_SECONDS + + + false + + + false + + + + 今から + false + + + + false + 以内 + + + 過去 + false + 以内 + + + 今から + false + 以内 + + + false + 以上 + + + false + 以上前 + + + 今から + false + 以上後 + + + diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ko.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ko.xml new file mode 100644 index 00000000000..cdc7a425b90 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ko.xml @@ -0,0 +1,93 @@ + + + + NONE + + + + + + 개월 + + + + + + + + + 시간 + + + + + + + + + 밀리세컨드 + + + + ½ + ½ + + false + + + + + + + + DEFAULT + 0 + . + false + false + DPLURAL + FSINGULAR_PLURAL + true + false + YES + + + false + + + false + + + + 지금부터 + false + + + false + + + false + + + + 지금부터 + false + + + false + + + false + + + + 지금부터 + false + + + \ No newline at end of file diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ru.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ru.xml new file mode 100644 index 00000000000..57e375b70f8 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_ru.xml @@ -0,0 +1,143 @@ + + + + PAUCAL + + + лет + год + Null + года + + + месяцев + месяц + Null + месяца + + + недель + неделя + Null + недели + + + дней + день + Null + дня + + + часов + час + Null + часа + + + минут + минута + Null + минуты + + + секунд + секунда + Null + секунды + + + миллисекунд + миллисекунда + Null + миллисекунды + + + + г + мес + нед + дн + ч + мин + с + мс + мкс + + + г + m + н + д + ч + м + с + x + + + ½ + ½ + + false + + + + , + и + , + и + + DEFAULT + 0 + . + false + true + DPAUCAL + FPAUCAL + true + false + YES + + + false + + + false + назад + + + через + false + + + меньше, чем + false + + + меньше, чем + false + назад + + + через + false + + + больше, чем + false + + + больше, чем + false + назад + + + через + false + + + diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_th.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_th.xml new file mode 100644 index 00000000000..bedc88035c4 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_th.xml @@ -0,0 +1,118 @@ + + + + NONE + + + ปี + + + เดือน + + + อาทิตย์ + + + วัน + + + ชั่วโมง + + + นาที + + + วินาที + + + มิลลิวินาที + + + + Null + Null + Null + Null + ชม. + Null + Null + Null + + + ครึ่ง + ครึ่ง + + + PREFIX + LAST + + + YES + YES + YES + YES + YES + YES + NO + NO + + true + + + + DEFAULT + 0 + . + false + false + DPLURAL + FPLURAL + true + false + NO + + + false + + + false + ที่แล้ว + + + อีก + false + + + น้อยกว่า + false + + + น้อยกว่า + false + ที่แล้ว + + + ไม่ถึงอีก + false + + + มากกว่า + false + + + มากกว่า + false + ที่แล้ว + + + อีัก + false + กว่าๆ + + + \ No newline at end of file diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hans.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hans.xml new file mode 100644 index 00000000000..3927c0c30e1 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hans.xml @@ -0,0 +1,132 @@ + + + + NONE + + + + + + + + + + + + + + + 小时 + + + + + + + + + 毫秒 + + + + Null + + Null + Null + + Null + Null + Null + Null + + + + Null + Null + Null + Null + Null + + Null + Null + + + Null + Null + Null + Null + Null + Null + + Null + + Null + + + + + + + PREFIX + AFTER_FIRST + + + false + + CHINESE_SIMPLIFIED + 0 + . + false + true + DPLURAL + FSINGULAR_PLURAL + true + false + YES + + + false + + + false + 以前 + + + false + 以后 + + + 不到 + false + + + 不到 + false + 以前 + + + 不到 + false + 以后 + + + 超过 + false + + + 超过 + false + 以前 + + + 超过 + false + 以后 + + + \ No newline at end of file diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hans_SG.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hans_SG.xml new file mode 100644 index 00000000000..679203d40bd --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hans_SG.xml @@ -0,0 +1,130 @@ + + + + NONE + + + + + + + + + + + + + + + 小时 + + + + + + + + + 毫秒 + + + + Null + + Null + Null + + Null + Null + Null + Null + + + + Null + Null + Null + Null + Null + + Null + Null + + + Null + Null + Null + Null + Null + Null + + Null + + + + + + + PREFIX + AFTER_FIRST + + + false + + CHINESE_SIMPLIFIED + 0 + . + false + true + DPLURAL + FSINGULAR_PLURAL + true + false + YES + + + false + + + false + 以前 + + + false + 以后 + + + 不到 + false + + + 不到 + false + 以前 + + + 不到 + false + 以后 + + + 超过 + false + + + 超过 + false + 以前 + + + 超过 + false + 以后 + + + \ No newline at end of file diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hant.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hant.xml new file mode 100644 index 00000000000..73ac14f7896 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hant.xml @@ -0,0 +1,130 @@ + + + + NONE + + + + + + + + + + + + + + + 小時 + + + + + + + + + 毫秒 + + + + Null + + Null + Null + + Null + Null + Null + + + Null + Null + Null + Null + Null + + Null + Null + + + Null + Null + Null + Null + Null + Null + + Null + + Null + + + + + + + PREFIX + AFTER_FIRST + + + false + + CHINESE_TRADITIONAL + 0 + . + false + true + DPLURAL + FSINGULAR_PLURAL + true + false + YES + + + false + + + false + 以前 + + + false + 以後 + + + 不到 + false + + + 不到 + false + 以前 + + + 不到 + false + 以後 + + + 超過 + false + + + 超過 + false + 以前 + + + 超過 + false + 以後 + + + \ No newline at end of file diff --git a/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hant_HK.xml b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hant_HK.xml new file mode 100644 index 00000000000..320d27f51f3 --- /dev/null +++ b/icu4j/src/com/ibm/icu/impl/duration/impl/data/pfd_zh_Hant_HK.xml @@ -0,0 +1,116 @@ + + + + NONE + + + + + + + + + + + + + + + 小時 + + + + + + + + + 毫秒 + + + + Null + + Null + Null + Null + Null + Null + Null + + + Null + Null + Null + Null + Null + + Null + Null + + + + + + + PREFIX + AFTER_FIRST + + false + + DEFAULT + 0 + . + false + true + DPLURAL + FSINGULAR_PLURAL + true + false + YES + + + false + + + false + 之前 + + + false + 之後 + + + 少於 + false + + + false + 以內 + + + 即時起 + false + 以內 + + + 超過 + false + + + 超過 + false + 之前 + + + 即時起 + false + 之後 + + + \ No newline at end of file diff --git a/icu4j/src/com/ibm/icu/text/DurationFormat.java b/icu4j/src/com/ibm/icu/text/DurationFormat.java index 4566f9d1ea7..78358b4fcf9 100644 --- a/icu4j/src/com/ibm/icu/text/DurationFormat.java +++ b/icu4j/src/com/ibm/icu/text/DurationFormat.java @@ -10,6 +10,7 @@ import java.text.FieldPosition; import java.text.ParsePosition; import java.util.Date; +import com.ibm.icu.impl.duration.BasicDurationFormat; import com.ibm.icu.util.ULocale; /** @@ -26,7 +27,7 @@ public abstract class DurationFormat extends UFormat { * @provisional This API might change or be removed in a future release. */ public static DurationFormat getInstance(ULocale locale) { - throw new UnsupportedOperationException(); + return (DurationFormat)BasicDurationFormat.getInstance(locale); } @@ -37,6 +38,15 @@ public abstract class DurationFormat extends UFormat { */ protected DurationFormat() { } + + /** + * Subclass interface + * @internal + * @deprecated This API is ICU internal only. + */ + protected DurationFormat(ULocale locale) { + setLocale(locale,locale); + } /** * Format an arbitrary object.