From 383c004638b5dfba6b0de42ec017a1170ffb9961 Mon Sep 17 00:00:00 2001 From: Edwin Hoogerbeets Date: Thu, 9 Apr 2020 17:36:50 -0700 Subject: [PATCH 01/48] Add apidocs target. Update few docs. --- docs/index.md | 6 +++++- js/build.xml | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/index.md b/docs/index.md index ce01b3fcb0..8718ca9477 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,6 +2,8 @@ Hello, and welcome to the iLib project! +View this documentation on [github pages](https://ilib-js.github.io/iLib/docs/) + * [Welcome](Welcome.md) * [History](History.md) * [License](License.md) @@ -10,7 +12,7 @@ Hello, and welcome to the iLib project! # Documentation # * [Getting Started](GettingStarted.md) -* [Old Tutorial](tutorial/iLib1.0JSTutorial.pdf) +* Tutorials: * [Handling Phone Numbers in iLib](tutorial/phone.md) * [Name Parsing and Formatting](tutorial/name.md) * [Glyphs, Characters, and Character Normalization](tutorial/characters.md) @@ -20,6 +22,8 @@ Hello, and welcome to the iLib project! * Architecture and Process * [Overall Architecture](Architecture.md) * [CommonJS Modularization Support](tutorial/modules.md) as of 11.0 + * For ES6-style modules, see the [ilib-es6](https://github.com/ilib-js/ilib-es6/) project + which provides wrappers for all ilib classes * [Updating the time zone information](tutorial/timezone.md) * [Running unit test on QT/QML](QtTest.md) * API Reference: diff --git a/js/build.xml b/js/build.xml index f6acc29d1c..eec32bc6fe 100644 --- a/js/build.xml +++ b/js/build.xml @@ -30,7 +30,9 @@ limitations under the License. - + + + @@ -850,7 +852,7 @@ limitations under the License. @@ -868,6 +870,16 @@ limitations under the License. + + + + + + + + From a17c469302bab2427bf067111e9f024bb9cd7df0 Mon Sep 17 00:00:00 2001 From: Edwin Hoogerbeets Date: Thu, 9 Apr 2020 17:58:06 -0700 Subject: [PATCH 02/48] Put the api docs in the right place --- build.xml | 5 +++++ java/build.xml | 15 +++++++++++++++ js/build.xml | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/build.xml b/build.xml index 9b9e7dae7a..acc1feed54 100644 --- a/build.xml +++ b/build.xml @@ -130,6 +130,11 @@ limitations under the License. + + + + + diff --git a/java/build.xml b/java/build.xml index 9e5030253a..c4955320a1 100644 --- a/java/build.xml +++ b/java/build.xml @@ -57,6 +57,8 @@ limitations under the License. + + @@ -374,4 +376,17 @@ limitations under the License. + + + + + + + + + + + \ No newline at end of file diff --git a/js/build.xml b/js/build.xml index eec32bc6fe..5cfe17b83f 100644 --- a/js/build.xml +++ b/js/build.xml @@ -32,7 +32,7 @@ limitations under the License. - + From c1794f98b553372f9b4d4572260f28e351f666fc Mon Sep 17 00:00:00 2001 From: Edwin Hoogerbeets Date: Thu, 9 Apr 2020 18:03:04 -0700 Subject: [PATCH 03/48] Clean up too --- java/build.xml | 1 + js/build.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/java/build.xml b/java/build.xml index c4955320a1..b5889044a6 100644 --- a/java/build.xml +++ b/java/build.xml @@ -108,6 +108,7 @@ limitations under the License. + diff --git a/js/build.xml b/js/build.xml index 5cfe17b83f..940a8bfce9 100644 --- a/js/build.xml +++ b/js/build.xml @@ -114,6 +114,7 @@ limitations under the License. + From 4b9ea34d5d3dca9a4b2f2ec9792be96e569069a6 Mon Sep 17 00:00:00 2001 From: Edwin Hoogerbeets Date: Mon, 18 May 2020 23:27:19 -0700 Subject: [PATCH 04/48] Update to tz 2020a --- js/data/locale/zoneinfo/Africa/Casablanca.json | 2 +- js/data/locale/zoneinfo/Africa/El_Aaiun.json | 2 +- js/data/locale/zoneinfo/America/Dawson.json | 17 ++--------------- js/data/locale/zoneinfo/America/Nuuk.json | 18 ++++++++++++++++++ .../locale/zoneinfo/America/Whitehorse.json | 17 ++--------------- js/data/locale/zoneinfo/Canada/Yukon.json | 17 ++--------------- js/data/locale/zoneinfo/zonetab.json | 1 + 7 files changed, 27 insertions(+), 47 deletions(-) create mode 100644 js/data/locale/zoneinfo/America/Nuuk.json diff --git a/js/data/locale/zoneinfo/Africa/Casablanca.json b/js/data/locale/zoneinfo/Africa/Casablanca.json index b216957835..7d38000603 100644 --- a/js/data/locale/zoneinfo/Africa/Casablanca.json +++ b/js/data/locale/zoneinfo/Africa/Casablanca.json @@ -1,7 +1,7 @@ { "e": { "m": 5, - "r": "24", + "r": "31", "t": "2:0" }, "f": "+01/+00", diff --git a/js/data/locale/zoneinfo/Africa/El_Aaiun.json b/js/data/locale/zoneinfo/Africa/El_Aaiun.json index 84cafccbd1..31d603ed64 100644 --- a/js/data/locale/zoneinfo/Africa/El_Aaiun.json +++ b/js/data/locale/zoneinfo/Africa/El_Aaiun.json @@ -1,7 +1,7 @@ { "e": { "m": 5, - "r": "24", + "r": "31", "t": "2:0" }, "f": "+01/+00", diff --git a/js/data/locale/zoneinfo/America/Dawson.json b/js/data/locale/zoneinfo/America/Dawson.json index aeb4e2ec1c..10e3ae118d 100644 --- a/js/data/locale/zoneinfo/America/Dawson.json +++ b/js/data/locale/zoneinfo/America/Dawson.json @@ -1,19 +1,6 @@ { - "e": { - "c": "S", - "m": 11, - "r": "0>1", - "t": "2:0" - }, - "f": "P{c}T", - "o": "-8:0", - "s": { - "c": "D", - "m": 3, - "r": "0>8", - "t": "2:0", - "v": "1:0" - }, + "f": "MST", + "o": "-7:0", "c": "CA", "n": "Pacific {c} Time" } \ No newline at end of file diff --git a/js/data/locale/zoneinfo/America/Nuuk.json b/js/data/locale/zoneinfo/America/Nuuk.json new file mode 100644 index 0000000000..c84d78469e --- /dev/null +++ b/js/data/locale/zoneinfo/America/Nuuk.json @@ -0,0 +1,18 @@ +{ + "e": { + "m": 10, + "r": "l6", + "t": "23:0" + }, + "f": "-03/-02", + "o": "-3:0", + "s": { + "c": "S", + "m": 3, + "r": "l6", + "t": "22:0", + "v": "1:0" + }, + "c": "GL", + "n": "Greenland {c} Time" +} \ No newline at end of file diff --git a/js/data/locale/zoneinfo/America/Whitehorse.json b/js/data/locale/zoneinfo/America/Whitehorse.json index aeb4e2ec1c..10e3ae118d 100644 --- a/js/data/locale/zoneinfo/America/Whitehorse.json +++ b/js/data/locale/zoneinfo/America/Whitehorse.json @@ -1,19 +1,6 @@ { - "e": { - "c": "S", - "m": 11, - "r": "0>1", - "t": "2:0" - }, - "f": "P{c}T", - "o": "-8:0", - "s": { - "c": "D", - "m": 3, - "r": "0>8", - "t": "2:0", - "v": "1:0" - }, + "f": "MST", + "o": "-7:0", "c": "CA", "n": "Pacific {c} Time" } \ No newline at end of file diff --git a/js/data/locale/zoneinfo/Canada/Yukon.json b/js/data/locale/zoneinfo/Canada/Yukon.json index e1e3a13f2c..9832f61f9e 100644 --- a/js/data/locale/zoneinfo/Canada/Yukon.json +++ b/js/data/locale/zoneinfo/Canada/Yukon.json @@ -1,18 +1,5 @@ { - "e": { - "c": "S", - "m": 11, - "r": "0>1", - "t": "2:0" - }, - "f": "P{c}T", - "o": "-8:0", - "s": { - "c": "D", - "m": 3, - "r": "0>8", - "t": "2:0", - "v": "1:0" - }, + "f": "MST", + "o": "-7:0", "c": "CA" } \ No newline at end of file diff --git a/js/data/locale/zoneinfo/zonetab.json b/js/data/locale/zoneinfo/zonetab.json index 5158eaa441..69c1230ec8 100644 --- a/js/data/locale/zoneinfo/zonetab.json +++ b/js/data/locale/zoneinfo/zonetab.json @@ -387,6 +387,7 @@ "GL": [ "America/Danmarkshavn", "America/Godthab", + "America/Nuuk", "America/Scoresbysund", "America/Thule" ], From e9aac98519377177e015b3ebe4562c467e9d4374 Mon Sep 17 00:00:00 2001 From: Edwin Hoogerbeets Date: Mon, 18 May 2020 23:35:22 -0700 Subject: [PATCH 05/48] Update release notes and version number --- build.properties | 2 +- docs/ReleaseNotes.md | 9 +++++++++ package.json | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/build.properties b/build.properties index 1d07d57a57..3c546d4aea 100644 --- a/build.properties +++ b/build.properties @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -version=14.6.0 +version=14.6.1 diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index 225ffafe52..7c9288d762 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -1,6 +1,15 @@ Release Notes for Version 14 ============================ +Build 010 +------- +Published as version 14.6.1 + +New Features: + +Bug Fixes: +* Updated to IANA time zone data 2020a + Build 009 ------- Published as version 14.6.0 diff --git a/package.json b/package.json index 1c25461ac6..2bc69b0fe9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ilib", - "version": "14.6.0", + "version": "14.6.1", "main": "js/index.js", "description": "iLib is a cross-engine library of internationalization (i18n) classes written in pure JS", "keywords": [ From 022492a1a4b932b09b7f5a75eafdd6e90f9f27f6 Mon Sep 17 00:00:00 2001 From: Seonghyup Park Date: Thu, 28 May 2020 11:15:11 +0900 Subject: [PATCH 06/48] Put base option back on ResBundle and remove root option --- js/lib/ResBundle.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/lib/ResBundle.js b/js/lib/ResBundle.js index be4e814f62..2cac084ce7 100644 --- a/js/lib/ResBundle.js +++ b/js/lib/ResBundle.js @@ -250,8 +250,8 @@ var ResBundle = function (options) { if (typeof(options.loadParams) !== 'undefined') { this.loadParams = options.loadParams; - if (typeof (options.loadParams.root) !== 'undefined') { - this.path = options.loadParams.root; + if (typeof (options.loadParams.base) !== 'undefined') { + this.path = options.loadParams.base; } } if (typeof(options.missing) !== 'undefined') { From 4926d6cfe9c7f6ce4d1f04d2be2435b968c39035 Mon Sep 17 00:00:00 2001 From: Seonghyup Park Date: Fri, 29 May 2020 16:40:05 +0900 Subject: [PATCH 07/48] Update release notes and support root option For backwards compatibility --- docs/ReleaseNotes.md | 1 + js/lib/ResBundle.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index 7c9288d762..b3a02896ef 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -9,6 +9,7 @@ New Features: Bug Fixes: * Updated to IANA time zone data 2020a +* Put base option back on ResBundle Build 009 ------- diff --git a/js/lib/ResBundle.js b/js/lib/ResBundle.js index 2cac084ce7..c31ed7cbe2 100644 --- a/js/lib/ResBundle.js +++ b/js/lib/ResBundle.js @@ -250,7 +250,9 @@ var ResBundle = function (options) { if (typeof(options.loadParams) !== 'undefined') { this.loadParams = options.loadParams; - if (typeof (options.loadParams.base) !== 'undefined') { + if (typeof (options.loadParams.root) !== 'undefined') { + this.path = options.loadParams.root; + } else if (typeof (options.loadParams.base) !== 'undefined') { this.path = options.loadParams.base; } } From b79b44ae1aae249840f36fbd4cdf533eee8225e2 Mon Sep 17 00:00:00 2001 From: Edwin Hoogerbeets Date: Fri, 29 May 2020 09:03:40 -0700 Subject: [PATCH 08/48] Make sure that options.basePath takes precedence over older options The basePath is a newer option, so any code that is using it clearly meant to use that instead of the older stuff. --- js/lib/ResBundle.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/lib/ResBundle.js b/js/lib/ResBundle.js index c31ed7cbe2..9f89c33b7c 100644 --- a/js/lib/ResBundle.js +++ b/js/lib/ResBundle.js @@ -250,10 +250,12 @@ var ResBundle = function (options) { if (typeof(options.loadParams) !== 'undefined') { this.loadParams = options.loadParams; - if (typeof (options.loadParams.root) !== 'undefined') { - this.path = options.loadParams.root; - } else if (typeof (options.loadParams.base) !== 'undefined') { - this.path = options.loadParams.base; + if (!this.path) { + if (typeof (options.loadParams.root) !== 'undefined') { + this.path = options.loadParams.root; + } else if (typeof (options.loadParams.base) !== 'undefined') { + this.path = options.loadParams.base; + } } } if (typeof(options.missing) !== 'undefined') { From 31bd4c0afb54cd49b10f716c984254566d95791c Mon Sep 17 00:00:00 2001 From: Edwin Hoogerbeets Date: Thu, 4 Jun 2020 00:53:31 -0700 Subject: [PATCH 09/48] Convert util.log to console.log - Also util.error to console.error - removed util require when possible --- js/lib/AsyncNodeLoader.js | 8 +- js/lib/Loader.js | 2 +- js/lib/NodeLoader.js | 8 +- js/lib/WebLoader.js | 2 +- js/lib/WebpackLoader.js | 4 +- js/test/calendar/testtimezoneasync.js | 4 +- package.json | 1 + tools/build/dependencies.js | 40 +- tools/build/jsoncompress.js | 24 +- tools/build/mkli.js | 18 +- tools/build/mkmf.js | 16 +- tools/build/mkstubs.js | 16 +- tools/cldr/charmapfile.js | 10 +- tools/cldr/common.js | 18 +- tools/cldr/datefmts.js | 46 +- tools/cldr/gencharmap.js | 126 +- tools/cldr/genclockprefs.js | 14 +- tools/cldr/gencoll.js | 89 +- tools/cldr/gencountrynames.js | 22 +- tools/cldr/genctype.js | 4 +- tools/cldr/gencurrencies.js | 6 +- tools/cldr/gendatefmts.js | 4033 ++++++++++++------------- tools/cldr/gendatefmts2.js | 52 +- tools/cldr/gendelimiters.js | 16 +- tools/cldr/genlang2charset.js | 7 +- tools/cldr/genlangreg.js | 2 +- tools/cldr/genlangscripts.js | 6 +- tools/cldr/genlikelyloc.js | 4 +- tools/cldr/genlist.js | 12 +- tools/cldr/genmeasurementsystem.js | 8 +- tools/cldr/gennorm.js | 23 +- tools/cldr/gennormtest.js | 17 +- tools/cldr/gennumfmt.js | 48 +- tools/cldr/genpapersizes.js | 8 +- tools/cldr/genphone.js | 37 +- tools/cldr/genplurals.js | 2 +- tools/cldr/genscripts.js | 2 +- tools/cldr/gentzinfo.js | 40 +- tools/cldr/genunits.js | 10 +- tools/cldr/genweekdata.js | 8 +- tools/cldr/reversectry.js | 10 +- tools/cldr/test/testcommon.js | 2 +- tools/locmaker/locmaker.js | 6 +- tools/phone/gengeoinfo.js | 8 +- tools/phone/geniddarea.js | 6 +- tools/phone/gennumplan.js | 6 +- tools/phone/genphonefmt.js | 6 +- tools/phone/genphoneloc.js | 6 +- 48 files changed, 2425 insertions(+), 2438 deletions(-) diff --git a/js/lib/AsyncNodeLoader.js b/js/lib/AsyncNodeLoader.js index 29a275daaa..30837b5eff 100644 --- a/js/lib/AsyncNodeLoader.js +++ b/js/lib/AsyncNodeLoader.js @@ -2,7 +2,7 @@ * AsyncAsyncNodeLoader.js - Loader implementation for nodejs with asynchronous calls. * Mostly this is used for testing the async calls * - * Copyright © 2018, JEDLSoft + * Copyright © 2018, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ module.exports = function (ilib) { Loader = require("./Loader.js"); var AsyncNodeLoader = function (ilib) { - // util.print("new common AsyncNodeLoader instance\n"); + // console.log("new common AsyncNodeLoader instance"); this.parent.call(this, ilib); @@ -44,8 +44,8 @@ module.exports = function (ilib) { path.join(path.dirname(module.filename), "..") : this.root; - //console.log("module.filename is " + module.filename + "\n"); - //console.log("base is defined as " + this.base + "\n"); + //console.log("module.filename is " + module.filename); + //console.log("base is defined as " + this.base); // this.includePath.push(path.join(this.root, "resources")); this._exists(this.root, "resources"); // always check the application's resources dir first diff --git a/js/lib/Loader.js b/js/lib/Loader.js index 9cdb5598b7..e3d7f808ee 100644 --- a/js/lib/Loader.js +++ b/js/lib/Loader.js @@ -98,7 +98,7 @@ Loader.prototype.loadFiles = function(paths, sync, params, callback, root) { return; } - //console.log("generic loader: attempting to load these files: " + JSON.stringify(paths) + "\n"); + //console.log("generic loader: attempting to load these files: " + JSON.stringify(paths)); if (sync) { var ret = []; diff --git a/js/lib/NodeLoader.js b/js/lib/NodeLoader.js index 5b2b6392e1..ed21af38a9 100644 --- a/js/lib/NodeLoader.js +++ b/js/lib/NodeLoader.js @@ -1,7 +1,7 @@ /* * NodeLoader.js - Loader implementation for nodejs * - * Copyright © 2015, JEDLSoft + * Copyright © 2015, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ module.exports = function (ilib) { Loader = require("./Loader.js"); var NodeLoader = function (ilib) { - // util.print("new common NodeLoader instance\n"); + // console.log("new common NodeLoader instance"); this.parent.call(this, ilib); @@ -43,8 +43,8 @@ module.exports = function (ilib) { path.join(path.dirname(module.filename), "..") : this.root; - //console.log("module.filename is " + module.filename + "\n"); - //console.log("base is defined as " + this.base + "\n"); + //console.log("module.filename is " + module.filename); + //console.log("base is defined as " + this.base); // this.includePath.push(path.join(this.root, "resources")); // always check the application's resources dir first this._exists(this.root, "resources"); // always check the application's resources dir first diff --git a/js/lib/WebLoader.js b/js/lib/WebLoader.js index 0a8e82013c..6a86e899c9 100644 --- a/js/lib/WebLoader.js +++ b/js/lib/WebLoader.js @@ -31,7 +31,7 @@ var Locale = require("./Locale.js"); * @private */ var WebLoader = function(ilib, sync, onLoad) { - //console.log("new WebLoader instance\n"); + //console.log("new WebLoader instance"); this.parent.call(this, ilib); diff --git a/js/lib/WebpackLoader.js b/js/lib/WebpackLoader.js index 4b1ff9018f..a0c93f65dc 100644 --- a/js/lib/WebpackLoader.js +++ b/js/lib/WebpackLoader.js @@ -1,7 +1,7 @@ /* * WebpackLoader.js - Loader implementation for webpack'ed ilib on the web * - * Copyright © 2018, JEDLSoft + * Copyright © 2018, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ function loadLocaleData(ilib, locale, callback) { */ module.exports = function (ilib) { var WebpackLoader = function (ilib) { - // util.print("new common WebpackLoader instance\n"); + // console.log("new common WebpackLoader instance"); this.parent.call(this, ilib); this.ilib = ilib; diff --git a/js/test/calendar/testtimezoneasync.js b/js/test/calendar/testtimezoneasync.js index 132bb9c706..32e09d9348 100644 --- a/js/test/calendar/testtimezoneasync.js +++ b/js/test/calendar/testtimezoneasync.js @@ -1,7 +1,7 @@ /* * testtimezoneasync.js - test the timezone objects asynchronously * - * Copyright © 2015,2017-2018, JEDLSoft + * Copyright © 2015,2017-2018,2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ module.exports.testtimezoneasync = { test.ok(typeof(zones) !== "undefined"); //var util = require("util"); - //util.print("ilib._load is " + util.inspect(ilib._load) + "\n"); + //console.log("ilib._load is " + util.inspect(ilib._load)); test.contains(zones, "Europe/London"); test.contains(zones, "America/Los_Angeles"); test.contains(zones, "Australia/Sydney"); diff --git a/package.json b/package.json index 2bc69b0fe9..54b94a784a 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "ilib-webpack-plugin": "^1.3.0", "iso-15924": "^2.1.0", "jsdoc2": "^2.4.0", + "node-expat": "2.3.18", "nodeunit": "^0.11.0", "should": "^13.2.3", "tap": "^10.0.2", diff --git a/tools/build/dependencies.js b/tools/build/dependencies.js index 430d8798e2..c4b93a7104 100644 --- a/tools/build/dependencies.js +++ b/tools/build/dependencies.js @@ -3,7 +3,7 @@ * uses those modules to have the right require() statements at the * top of them * - * Copyright © 2015, JEDLSoft + * Copyright © 2015, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ var util = require('util'); var path = require('path'); function usage() { - util.print("Usage: dependencies.js [-h] [-c] [-v] [-I lib_dir ] [start_dir]\n" + + console.log("Usage: dependencies.js [-h] [-c] [-v] [-I lib_dir ] [start_dir]\n" + "Automatically find modules and update code that uses those modules\n" + "to have the right require() statements at the top of them.\n\n" + "-h or --help\n" + @@ -43,7 +43,7 @@ function usage() { " start dir for modules." + "start_dir\n" + " The top level of the diretory to search for js file that need their\n" + - ' require() statements updated. Default "."\n'); + ' require() statements updated. Default "."'); process.exit(1); } @@ -62,7 +62,7 @@ for (var i = 2; i < process.argv.length; i++) { case "-i": case "--include": if (i+1 >= process.argv.length) { - util.print("Error: " + process.argv[i] + " must be followed by a directory name"); + console.log("Error: " + process.argv[i] + " must be followed by a directory name"); usage(); } i++; @@ -81,7 +81,7 @@ for (var i = 2; i < process.argv.length; i++) { default: if (process.argv[i].charAt(0) === '-') { - util.print("Unrecognized option: " + process.argv[i] + "\n"); + console.log("Unrecognized option: " + process.argv[i]); usage(); } startDir.push(process.argv[i]); @@ -93,18 +93,18 @@ if (startDir.length === 0) { startDir.push("."); } -verbose && util.print("Start dir: " + startDir + "\n"); +verbose && console.log("Start dir: " + startDir); for (i = 0; i < startDir.length; i++) { if (!fs.existsSync(startDir[i])) { - util.print("Could not access start directory " + startDir[i] + "\n"); + console.log("Could not access start directory " + startDir[i]); usage(); } } for (i = 0; i < includes.length; i++) { if (!fs.existsSync(includes[i])) { - util.print("Could not access include directory " + includes[i] + "\n"); + console.log("Could not access include directory " + includes[i]); usage(); } } @@ -307,20 +307,20 @@ function processFile(dir, file, update) { var result, text = fs.readFileSync(pathname, "utf-8"); if (text) { if (update) { - verbose && util.print("Searching " + pathname + " for module definitions..."); + verbose && console.log("Searching " + pathname + " for module definitions..."); if ((result = reExports.exec(text)) && result && result.length > 0) { - verbose && util.print("found " + result[1]); + verbose && console.log("found " + result[1]); modules[result[1]] = { "path": pathname, "re": new RegExp("([^\\w\\$]" + result[1] + "[^\\w\\$]|^" + result[1] + "[^\\w\\$]|[^\\w\\$]" + result[1] + "$)") } } - verbose && util.print("\n"); + verbose && console.log(""); reExports.lastIndex = 0; } else { verbose && console.log("Searching " + pathname + " to update its require() calls."); if (reSlashSlashNoDependencies.test(text)) { - verbose && util.print(" Found a 'dependencies: false' comment. Skipping this file.\n"); + verbose && console.log(" Found a 'dependencies: false' comment. Skipping this file."); } else { var uses = []; var requires = []; @@ -330,10 +330,10 @@ function processFile(dir, file, update) { var len = text.length; // first convert old ilib namespace calls to the modular classes for (var name in legacyCalls) { - util.print(" trying " + name + "\n"); + console.log(" trying " + name); text = text.replace(new RegExp(name, "g"), legacyCalls[name]); if (text.length !== len) { - verbose && util.print(" Replaced legacy call " + name + " with call to module " + legacyCalls[name] + "\n"); + verbose && console.log(" Replaced legacy call " + name + " with call to module " + legacyCalls[name]); len = text.length; changes++; } @@ -349,7 +349,7 @@ function processFile(dir, file, update) { if (modules[mod].path !== pathname) { result = modules[mod].re.exec(cleaned); if (result && result.length > 0) { - verbose && util.print(" This file uses module " + mod + "\n"); + verbose && console.log(" This file uses module " + mod); uses.push(mod); } modules[mod].re.lastIndex = 0; @@ -357,7 +357,7 @@ function processFile(dir, file, update) { } while ((result = reRequires.exec(cleaned)) && result && result.length > 0) { - verbose && util.print(" File already requires " + result[1] + "\n"); + verbose && console.log(" File already requires " + result[1]); requires.push(result[1]); } @@ -365,7 +365,7 @@ function processFile(dir, file, update) { for (i = 0; i < uses.length; i++) { if (requires.indexOf(uses[i]) === -1) { - verbose && util.print(" Need to add require('" + uses[i] + "')\n"); + verbose && console.log(" Need to add require('" + uses[i] + "')"); changes++; j = 0; @@ -397,7 +397,7 @@ function processFile(dir, file, update) { for (i = 0; i < requires.length; i++) { if (uses.indexOf(requires[i]) === -1) { - verbose && util.print(" Need to remove require('" + requires[i] + "')\n"); + verbose && console.log(" Need to remove require('" + requires[i] + "')"); changes++; if (!updated) { @@ -417,7 +417,7 @@ function processFile(dir, file, update) { } } - verbose && util.print(changes + " changes were needed.\n"); + verbose && console.log(changes + " changes were needed."); if (changes > 0) { filesUpdated++; fs.writeFileSync(pathname, updated.join("\n")); @@ -460,4 +460,4 @@ for (i = 0; i < startDir.length; i++) { } } -util.print("Done. " + filesUpdated + " files updated.\n"); \ No newline at end of file +console.log("Done. " + filesUpdated + " files updated."); \ No newline at end of file diff --git a/tools/build/jsoncompress.js b/tools/build/jsoncompress.js index 78183fa245..0a02093786 100644 --- a/tools/build/jsoncompress.js +++ b/tools/build/jsoncompress.js @@ -1,7 +1,7 @@ /* * jsoncompress.js - ilib tool to remove the whitespace from json files * - * Copyright © 2013, JEDLSoft + * Copyright © 2013, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,14 +25,14 @@ var common = require('../cldr/common'); var path = require('../../js/lib/Path.js'); function usage() { - util.print("Usage: jsoncompress.js [-h] [source_dir [target_dir]]\n" + + console.log("Usage: jsoncompress.js [-h] [source_dir [target_dir]]\n" + "Find all json files and compress all the whitespace out of them.\n\n" + "-h or --help\n" + " this help\n" + "source_dir\n" + ' Where to find json files to compress. Default "."\n' + "target_dir\n" + - ' Where to put the results. Default "compressed"\n'); + ' Where to put the results. Default "compressed"'); process.exit(1); } @@ -52,7 +52,7 @@ if (process.argv.length > 2) { fs.exists(sourcedir, function (exists) { if (!exists) { - util.print("Could not access source directory " + sourcedir + "\n"); + console.log("Could not access source directory " + sourcedir); usage(); } }); @@ -62,14 +62,14 @@ fs.exists(targetdir, function (exists) { try { common.makeDirs(targetdir); } catch (e) { - util.print("Could not access or create target directory " + targetdir + "\nError: " + e + "\n"); + console.log("Could not access or create target directory " + targetdir + "\nError: " + e); usage(); } } }); -util.print("source dir: " + sourcedir + "\n"); -util.print("target dir: " + targetdir + "\n"); +console.log("source dir: " + sourcedir); +console.log("target dir: " + targetdir); //escape some of these Unicode characters because Google Closure Compiler doesn't like them function escape(str) { @@ -111,18 +111,18 @@ function walk(root, dir) { obj = JSON.parse(data); var targetPath = path.join(targetdir, sourcePathRelative); - util.print("compress " + sourcePath + " -> " + targetPath + "\n"); + console.log("compress " + sourcePath + " -> " + targetPath); var targetDir = path.dirname(targetPath); - //util.print("dirname is " + targetDir + "\n"); + //console.log("dirname is " + targetDir); common.makeDirs(targetDir); - //util.print("writing file " + targetPath + "\n"); + //console.log("writing file " + targetPath); fs.writeFileSync(targetPath, escape(JSON.stringify(obj)), 'utf8'); } } catch (err) { - util.print("File " + sourcePath + " is not readable or does not contain valid JSON.\n"); - util.print(err + "\n"); + console.log("File " + sourcePath + " is not readable or does not contain valid JSON."); + console.log(err); process.exit(2); } } diff --git a/tools/build/mkli.js b/tools/build/mkli.js index 7f3c48d3d9..d506a0b754 100644 --- a/tools/build/mkli.js +++ b/tools/build/mkli.js @@ -1,7 +1,7 @@ /* * mkli.js - ilib tool to remove the non-json fragments * - * Copyright © 2013, LGE + * Copyright © 2013, 2020 LGE * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,20 +24,20 @@ var util = require('util'); var common = require('../cldr/common'); function usage() { - util.print("Usage: mkli.js [-h] [locale_data_dir]\n" + + console.log("Usage: mkli.js [-h] [locale_data_dir]\n" + "Make the localeinfo.json files from the jf fragment files.\n\n" + "-h or --help\n" + " this help\n" + "locale_data_dir\n" + - ' the top level of the ilib locale data directory. Default "."\n'); + ' the top level of the ilib locale data directory. Default "."'); process.exit(1); } localeDirName = process.argv[2] || "."; -util.print("locale dir: " + localeDirName + "\n"); +console.log("locale dir: " + localeDirName); fs.exists(localeDirName, function (exists) { if (!exists) { - util.print("Could not access locale data directory " + localeDirName); + console.log("Could not access locale data directory " + localeDirName); usage(); } }); @@ -61,8 +61,8 @@ function walk(dir, locale) { merged = common.merge(merged, obj); } } catch (err) { - util.print("File " + path + " is not readable or does not contain valid JSON.\n"); - util.print(err + "\n"); + console.log("File " + path + " is not readable or does not contain valid JSON."); + console.log(err); } } } @@ -75,9 +75,9 @@ function walk(dir, locale) { } merged.locale = locale; fs.writeFileSync(path + "/localeinfo.json", JSON.stringify(merged, true, 4), 'utf8'); - util.print(path + ": merged *.jf into localeinfo.json\n"); + console.log(path + ": merged *.jf into localeinfo.json"); } else { - util.print(path + ": nothing to write\n"); + console.log(path + ": nothing to write"); } return results; diff --git a/tools/build/mkmf.js b/tools/build/mkmf.js index f3b37558f5..b843a1ef7a 100644 --- a/tools/build/mkmf.js +++ b/tools/build/mkmf.js @@ -1,7 +1,7 @@ /* * mkmf.js - ilib tool to create the manifest file for locale data * - * Copyright © 2013, JEDLSoft + * Copyright © 2013, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,12 +25,12 @@ var common = require('../cldr/common'); var path = require('../../js/lib/Path.js'); function usage() { - util.print("Usage: mkmf.js [-h] source_dir\n" + + console.log("Usage: mkmf.js [-h] source_dir\n" + "Create an ilibmanifest.json file out of the existing locale data.\n\n" + "-h or --help\n" + " this help\n" + "source_dir\n" + - ' Dir to scan. Default "."\n'); + ' Dir to scan. Default "."'); process.exit(1); } @@ -46,12 +46,12 @@ if (process.argv.length > 2) { fs.exists(sourcedir, function (exists) { if (!exists) { - util.print("Could not access directory " + sourcedir + "\n"); + console.log("Could not access directory " + sourcedir); usage(); } }); -util.print("source dir: " + sourcedir + "\n"); +console.log("source dir: " + sourcedir); var manifest = { files: [] @@ -77,9 +77,9 @@ walk(sourcedir, ""); try { var targetPath = path.join(sourcedir, "ilibmanifest.json"); - util.print("Writing " + targetPath + "\n"); + console.log("Writing " + targetPath); fs.writeFileSync(targetPath, JSON.stringify(manifest), 'utf8'); } catch (err) { - util.print("Could not write target manifest file: " + targetPath + "\n"); - util.print(err + "\n"); + console.log("Could not write target manifest file: " + targetPath); + console.log(err); } diff --git a/tools/build/mkstubs.js b/tools/build/mkstubs.js index 74d8c2308d..c9963d5ee6 100644 --- a/tools/build/mkstubs.js +++ b/tools/build/mkstubs.js @@ -1,7 +1,7 @@ /* * mkstubs.js - ilib tool to extract stubs for * - * Copyright © 2015, JEDLSoft + * Copyright © 2015, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,14 +26,14 @@ var common = require('../cldr/common'); var path = require('../../js/lib/Path.js'); function usage() { - util.print("Usage: mkstubs.js [-h] [assembled_source_file [output_file]]\n" + console.log("Usage: mkstubs.js [-h] [assembled_source_file [output_file]]\n" + "Create an dynamic-load stub file out of the existing assembled source file.\n\n" + "-h or --help\n" + " this help\n" + "assembled_source_file\n" + ' File to scan. Default: "ilib-dyn.js"\n' + "output_file\n" - + ' File to put output. Default: "ilib-stubs.js"\n'); + + ' File to put output. Default: "ilib-stubs.js"'); process.exit(1); } @@ -53,12 +53,12 @@ if (process.argv.length > 2) { } if (!fs.existsSync(sourcefile)) { - util.print("Could not access source file " + sourcefile + "\n"); + console.log("Could not access source file " + sourcefile); usage(); } -util.print("mkstubs - make a dynamic-load stubs file\n"); -util.print("source file: " + sourcefile + "\n"); +console.log("mkstubs - make a dynamic-load stubs file"); +console.log("source file: " + sourcefile); var legacyMapping = { "AddressFmt" : "ilib.AddressFmt", @@ -315,9 +315,9 @@ for (i = 0; i < lines.length; i++) { outputDyn += "module.exports = ilib;\n"; fs.writeFileSync(outputDynFile, outputDyn, "utf-8"); -util.print("Output written to " + outputDynFile + "\n"); +console.log("Output written to " + outputDynFile); output += "\n"; fs.writeFileSync(outputFile, output, "utf-8"); -util.print("Output written to " + outputFile + "\n"); +console.log("Output written to " + outputFile); diff --git a/tools/cldr/charmapfile.js b/tools/cldr/charmapfile.js index aa01753362..06d4c9b626 100644 --- a/tools/cldr/charmapfile.js +++ b/tools/cldr/charmapfile.js @@ -1,7 +1,7 @@ /* * charmapfile.js - read and parse a Linux charmap file * - * Copyright © 2014-2015, JEDLSoft + * Copyright © 2014-2015, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,11 +71,11 @@ exports.CharmapFile = function (options) { } if (!data) { - util.print("could not read data\n"); + console.log("could not read data"); return undefined; } - // util.print("read data\n"); + // console.log("read data"); var string = new String(data, "utf-8"); string = (string.charAt(string.length-1) === '\n') ? string.substring(0, string.length-1): string; @@ -117,12 +117,12 @@ exports.CharmapFile = function (options) { row = (commentStart === -1) ? rows[i] : rows[i].substring(0, commentStart); row = row.trim(); if (row.length > 0) { - // util.print("pushing row " + JSON.stringify(row.split(this.splitChar)) + "\n"); + // console.log("pushing row " + JSON.stringify(row.split(this.splitChar))); this.rows.push(row.split(this.splitChar)); } i++; } - util.print("found " + this.rows.length + " rows\n"); + console.log("found " + this.rows.length + " rows"); }; exports.CharmapFile.prototype = { diff --git a/tools/cldr/common.js b/tools/cldr/common.js index 71481d1783..3f8170c2b6 100644 --- a/tools/cldr/common.js +++ b/tools/cldr/common.js @@ -732,12 +732,12 @@ exports.mergeAndPrune = function mergeAndPrune(localeData) { localeData.merged = localeData.data; } for (var prop in localeData) { - // console.log("merging " + prop + "\n"); + // console.log("merging " + prop); if (prop && typeof(localeData[prop]) !== 'undefined' && prop !== 'data' && prop !== 'merged') { // console.log(prop + " "); localeData[prop].merged = exports.merge(localeData.merged || {}, localeData[prop].data || {}); localeData[prop].data = exports.prune(localeData.merged || {}, localeData[prop].data || {}); - // console.log("recursing\n"); + // console.log("recursing"); exports.mergeAndPrune(localeData[prop]); } } @@ -930,7 +930,7 @@ exports.Trie = function () { * @param {Object} to */ exports.Trie.prototype.add = function(from, to) { - //console.log("from length is " + from.length + "\n"); + //console.log("from length is " + from.length); var trienode = this.nodes; var dest = new TrieNode(to); @@ -938,7 +938,7 @@ exports.Trie.prototype.add = function(from, to) { switch (typeof(trienode[from[j]])) { case 'number': case 'string': - //console.log("existing leaf node " + from[j] + "\n"); + //console.log("existing leaf node " + from[j]); // context-sensitive? var temp = { "__leaf": trienode[from[j]] @@ -948,7 +948,7 @@ exports.Trie.prototype.add = function(from, to) { case 'object': if (trienode[from[j]] instanceof TrieNode) { - //console.log("existing leaf node " + from[j] + "\n"); + //console.log("existing leaf node " + from[j]); // context-sensitive? We have more to add, but // there is a leaf here already. Push it down as // a leaf and go on. @@ -960,7 +960,7 @@ exports.Trie.prototype.add = function(from, to) { break; case 'undefined': - //console.log("new node " + from[j] + "\n"); + //console.log("new node " + from[j]); trienode[from[j]] = {}; break; } @@ -968,13 +968,13 @@ exports.Trie.prototype.add = function(from, to) { trienode = trienode[from[j]]; } - //console.log("setting node " + from[j] + " to " + to + "\n"); + //console.log("setting node " + from[j] + " to " + to); if (!exports.isEmpty(trienode[from[j]])) { - //console.log("Add existing node leaf " + from[j] + "\n"); + //console.log("Add existing node leaf " + from[j]); // context-sensitive? trienode[from[j]].__leaf = dest; } else { - //console.log("Adding new node " + from[j] + "\n"); + //console.log("Adding new node " + from[j]); trienode[from[j]] = dest; } }; diff --git a/tools/cldr/datefmts.js b/tools/cldr/datefmts.js index 49b8b9f54d..7777173df4 100644 --- a/tools/cldr/datefmts.js +++ b/tools/cldr/datefmts.js @@ -179,7 +179,7 @@ function dateOrder(fmt) { } else if (stripped.match(/y.*d.*M/)) { return "ydm"; } else { - console.log("WARNING: unknown date order: " + fmt + "\n"); + console.log("WARNING: unknown date order: " + fmt); } } @@ -194,7 +194,7 @@ function dateOrder2(fmt) { } else if (stripped.match(/M.*d.*[Ec]/)) { return "mdw"; } else { - console.log("WARNING: unknown date order: " + fmt + "\n"); + console.log("WARNING: unknown date order: " + fmt); } } @@ -209,7 +209,7 @@ function timeOrder(fmt) { } else if (stripped.match(/h.*a/)) { return "haz"; } else { - console.log("WARNING: unknown time order: " + fmt + "\n"); + console.log("WARNING: unknown time order: " + fmt); } } @@ -373,8 +373,8 @@ module.exports = { addDateFormat(formats, locale, obj); } } catch (err) { - console.log("File " + sourcePath + " is not readable or does not contain valid JSON.\n"); - console.log(err + "\n"); + console.log("File " + sourcePath + " is not readable or does not contain valid JSON."); + console.log(err); process.exit(2); } } @@ -537,17 +537,17 @@ module.exports = { if (y["full"] !== y["long"]) { longPlus = longPlus.replace(y["long"], y["full"]); } - // console.log("Search for '" + longPlus + "' in '" + cldrFormats["full"] + "'\n"); + // console.log("Search for '" + longPlus + "' in '" + cldrFormats["full"] + "'"); var longIndex = cldrFormats["full"].indexOf(longPlus); if (longIndex > -1 && weekFormatIndex !== -1) { tmp = cldrFormats["full"].replace(longPlus, "{date}"); - // console.log("tmp is " + tmp + "\n"); + // console.log("tmp is " + tmp); wTemplate = tmp; } else { // didn't work. Next attempt: try searching for the w components and see if the dmy parts come before // or after it in the format. If it comes before, take after the the first "d", "M", or "y" as the "dmy" // part. If it comes after take everything up to the first "d", "M", or "y" as the "dmy" part. - // console.log("Not found. Trying positional method\n"); + // console.log("Not found. Trying positional method"); // strip out the quoted parts so we don't accidentally match the characters inside the quotes var full = cldrFormats["full"]; @@ -557,7 +557,7 @@ module.exports = { if (scanForLastChars(full, "E") < min) { wTemplate = full.substring(0, min) + "{date}"; longPlus = full.substring(min); - // console.log("language " + language + " E found before date. Using wtemplate " + wTemplate + "\n"); + // console.log("language " + language + " E found before date. Using wtemplate " + wTemplate); } else if (scanForChars(full, "E") > max) { // scan backwards to find the last dmy char var iterator = full.length-1; @@ -575,13 +575,13 @@ module.exports = { } wTemplate = "{date}" + full.substring(iterator+1); longPlus = full.substring(0, iterator+1); - // console.log("language " + language + " E found after date. Using wtemplate " + wTemplate + " and longPlus is " + longPlus + "\n"); + // console.log("language " + language + " E found after date. Using wtemplate " + wTemplate + " and longPlus is " + longPlus); //} else { // the w is in the middle of the dmy... not sure what to do about that! - // console.log("failed. Using fallback.\n"); + // console.log("failed. Using fallback."); } } - // console.log("wTemplate is " + wTemplate + "\n"); + // console.log("wTemplate is " + wTemplate); calendar.date.dmwy["f"] = rtlify(correctedYear(cldrFormats["full"])); calendar.date.dmy["f"] = rtlify(correctedYear(longPlus)); @@ -618,18 +618,18 @@ module.exports = { // the long format switch (orders[len]) { case "dmy": - // console.log("Length " + len + " order dmy\n"); + // console.log("Length " + len + " order dmy"); calendar.date.my[lenAbbr] = rtlify(dmy.substring(scanForChars(dmy, "M"))); calendar.date.dm[lenAbbr] = rtlify(dmy.substring(0, scanForLastChars(dmy, "M"))); break; case "mdy": - // console.log("Length " + len + " order mdy\n"); + // console.log("Length " + len + " order mdy"); calendar.date.my[lenAbbr] = rtlify(dmy.substring(0, scanForLastChars(dmy, "M")) + dmy.substring(scanForLastChars(dmy, "d"))); calendar.date.dm[lenAbbr] = rtlify(dmy.substring(0, scanForLastChars(dmy, "d"))); break; case "ymd": - // console.log("Length " + len + " order ymd\n"); + // console.log("Length " + len + " order ymd"); calendar.date.dm[lenAbbr] = rtlify(dmy.substring(scanForChars(dmy, "M"))); if (isAsianLang(language)) { var firstd = scanForChars(dmy, "d"); @@ -643,7 +643,7 @@ module.exports = { break; case "ydm": - // console.log("Length " + len + " order ydm\n"); + // console.log("Length " + len + " order ydm"); calendar.date.dm[lenAbbr] = rtlify(dmy.substring(scanForChars(dmy, "d"))); calendar.date.my[lenAbbr] = rtlify(dmy.substring(0, scanForChars(dmy, "d")) + dmy.substring(scanForChars(dmy, "M"))); @@ -670,20 +670,20 @@ module.exports = { switch (dateOrder2(dmw)) { case "dmw": - // console.log("Length " + len + " dw order dmw\n"); + // console.log("Length " + len + " dw order dmw"); calendar.date.dw[lenAbbr] = rtlify(dmw.substring(0, scanForChars(dmw, "M")) + dmw.substring(scanForChars(dmw, "Ec"))); break; case "wdm": - // console.log("Length " + len + " dw order wdm\n"); + // console.log("Length " + len + " dw order wdm"); calendar.date.dw[lenAbbr] = rtlify(dmw.substring(0, scanForLastChars(dmw, "d"))); break; case "mdw": - // console.log("Length " + len + " dw order mdw\n"); + // console.log("Length " + len + " dw order mdw"); calendar.date.dw[lenAbbr] = rtlify(dmw.substring(scanForChars(dmw, "d"))); break; case "wmd": - // console.log("Length " + len + " dw order wmd\n"); + // console.log("Length " + len + " dw order wmd"); calendar.date.dw[lenAbbr] = rtlify(dmw.substring(0, scanForChars(dmw, "M")) + dmw.substring(scanForChars(dmw, "d"))); break; @@ -707,7 +707,7 @@ module.exports = { var H, h; if (longtime.indexOf("H") > -1) { - // console.log("24-hour locale. Longtime: " + longtime + "\n"); + // console.log("24-hour locale. Longtime: " + longtime); calendar.time["24"]["h"] = strippedLongTime.replace(/[^H]/g, ""); calendar.time["24"]["m"] = strippedLongTime.replace(/[^m]/g, ""); calendar.time["24"]["s"] = strippedLongTime.replace(/[^s]/g, ""); @@ -789,7 +789,7 @@ module.exports = { calendar.time["12"]["ahmsz"] = rtlify(zTemplate.replace(/\{time\}/, aTemplate.replace(/\{time\}/, calendar.time["12"]["hms"]))); } else { - // console.log("12-hour locale. Longtime: " + longtime + "\n"); + // console.log("12-hour locale. Longtime: " + longtime); order = timeOrder(longtime); calendar.time["12"]["h"] = longtime.replace(/[^h]/g, ""); @@ -2045,7 +2045,7 @@ module.exports = { return; } - console.log("Promoting " + totals[0].name + "/" + filename + " to " + parentName + "\n"); + console.log("Promoting " + totals[0].name + "/" + filename + " to " + parentName); // promote a child as the new root, dropping the current root group.data = group[totals[0].name].data; }, diff --git a/tools/cldr/gencharmap.js b/tools/cldr/gencharmap.js index 10702cf834..7ba73f1dd8 100644 --- a/tools/cldr/gencharmap.js +++ b/tools/cldr/gencharmap.js @@ -2,7 +2,7 @@ * genccharmap.js - ilib tool to generate the charset mappings from the Unicode * data files * - * Copyright © 2014, JEDLSoft + * Copyright © 2014, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,16 +23,12 @@ */ var fs = require('fs'); -var util = require('util'); -var unifile = require('./unifile.js'); var common = require('./common.js'); var CharmapFile = require('./charmapfile.js').CharmapFile; var path = require('path'); -var charIterator = common.charIterator; -var isMember = common.isMember; function usage() { - util.print("Usage: gencharmap [-h] path_to_linux_charmaps path_to_UCD_mappings charsetaliases.json [toDir]\n" + + console.log("Usage: gencharmap [-h] path_to_linux_charmaps path_to_UCD_mappings charsetaliases.json [toDir]\n" + "Generate the character type data.\n\n" + "-h or --help\n" + " this help\n" + @@ -43,7 +39,7 @@ function usage() { "charsetaliases.json\n" + " path to json file with the mappings to standard IANA charset names\n" + "toDir\n" + - " directory to output the normalization json files. Default: /charmaps.\n"); + " directory to output the normalization json files. Default: /charmaps."); process.exit(1); } @@ -58,7 +54,7 @@ process.argv.forEach(function (val, index, array) { }); if (process.argv.length < 4) { - util.error('Error: not enough arguments'); + console.error('Error: not enough arguments'); usage(); } @@ -72,27 +68,27 @@ if (process.argv.length > 5) { toDir = path.join(toDir, "charmaps"); -util.print("gencharmap - generate charmap mapping data.\n" + +console.log("gencharmap - generate charmap mapping data.\n" + "Copyright (c) 2014 JEDLSoft\n"); if (!fs.existsSync(charmapDir)) { - util.error("Could not access dir " + charmapDir); + console.error("Could not access dir " + charmapDir); usage(); } if (!fs.existsSync(ucdDir)) { - util.error("Could not access UCD mappings dir " + ucdDir); + console.error("Could not access UCD mappings dir " + ucdDir); usage(); } if (!fs.existsSync(aliasesFile)) { - util.error("Could not access aliases file " + aliasesFile); + console.error("Could not access aliases file " + aliasesFile); usage(); } if (!fs.existsSync(toDir)) { if (!common.makeDirs(toDir)) { - util.error("Could not access target directory " + toDir); + console.error("Could not access target directory " + toDir); usage(); } } @@ -221,17 +217,17 @@ function walk(dir) { var list = fs.readdirSync(dir); list.forEach(function (file) { var fullpath = dir + '/' + file; - // util.print("fullpath is " + fullpath + "\n"); + // console.log("fullpath is " + fullpath); var stat = fs.statSync(fullpath); if (stat && stat.isDirectory()) { walk(fullpath); } else { //if (fullpath.match(/.gz$/)) { - util.print("found charmap file " + fullpath + "\n"); + console.log("found charmap file " + fullpath); try { var fileName = aliases[file.replace(/[-_:\+\.\(\)]/g, '').toUpperCase()] || file; var toFileName = path.join(toDir, fileName + ".json"); - // util.print("Writing results to file " + toFileName + "\n"); + // console.log("Writing results to file " + toFileName); var map = { to: new common.Trie(), from: new common.Trie() @@ -246,7 +242,7 @@ function walk(dir) { // 3 column mode = true var three = thirdColumnRE.test(uf.get(0)[2]); - // util.print("len is " + len + "\n"); + // console.log("len is " + len); for (var i = 0; i < len; i++) { row = uf.get(i); @@ -254,9 +250,9 @@ function walk(dir) { unicode = []; reversible = true; - //util.print("row is " + JSON.stringify(row) + "\n"); + //console.log("row is " + JSON.stringify(row)); if (three) { - //util.print("3 column mode\n"); + //console.log("3 column mode"); // 3 column mode var nativeByteStrings = row[1].split(/\/x/g); @@ -265,17 +261,17 @@ function walk(dir) { native.push(parseInt(nativeByteStrings[j], 16)); } } - //util.print("native is " + JSON.stringify(native) + "\n"); + //console.log("native is " + JSON.stringify(native)); if (native[0] === 0) { var symbolicName = row[0].substring(1, row[0].length-1); - //util.print("native is the PCS symbolic name " + symbolicName + "\n"); + //console.log("native is the PCS symbolic name " + symbolicName); if (typeof(portable_charset[symbolicName]) !== 'undefined') { native = [ portable_charset[symbolicName].charCodeAt(0) ]; - //util.print("maps to: " + native[native.length-1] + "\n"); + //console.log("maps to: " + native[native.length-1]); //} else { - //util.print("Unknown symbolic name: " + row[0] + "\n"); + //console.log("Unknown symbolic name: " + row[0]); } } @@ -293,9 +289,9 @@ function walk(dir) { } } } - //util.print("3 column unicode is " + JSON.stringify(unicode) + " and uniChars is " + JSON.stringify(uniChars) + "\n"); + //console.log("3 column unicode is " + JSON.stringify(unicode) + " and uniChars is " + JSON.stringify(uniChars)); } else { - //util.print("2 column mode\n"); + //console.log("2 column mode"); // two column mode var uniResult = firstColumnRE.exec(row[0]); if (uniResult !== null) { @@ -306,7 +302,7 @@ function walk(dir) { native.push(parseInt(nativeByteStrings[j], 16)); } } - //util.print("uniResult[2] is " + uniResult[2] + "\n"); + //console.log("uniResult[2] is " + uniResult[2]); var uniChars = uniResult[2].split(/ 0 && native[0] !== 0 && unicode && unicode.length > 0 && unicode[0] !== "\u0000") { @@ -349,12 +345,12 @@ function walk(dir) { map.from.add(unicode, native); } } else { - util.print("skipping bad mapping from " + row[0] + " to " + row[1] + "\n"); + console.log("skipping bad mapping from " + row[0] + " to " + row[1]); } //} else { - //util.print("row " + row + " did not pass the test\n"); - //util.print("uniRE.exec(row[0]) was " + JSON.stringify(uniRE.exec(row[0])) + "\n"); - //util.print("mapRE.test(row[1]) was " + mapRE.test(row[1]) + "\n"); + //console.log("row " + row + " did not pass the test"); + //console.log("uniRE.exec(row[0]) was " + JSON.stringify(uniRE.exec(row[0]))); + //console.log("mapRE.test(row[1]) was " + mapRE.test(row[1])); //} } @@ -365,14 +361,14 @@ function walk(dir) { }; if (fs.writeFileSync(toFileName, JSON.stringify(m, undefined, 4), "utf-8") < 0) { - util.print("Could not write to output file " + toFileName + "\n"); + console.log("Could not write to output file " + toFileName); } } else { - util.print("No data to write for charmap " + toFileName + ". Skipping...\n"); + console.log("No data to write for charmap " + toFileName + ". Skipping..."); } } catch (err) { - util.print("File " + fullpath + " is not readable or does not contain valid unicode mapping data.\n"); - util.print(err + "\n"); + console.log("File " + fullpath + " is not readable or does not contain valid unicode mapping data."); + console.log(err); } //} } @@ -383,18 +379,18 @@ function ucdWalk(dir) { var list = fs.readdirSync(dir); list.forEach(function (file) { var fullpath = dir + '/' + file; - // util.print("fullpath is " + fullpath + "\n"); + // console.log("fullpath is " + fullpath); var stat = fs.statSync(fullpath); if (stat && stat.isDirectory()) { ucdWalk(fullpath); } else { if (fullpath.match(/.TXT$/)) { - util.print("found charmap file " + fullpath + "\n"); + console.log("found charmap file " + fullpath); try { var baseName = file.replace(/.TXT$/, ''); var fileName = aliases[baseName.replace(/[-_,:\+\.\(\)]/g, '').toUpperCase()] || baseName; var toFileName = path.join(toDir, fileName + ".json"); - util.print("Output file is " + toFileName + "\n"); + console.log("Output file is " + toFileName); // don't override files written out by the other walker if (!fs.existsSync(toFileName)) { @@ -423,14 +419,14 @@ function ucdWalk(dir) { // three column file nativeColumn = 1; unicodeColumn = 2; - util.print("3 column mode\n"); + console.log("3 column mode"); } } } columnRE.lastIndex = 0; - // util.print("len is " + len + "\n"); + // console.log("len is " + len); for (var i = 0; i < len; i++) { row = uf.get(i); @@ -451,13 +447,13 @@ function ucdWalk(dir) { native.push(bytes[j]); } - // util.print("native is " + JSON.stringify(native) + "\n"); + // console.log("native is " + JSON.stringify(native)); var uniResult; columnRE.lastIndex = 0; - // util.print("row[nativeColumn] is " + row[nativeColumn] + " and columnRE.exec is " + columnRE.exec(row[unicodeColumn]) + "\n"); + // console.log("row[nativeColumn] is " + row[nativeColumn] + " and columnRE.exec is " + columnRE.exec(row[unicodeColumn])); while ((uniResult = columnRE.exec(row[unicodeColumn])) !== null) { - // util.print("found uni char " + uniResult[0] + "\n"); + // console.log("found uni char " + uniResult[0]); var u = parseInt(uniResult[0], 16); var uniStr = common.codePointToUTF16(u); // push each surrogate separately so that we can @@ -468,22 +464,22 @@ function ucdWalk(dir) { } } - // util.print("unicode is " + JSON.stringify(unicode) + "\n"); + // console.log("unicode is " + JSON.stringify(unicode)); } /* if (native.length <= 0) { - util.print("native length\n"); + console.log("native length"); } if (native[0] === 0) { - util.print("native null\n"); + console.log("native null"); } if (!unicode) { - util.print("not unicode\n"); + console.log("not unicode"); } else if (unicode.length <= 0) { - util.print("unicode zero length\n"); + console.log("unicode zero length"); } else if (unicode[0] === '\u0000') { - util.print("unicode zero first char. Array is: " + JSON.stringify(unicode) + "\n"); + console.log("unicode zero first char. Array is: " + JSON.stringify(unicode)); } */ if (native.length > 0 && native[0] !== 0 && @@ -492,12 +488,12 @@ function ucdWalk(dir) { map.to.add(native, unicode); map.from.add(unicode, native); } else { - util.print("skipping bad mapping from " + row[nativeColumn] + " to " + row[unicodeColumn] + "\n"); + console.log("skipping bad mapping from " + row[nativeColumn] + " to " + row[unicodeColumn]); } //} else { - //util.print("row " + row + " did not pass the test\n"); - //util.print("uniRE.exec(row[nativeColumn]) was " + JSON.stringify(uniRE.exec(row[nativeColumn])) + "\n"); - //util.print("mapRE.test(row[unicodeColumn]) was " + mapRE.test(row[unicodeColumn]) + "\n"); + //console.log("row " + row + " did not pass the test"); + //console.log("uniRE.exec(row[nativeColumn]) was " + JSON.stringify(uniRE.exec(row[nativeColumn]))); + //console.log("mapRE.test(row[unicodeColumn]) was " + mapRE.test(row[unicodeColumn])); //} } @@ -508,17 +504,17 @@ function ucdWalk(dir) { }; if (fs.writeFileSync(toFileName, JSON.stringify(m, undefined, 4), "utf-8") < 0) { - util.print("Could not write to output file " + toFileName + "\n"); + console.log("Could not write to output file " + toFileName); } } else { - util.print("No data to write for charmap " + toFileName + ". Skipping...\n"); + console.log("No data to write for charmap " + toFileName + ". Skipping..."); } } else { - util.print("Output file " + toFileName + " already exists. Will not overwrite.\n"); + console.log("Output file " + toFileName + " already exists. Will not overwrite."); } } catch (err) { - util.print("File " + fullpath + " is not readable or does not contain valid unicode mapping data.\n"); - util.print(err + "\n"); + console.log("File " + fullpath + " is not readable or does not contain valid unicode mapping data."); + console.log(err); } } } diff --git a/tools/cldr/genclockprefs.js b/tools/cldr/genclockprefs.js index f0293151d1..384d37dd3e 100644 --- a/tools/cldr/genclockprefs.js +++ b/tools/cldr/genclockprefs.js @@ -2,7 +2,7 @@ * genclockprefs.js - ilib tool to generate the clock json fragments from * the CLDR data files * - * Copyright © 2013-2018, LGE + * Copyright © 2013-2018, 2020 LGE * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ function usage() { "-h or --help\n" + " this help\n" + "locale_data_dir\n" + - " the top level of the ilib locale data directory\n"); + " the top level of the ilib locale data directory"); process.exit(1); } var cldrDirName; @@ -64,7 +64,7 @@ function loadFile(pathname) { if (fs.existsSync(pathname)) { var json = fs.readFileSync(pathname, "utf-8"); ret = JSON.parse(json); - //console.log("pathname is :"+pathname+"\n");# + //console.log("pathname is :"+pathname);# } return ret; } @@ -139,12 +139,12 @@ function anyProperties(data) { function writeClockPrefs(language, script, region, data) { var pathname = calcLocalePath(language, script, region, ""); - //console.log("data to be written into jf files" + pathname + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"+JSON.stringify(data)+"\n"); + //console.log("data to be written into jf files" + pathname + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"+JSON.stringify(data)); if (data.generated) { if (anyProperties(data)) { console.log("Writing " + pathname); makeDirs(pathname); - //console.log("data to be written into jf files" + pathname + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"+JSON.stringify(data["clock"])+"\n");# + //console.log("data to be written into jf files" + pathname + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"+JSON.stringifyta["clock"]));# if (typeof (data["clock"]) != 'undefined') { data.generated = true; makeDirs(pathname); @@ -180,8 +180,8 @@ function getClockPrefs(locale) { } else { console.log("could not find default clock preference for locale " + locale); } - //console.log("time format is :"+JSON.stringify(timeformat)+"\n"); - //console.log("clock preference is :"+JSON.stringify(clockprefs)+"\n"); + //console.log("time format is :"+JSON.stringify(timeformat)); + //console.log("clock preference is :"+JSON.stringify(clockprefs)); return clockprefs; } diff --git a/tools/cldr/gencoll.js b/tools/cldr/gencoll.js index b24924c496..5d7e2ac189 100644 --- a/tools/cldr/gencoll.js +++ b/tools/cldr/gencoll.js @@ -2,7 +2,7 @@ * gencoll.js - ilib tool to generate the json UCA data from the Unicode * data files * - * Copyright © 2014, JEDLSoft + * Copyright © 2014, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ */ var fs = require('fs'); -var util = require('util'); var path = require('path'); var uniData = require('./uniData.js'); var unifile = require('./unifile.js'); @@ -44,7 +43,7 @@ var coelesce = common.coelesce; var hexStringUTF16String = common.hexStringUTF16String; function usage() { - util.print("Usage: gencoll [-h] ISO-15924-file.txt UCD-dir CLDR-dir [toDir]\n" + + console.log("Usage: gencoll [-h] ISO-15924-file.txt UCD-dir CLDR-dir [toDir]\n" + "Generate the collation data.\n\n" + "-h or --help\n" + " this help\n" + @@ -55,7 +54,7 @@ function usage() { "CLDR-dir\n" + " path to the json CLDR files downloaded from the Unicode site\n" + "toDir\n" + - " directory to output the normalization json files. Default: current dir.\n"); + " directory to output the normalization json files. Default: current dir."); process.exit(1); } @@ -74,7 +73,7 @@ process.argv.forEach(function (val, index, array) { }); if (process.argv.length < 4) { - util.error('Error: not enough arguments'); + console.error('Error: not enough arguments'); usage(); } @@ -85,31 +84,31 @@ if (process.argv.length > 5) { toDir = process.argv[5]; } -util.print("gencoll - generate collation data.\n" + +console.log("gencoll - generate collation data.\n" + "Copyright (c) 2014 JEDLSoft\n"); fs.exists(iso15924FileName, function (exists) { if (!exists) { - util.error("Could not access file " + iso15924FileName); + console.error("Could not access file " + iso15924FileName); usage(); } }); fs.exists(ucdDir, function (exists) { if (!exists) { - util.error("Could not access UCD directory " + ucdDir); + console.error("Could not access UCD directory " + ucdDir); usage(); } }); fs.exists(cldrDir, function (exists) { if (!exists) { - util.error("Could not access CLDR directory " + cldrDir); + console.error("Could not access CLDR directory " + cldrDir); usage(); } }); fs.exists(toDir, function (exists) { if (!exists) { - util.error("Could not access target directory " + toDir); + console.error("Could not access target directory " + toDir); usage(); } }); @@ -118,7 +117,7 @@ scriptFileName = ucdDir + "/Scripts.txt"; fs.exists(scriptFileName, function (exists) { if (!exists) { - util.error("Could not access file " + scriptFileName); + console.error("Could not access file " + scriptFileName); usage(); } }); @@ -127,7 +126,7 @@ ducetFileName = cldrDir + "/common/uca/allkeys_DUCET.txt"; fs.exists(ducetFileName, function (exists) { if (!exists) { - util.error("Could not access file " + ducetFileName); + console.error("Could not access file " + ducetFileName); usage(); } }); @@ -150,7 +149,7 @@ for (var i = 0; i < len; i++ ) { if (longCode.length > 0) { fullToShortMap[longCode.toLowerCase()] = code; - // util.print("Mapping " + longCode.toLowerCase() + " to " + code + "\n"); + // console.log("Mapping " + longCode.toLowerCase() + " to " + code); } } @@ -169,10 +168,10 @@ for (var i = 0; i < scriptsFile.length(); i++) { if (rangeEnd && rangeEnd.length > 0) { rangeEnd = parseInt(rangeEnd[0].substring(2), 16); ranges.push([rangeStart, rangeEnd, scriptName]); - // util.print("pushing range [" + rangeStart + "," + rangeEnd + "," + scriptName + "]\n"); + // console.log("pushing range [" + rangeStart + "," + rangeEnd + "," + scriptName + "]"); } else { ranges.push([rangeStart, rangeStart, scriptName]); - // util.print("pushing range [" + rangeStart + "," + rangeStart + "," + scriptName + "]\n"); + // console.log("pushing range [" + rangeStart + "," + rangeStart + "," + scriptName + "]"); } } @@ -184,8 +183,8 @@ ranges.sort(compareByStart); // rangeToScript = coelesce(ranges, 0); rangeToScript = ranges; -// util.print("Sorted and coelesced ranges are:\n"); -// util.print(JSON.stringify(rangeToScript)); +// console.log("Sorted and coelesced ranges are:"); +// console.log(JSON.stringify(rangeToScript)); /** * Create a new weight vector instance. @@ -273,22 +272,22 @@ WeightVector.prototype = { }; function parseWeightLine(weightLine) { - //util.print("parsing weight line: " + weightLine + "\n"); + //console.log("parsing weight line: " + weightLine); var chars = weightLine.trim().split(/\]\[/g); var weights = []; - //util.print("chars is: " + JSON.stringify(chars) + "\n"); + //console.log("chars is: " + JSON.stringify(chars)); for (var j = 0; j < chars.length; j++) { var str = chars[j].trim(); if (str.length > 0) { weights.push(new WeightVector(str)); } } - //util.print("weights: " + JSON.stringify(weights) + "\n"); + //console.log("weights: " + JSON.stringify(weights)); return weights; } -util.print("Reading DUCET code points and weights\n"); +console.log("Reading DUCET code points and weights"); var ducet = {}; @@ -305,7 +304,7 @@ for (var i = 0; i < len; i++ ) { }; } -util.print("Attaching script codes to DUCET code points\n"); +console.log("Attaching script codes to DUCET code points"); var elementsByScript = {}; var range; @@ -322,11 +321,11 @@ for (var name in ducet) { // about expansions or contractions, because the first char gives the script anyways ch = common.UTF16ToCodePoint(name); - // util.print("Checking char " + ch + ": "); + // console.log("Checking char " + ch + ": "); range = common.findMember(rangeToScript, ch); if (typeof(range) !== 'undefined' && range !== -1) { scriptName = rangeToScript[range][2]; - // util.print(scriptName); + // console.log(scriptName); if (typeof(elementsByScript[scriptName]) === 'undefined') { elementsByScript[scriptName] = []; } @@ -341,7 +340,7 @@ for (var name in ducet) { } } } - //util.print("\n"); + //console.log(""); ducet[name].script = scriptName; } } @@ -358,7 +357,7 @@ function compareByWeights(left, right) { // elements.sort(compareByWeights); -util.print("Ducet table for " + scriptName + " is: " + JSON.stringify(elements) + "\n"); +console.log("Ducet table for " + scriptName + " is: " + JSON.stringify(elements)); var i = 0; var lastChar; @@ -375,14 +374,14 @@ for (i = 0; i < elements.length; i++) { if (ch && ch.length > 0) { var row = ducet[ch]; if (!row) { - util.print("Not sure how this happened, but there is a char not in the ducet: " + ch + "\n"); + console.log("Not sure how this happened, but there is a char not in the ducet: " + ch); } else { if (lastChar) { - util.print("comparing " + JSON.stringify(lastChar) + " and " + JSON.stringify(row.weights[0]) + "\n"); + console.log("comparing " + JSON.stringify(lastChar) + " and " + JSON.stringify(row.weights[0])); var diff = lastChar.compare(row.weights[0]); - util.print(operators[diff] + " " + ch + "\n"); + console.log(operators[diff] + " " + ch); } else { - util.print(ch + "\n"); + console.log(ch); } lastChar = row.weights[0]; } @@ -391,13 +390,13 @@ for (i = 0; i < elements.length; i++) { process.exit(0); -util.print("Ducet table is: \n"); +console.log("Ducet table is: "); var i = 0; for (ch in ducet) { if (ch && ch.length > 0) { var row = ducet[ch]; - util.print(i + ": " + ch + " " + JSON.stringify(row) + "\n"); + console.log(i + ": " + ch + " " + JSON.stringify(row)); i++; } } @@ -415,7 +414,7 @@ function compareWeightArray(left, right) { return 0; } -/* util.print("Ducet table for Hani is: " + JSON.stringify(elementsByScript["Hani"]) + "\n"); +/* console.log("Ducet table for Hani is: " + JSON.stringify(elementsByScript["Hani"])); var hani = elementsByScript["Hani"]; var previousRow; for (var i = 0; i < hani.length; i++) { @@ -432,7 +431,7 @@ for (var i = 0; i < hani.length; i++) { // first get ducet data -//util.print("Ducet table for Hani is: " + JSON.stringify(elementsByScript["Hani"]) + "\n"); +//console.log("Ducet table for Hani is: " + JSON.stringify(elementsByScript["Hani"])); var collPinyin = []; var hani = elementsByScript["Hani"]; var previousRow; @@ -456,7 +455,7 @@ for (var i = 0; i < hani.length; i++) { follows: [] }); - // util.print("DUCET char " + ch + " has " + thisElement + "\n"); + // console.log("DUCET char " + ch + " has " + thisElement); } lastElement = thisElement; previousRow = row; @@ -482,7 +481,7 @@ var collPinyinName = collationsDir + "zh/coll.pinyin.txt"; fs.exists(collPinyinName, function (exists) { if (!exists) { - util.error("Could not access file " + collPinyinName); + console.error("Could not access file " + collPinyinName); usage(); } }); @@ -525,7 +524,7 @@ while (i < data.length) { mode = "separate"; i++; } - util.print("found op level " + op + "\n"); + console.log("found op level " + op); } else if (ch === '#') { // skip comments while (i < data.length && data.charAt(i) !== '\n') { @@ -542,21 +541,21 @@ while (i < data.length) { } ch = data.charAt(++i); } - util.print("Searching for string " + value + "\n"); + console.log("Searching for string " + value); for (var j = 0; j < collPinyin.length; j++) { if (collPinyin[j].char === value.charAt(0)) { current = j; - util.print("Found reference to string " + value + " at position " + j + "\n"); + console.log("Found reference to string " + value + " at position " + j); } } } else { var f = collPinyin[current].follows; if (f.length > 0) { - util.print("Adding collation element " + ch + " at position " + current + "[" + (f.length-1) + "] level " + op + "\n"); + console.log("Adding collation element " + ch + " at position " + current + "[" + (f.length-1) + "] level " + op); vector = f[f.length-1].weights.clone(); } else { - util.print("Adding collation element " + ch + " at position " + (current+1) + " level " + op + "\n"); + console.log("Adding collation element " + ch + " at position " + (current+1) + " level " + op); vector = collPinyin[current].weights.clone(); } @@ -572,17 +571,17 @@ while (i < data.length) { } } -util.print("Pinyin collation is: \n"); +console.log("Pinyin collation is: "); var collation = {}; for (var i = 0; i < collPinyin.length; i++) { element = collPinyin[i]; - util.print('"' + element.char + '": ' + element.weights.toString() + "\n"); + console.log('"' + element.char + '": ' + element.weights.toString()); collation[element.char] = element.weights; var follows = element.follows; for (var j = 0; j < follows.length; j++) { - util.print(' "' + follows[j].char + '": ' + follows[j].weights.toString() + "\n"); + console.log(' "' + follows[j].char + '": ' + follows[j].weights.toString()); collation[follows[j].char] = follows[j].weights; } } @@ -590,7 +589,7 @@ for (var i = 0; i < collPinyin.length; i++) { var outputFileName = path.join(toDir, "collation.json"); fs.writeFileSync(outputFileName, JSON.stringify(collation, undefined, 4), "utf-8"); -util.print("Output written to " + outputFileName + ".\nDone\n"); +console.log("Output written to " + outputFileName + ".\nDone"); /* å [1,0,0] diff --git a/tools/cldr/gencountrynames.js b/tools/cldr/gencountrynames.js index f45068d015..fdb38ec910 100644 --- a/tools/cldr/gencountrynames.js +++ b/tools/cldr/gencountrynames.js @@ -2,7 +2,7 @@ * gencountrynames.js - ilib tool to generate the ctrynames.json files from * the CLDR data files * - * Copyright © 2013-2018, JEDLSoft + * Copyright © 2013-2018, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ function usage() { "CLDR_xml_dir\n" + " the top level of the Unicode CLDR distribution in xml format\n" + "locale_data_dir\n" + - " the top level of the ilib locale data directory\n"); + " the top level of the ilib locale data directory"); process.exit(1); } @@ -116,7 +116,7 @@ function getCountryNames(localeData, pathname, locale) { if (!destdata || typeof(destdata.generated) === 'undefined' || destdata.generated !== false) { destdata = {}; } else { - console.log("Merging into existing by-hand file\n"); + console.log("Merging into existing by-hand file"); } if (script) { @@ -419,12 +419,12 @@ function mergeAndSortRegions(localeData) { localeData.merged = localeData.data; } for (var prop in localeData) { - // util.print("merging " + prop + "\n"); + // console.log("merging " + prop); if (prop && typeof(localeData[prop]) !== 'undefined' && prop !== 'data' && prop !== 'merged') { - // util.print(prop + " "); + // console.log(prop + " "); localeData[prop].merged = mergeRegions(localeData.merged || {}, localeData[prop].data || {}); localeData[prop].data = sortRegions(localeData[prop].merged); - // util.print("recursing\n"); + // console.log("recursing"); mergeAndSortRegions(localeData[prop]); } } @@ -460,9 +460,9 @@ function sortCountries(localeData, locale) { } for (var prop in localeData) { - // util.print("merging " + prop + "\n"); + // console.log("merging " + prop); if (prop && typeof(localeData[prop]) !== 'undefined' && prop !== 'data' && prop !== 'merged') { - // util.print(prop + " "); + // console.log(prop + " "); sortCountries(localeData[prop], (locale !== "root") ? locale + '-' + prop : prop); } } @@ -476,12 +476,12 @@ function mergeCountries(localeData) { localeData.merged = localeData.data; } for (var prop in localeData) { - // util.print("merging " + prop + "\n"); + // console.log("merging " + prop); if (prop && typeof(localeData[prop]) !== 'undefined' && prop !== 'data' && prop !== 'merged') { - // util.print(prop + " "); + // console.log(prop + " "); localeData[prop].merged = mergeByValue(localeData.merged || {}, localeData[prop].data || {}); localeData[prop].data = localeData[prop].merged; - // util.print("recursing\n"); + // console.log("recursing"); mergeCountries(localeData[prop]); } } diff --git a/tools/cldr/genctype.js b/tools/cldr/genctype.js index 1e7c4a0cfe..be4e02bdf1 100644 --- a/tools/cldr/genctype.js +++ b/tools/cldr/genctype.js @@ -41,7 +41,7 @@ function usage() { "UCD_dir\n" + " path to the Unicode Character Database files \n" + "toDir\n" + - " directory to output the normalization json files. Default: current dir.\n"); + " directory to output the normalization json files. Default: current dir."); process.exit(1); } @@ -72,7 +72,7 @@ if (process.argv.length > 3) { } console.log("genctype - generate ctype data.\n" + - "Copyright (c) 2012 - 2015, 2018 JEDLSoft\n"); + "Copyright (c) 2012 - 2015, 2018 JEDLSoft"); if (!fs.existsSync(unicodeFileName)) { console.error("Could not access file " + unicodeFileName); diff --git a/tools/cldr/gencurrencies.js b/tools/cldr/gencurrencies.js index a90753cc8d..66514aa69b 100644 --- a/tools/cldr/gencurrencies.js +++ b/tools/cldr/gencurrencies.js @@ -38,7 +38,7 @@ function usage() { "iLibDataDir\n" + " Current ilib locale directory in order to refer the current currency info.\n" + "toDir\n" + - " directory to output the currency.jf json files. Default: current dir.\n"); + " directory to output the currency.jf json files. Default: current dir."); process.exit(1); } @@ -119,8 +119,8 @@ if (process.argv.length > 3) { toDir = process.argv[3]; } -console.log("gencurrency - generate currency information files.\n" + "Copyright © 2016, 2018-2020, JEDLSoft\n"); -console.log("output dir: " + toDir + "\n"); +console.log("gencurrency - generate currency information files.\n" + "Copyright © 2016, 2018-2020, JEDLSoft"); +console.log("output dir: " + toDir); var ilibDataFileName = path.join(ilibDir, "currency.json"); diff --git a/tools/cldr/gendatefmts.js b/tools/cldr/gendatefmts.js index 2fd6b32ebb..74fcb68312 100644 --- a/tools/cldr/gendatefmts.js +++ b/tools/cldr/gendatefmts.js @@ -1,2017 +1,2016 @@ -/* - * gendatefmts.js - ilib tool to generate the dateformats.json files and the date json fragments from - * the CLDR data files - * - * Copyright © 2013, JEDLSoft - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * This code is intended to be run under node.js - */ -var fs = require('fs'); -var util = require('util'); -var common = require('./common'); -var merge = common.merge; -var Locale = common.Locale; -var mergeAndPrune = common.mergeAndPrune; -var makeDirs = common.makeDirs; - -function usage() { - util.print("Usage: gendatefmts [-h] CLDR_json_dir locale_data_dir\n" + - "Generate date formats information files.\n" + - "-h or --help\n" + - " this help\n" + - "CLDR_json_dir\n" + - " the top level of the Unicode CLDR distribution in json format\n" + - "locale_data_dir\n" + - " the top level of the ilib locale data directory\n"); - process.exit(1); -} -var cldrDirName; -var localeDirName; -process.argv.forEach(function (val, index, array) { - if (val === "-h" || val === "--help") { - usage(); - } -}); -if (process.argv.length < 4) { - util.error('Error: not enough arguments'); - usage(); -} -cldrDirName = process.argv[2]; -localeDirName = process.argv[3]; -util.print("gendatefmts - generate date and time formats information files.\n" + - "Copyright (c) 2013 JEDLSoft\n"); -util.print("CLDR dir: " + cldrDirName + "\n"); -util.print("locale dir: " + localeDirName + "\n"); -fs.exists(cldrDirName, function (exists) { - if (!exists) { - util.error("Could not access CLDR dir " + cldrDirName); - usage(); - } -}); -fs.exists(localeDirName, function (exists) { - if (!exists) { - util.error("Could not access locale data directory " + localeDirName); - usage(); - } -}); -var filename, root, json, suppData, languageData, scripts = {}; -try { - filename = cldrDirName + "/main/en.json"; - json = fs.readFileSync(filename, "utf-8"); - root = JSON.parse(json); - filename = cldrDirName + "/supplemental/supplementalData.json"; - json = fs.readFileSync(filename, "utf-8"); - suppData = JSON.parse(json); - languageData = suppData.languageData; -} catch (e) { - util.print("Error: Could not load file " + filename + "\n"); - process.exit(2); -} -// get the information about scripts if necessary -for (var locale in languageData) { - if (locale && languageData[locale]) { - - //util.print("languageData[locale][@scripts] === " + JSON.stringify(languageData[locale]["@scripts"]) + "\n"); - if (typeof (languageData[locale]["@scripts"]) === 'string') { - var language = (locale.length <= 3) ? locale : locale.split(/-/)[0]; - - if (typeof (scripts[language]) === 'undefined') { - scripts[language] = []; - } - - var newLangs = languageData[locale]["@scripts"].split(/ /g); - if (locale.length <= 3) { - // util.print("language " + language + " prepending " + JSON.stringify(newLangs)); - scripts[language] = newLangs.concat(scripts[language]); - - } else { - // util.print("language " + language + " appending " + JSON.stringify(newLangs)); - scripts[language] = scripts[language].concat(newLangs); - } - - } - } -} - -function loadFile(path) { - var ret = undefined; - if (fs.existsSync(path)) { - json = fs.readFileSync(path, "utf-8"); - ret = JSON.parse(json); - } - return ret; -} - -function calcLocalePath(language, script, region, filename) { - var path = localeDirName + "/"; - if (language) { - path += language + "/"; - } - if (script) { - path += script + "/"; - } - if (region) { - path += region + "/"; - } - path += filename; - return path; -} - -function calcLocalePath(language, script, region, filename) { - var path = localeDirName + "/"; - if (language) { - path += language + "/"; - } - if (script) { - path += script + "/"; - } - if (region) { - path += region + "/"; - } - path += filename; - return path; -} - -function checkifHandwritten(language, script, region, filename) { - - if (language) { - if (language == 'en') { - return false; - } - if (script && region) { - - var file = localeDirName + "/" + language + "/" + script + "/" + filename; - var obj = loadFile(file); - - if (typeof (obj) !== 'undefined') { - if (typeof (obj.generated) === 'undefined' || obj.generated === false) { - return false; - } - } else { - file = localeDirName + "/" + language + "/" + filename; - - obj = loadFile(file); - - if (typeof (obj) !== 'undefined') { - - if (typeof (obj.generated) === 'undefined' || obj.generated === false) { - - return false; - } - } - - } - } else { - if (script || region) { - - file = localeDirName + "/" + language + "/" + filename; - - obj = loadFile(file); - if (typeof (obj) !== 'undefined') { - if (typeof (obj.generated) === 'undefined' || obj.generated === false) { - return false; - } - } - } - } - - } - return true; -} - -function loadFileNonGenerated(language, script, region, filename) { - var path = calcLocalePath(language, script, region, filename); - var obj = loadFile(path); - var flag; - if (typeof (language) != 'undefined') { - - flag = checkifHandwritten(language, script, region, filename); - - } - - if (typeof (obj) !== 'undefined' && (typeof (obj.generated) === 'undefined' || obj.generated === false)) { - // only return non-generated files - return obj; - } - - // else if (typeof (obj) !== 'undefined' && obj.generated) { - // if (typeof (obj) !== 'undefined') { - //var flag= checkifHandwritten(language, script, region, filename) ; - //if (typeof (obj) !== 'undefined') { - if (typeof (flag) == 'undefined' || flag == false) { - var obj = {}; - obj.generated = false; - return obj; - } - //} - //} - return undefined; -} -var localeData = {}; - -function getLocaleData(path, language, script, region) { - var data; - try { - filename = cldrDirName + "/main/" + path; - data = loadFile(filename); - util.print(language + " "); - if (script) { - if (region) { - if (!localeData[language]) { - localeData[language] = {}; - } - if (!localeData[language][script]) { - localeData[language][script] = {}; - } - if (!localeData[language][script][region]) { - localeData[language][script][region] = {}; - } - localeData[language][script][region].data = data; - } - } else if (region) { - if (!localeData[language]) { - localeData[language] = {}; - } - if (!localeData[language][region]) { - localeData[language][region] = {}; - } - localeData[language][region].data = data; - } else if (language) { - if (!localeData[language]) { - localeData[language] = {}; - } - localeData[language].data = data; - } else { - // root locale - localeData.data = data; - } - } catch (e) { - return undefined; - } - return data; -} - -function getMergedData(language, script, region) { - var ret = localeData.data; // root - if (language) { - ret = merge(ret, localeData[language].data); - if (script) { - ret = merge(ret, localeData[language][script].data); - if (region) { - ret = merge(ret, localeData[language][script][region].data); - } - } else if (region) { - ret = merge(ret, localeData[language][region].data); - } - } - return ret; -} - -function getDefaultScript(language) { - return scripts[language] ? scripts[language][0] : undefined; -} - -function initialCap(str) { - return str.charAt(0).toUpperCase() + str.substring(1); -} - -function initialLower(str) { - return str.charAt(0).toLowerCase() + str.substring(1); -} - -function leaveSame(str) { - return str; -} - -function getSystemResources(language, script, region, data) { - // if it is already there and non-generated, return it - //util.print("language is " + language + "\n"); - var sysres = loadFileNonGenerated(language, script, region, "sysres.json"); - if (sysres && !sysres.generated) { - util.print("\nLoaded existing resources from " + calcLocalePath(language, script, region, "sysres.json") + "\n"); - sysres.generated = false; - return sysres; - } - // else generate a new one - sysres = { - generated: true - }; - // from https://meta.wikimedia.org/wiki/Capitalization_of_Wiktionary_pages#Capitalization_of_month_names - var capitalizedMonthLocales = { - "af": 1, - "br": 1, - "cy": 1, - "el": 1, - "en": 1, - "de": 1, - "bar": 1, - "gsw": 1, - "ksh": 1, - "lb": 1, - "nds": 1, - "pfl": 1, - "hz": 1, - "id": 1, - "la": 1, - "ms": 1, - "pt": 1, - "ve": 1, - "xh": 1, - "zu": 1, - }; - var lowercasedMonthLocales = { - "bs": 1, - "bg": 1, - "hr": 1, - "ca": 1, - "cs": 1, - "da": 1, - "dsb": 1, - "eo": 1, - "es": 1, - "et": 1, - "fi": 1, - "fr": 1, - "hr": 1, - "hsb": 1, - "hu": 1, - "hy": 1, - "is": 1, - "it": 1, - "li": 1, - "lv": 1, - "lt": 1, - "mk": 1, - "no": 1, - "nn": 1, - "nl": 1, - "pl": 1, - "BR": 1, - "ro": 1, - "ru": 1, - "os": 1, - "sr": 1, - "sk": 1, - "sl": 1, - "sv": 1, - "tr": 1, - "uk": 1, - "vi": 1, - "wa": 1 - }; - var str = ""; - var parent = typeof (data.dates.calendars.gregorian.months.format) === 'undefined' ? - data.dates.calendars.gregorian.months.standalone : - data.dates.calendars.gregorian.months.format; - var capFunction = (typeof (lowercasedMonthLocales[language]) !== 'undefined' || typeof (lowercasedMonthLocales[region]) !== 'undefined') ? initialLower : - (typeof (capitalizedMonthLocales[language]) !== 'undefined' ? initialCap : leaveSame); - table = parent.narrow; - for (var i = 1; i < 13; i++) { - sysres["N" + i] = str; - } - table = parent.abbreviated; - for (var i = 1; i < 13; i++) { - sysres["NN" + i] = capFunction(table[i].substring(0, 2)); - } - for (var i = 1; i < 13; i++) { - sysres["MMM" + i] = capFunction(table[i]); - } - table = parent.wide; - for (var i = 1; i < 13; i++) { - sysres["MMMM" + i] = capFunction(table[i]); - } - // from https://meta.wikimedia.org/wiki/Capitalization_of_Wiktionary_pages#Capitalization_of_month_names - var capitalizedDayLocales = { - "af": 1, - "br": 1, - "cy": 1, - "en": 1, - "de": 1, - "bar": 1, - "gsw": 1, - "ksh": 1, - "lb": 1, - "nds": 1, - "pfl": 1, - "el": 1, - "hz": 1, - "id": 1, - "la": 1, - "ve": 1, - "xh": 1, - "zu": 1, - }; - var lowercasedDayLocales = { - "bs": 1, - "bg": 1, - "hr": 1, - "ca": 1, - "cs": 1, - "dsb": 1, - "eo": 1, - "fi": 1, - "fr": 1, - "hsb": 1, - "hu": 1, - "hy": 1, - "it": 1, - "li": 1, - "lv": 1, - "lt": 1, - "mk": 1, - "no": 1, - "nn": 1, - "nl": 1, - "os": 1, - "pl": 1, - "pt": 1, - "ro": 1, - "ru": 1, - "sr": 1, - "sk": 1, - "sv": 1, - "vi": 1, - "wa": 1 - }; - var dayProperties = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]; - var parent = typeof (data.dates.calendars.gregorian.days.format) === 'undefined' ? - data.dates.calendars.gregorian.days.standalone : - data.dates.calendars.gregorian.days.format; - capFunction = (typeof (capitalizedDayLocales[language]) !== 'undefined') ? initialCap : - (typeof (lowercasedDayLocales[language]) !== 'undefined') ? initialLower : - leaveSame; - table = parent.narrow; - for (var i = 0; i < 7; i++) { - sysres["E" + i] = table[dayProperties[i]]; - } - table = parent.short; - for (var i = 0; i < 7; i++) { - sysres["EE" + i] = capFunction(table[dayProperties[i]].substring(0, 2)); - } - table = parent.abbreviated; - for (var i = 0; i < 7; i++) { - sysres["EEE" + i] = capFunction(table[dayProperties[i]]); - } - table = parent.wide; - for (var i = 0; i < 7; i++) { - sysres["EEEE" + i] = capFunction(table[dayProperties[i]]); - } - var periodProperties = ["am", "pm"]; - parent = typeof (data.dates.calendars.gregorian.dayPeriods.format) === 'undefined' ? - data.dates.calendars.gregorian.dayPeriods.standalone : - data.dates.calendars.gregorian.dayPeriods.format; - table = parent.wide; - for (var i = 0; i < 2; i++) { - sysres["a" + i] = table[periodProperties[i]]; - } - table = data.dates.calendars.gregorian.eras.eraAbbr; - sysres["G-1"] = table["0"]; - sysres["G1"] = table["1"]; - - function truncToSize(str, size) { - var i = str.indexOf("{0}"); - if (i >= 0) { - i += 3; - while (str.charAt(i) === ' ') { - i++; - } - if (i + size <= str.length) { - if (i + size + 1 === str.length) { - return str.substring(0, i + size + 1); - } - return str.substring(0, i + size); - } - return undefined; - } - return undefined; - } - - function clip(shortStr, longStr, size) { - var truncated = undefined; - if (shortStr) { - truncated = truncToSize(shortStr, size); - } - if (truncated) { - return truncated; - } - if (longStr) { - truncated = truncToSize(longStr, size); - } - if (truncated) { - return truncated; - } - return shortStr || longStr; - } - - function clipForMedium(shortStr, longStr) { - return clip(shortStr, longStr, 2); - } - - function clipForLong(longStr) { - return clip(longStr, undefined, 3); - } - var durationPropertiesFull = { - "second": "1#1 second|#{num} seconds", - "minute": "1#1 minute|#{num} minutes", - "hour": "1#1 hour|#{num} hours", - "day": "1#1 day|#{num} days", - "week": "1#1 week|#{num} weeks", - "month": "1#1 month|#{num} months", - "year": "1#1 year|#{num} years" - }; - var durationPropertiesLong = { - "second": "1#1 sec|#{num} sec", - "minute": "1#1 min|#{num} min", - "hour": "1#1 hr|#{num} hrs", - "day": "durationLongDays", - "week": "1#1 wk|#{num} wks", - "month": "1#1 mon|#{num} mons", - "year": "1#1 yr|#{num} yrs" - }; - var durationPropertiesMedium = { - "second": "1#1 se|#{num} sec", - "minute": "1#1 mi|#{num} min", - "hour": "durationMediumHours", - "day": "1#1 dy|#{num} dys", - "week": "durationMediumWeeks", - "month": "1#1 mo|#{num} mos", - "year": "durationMediumYears" - }; - var durationPropertiesShort = { - "second": "#{num}s", - "minute": "durationShortMinutes", - "hour": "#{num}h", - "day": "#{num}d", - "week": "#{num}w", - "month": "durationShortMonths", - "year": "#{num}y" - }; - table = data.units; - for (duration in durationPropertiesMedium) { - if (duration && durationPropertiesMedium[duration]) { - var unit = table[duration]; - var shortStr = unit["unitPattern-count-one"]; - if (!shortStr) { - shortStr = unit["unitPattern-count-other"]; - } - if (shortStr) { - var unitOnly = shortStr.replace("{0}", ""); - var initial = unitOnly.trim().charAt(0); - shortStr = shortStr.replace(unitOnly, initial).replace("{0}", "{num}"); - if (shortStr.length > 0) { - sysres[durationPropertiesShort[duration]] = "#" + shortStr; - } - } - var mediumOther = "", - longOther = "", - fullOther = ""; - var temp, mediumClipped, longClipped, mediumStr = "", - longStr = "", - fullStr = ""; - if (typeof (unit["unitPattern-count-other-alt-short"]) !== 'undefined') { - mediumOther = clipForMedium( - unit["unitPattern-count-other-alt-short"], - unit["unitPattern-count-other"]); - } - if (typeof (unit["unitPattern-count-other"]) !== 'undefined') { - longOther = clipForLong(unit["unitPattern-count-other"]); - fullOther = unit["unitPattern-count-other"]; - } - var unitNames = [ - "0", - "1", - "zero", - "one", - "two", - "few", - "many" - ]; - for (var j = 0; j < unitNames.length; j++) { - name = unitNames[j]; - mediumClipped = clipForMedium( - unit["unitPattern-count-" + name + "-alt-short"], - unit["unitPattern-count-" + name]); - if (typeof (unit["unitPattern-count-" + name + "-alt-short"]) !== 'undefined' && - mediumClipped !== mediumOther) { - if (mediumStr.length > 0) { - mediumStr += "|"; - } - temp = mediumClipped.replace("{0}", "{num}"); - mediumStr += name + "#" + temp; - } - longClipped = clipForLong(unit["unitPattern-count-" + name]); - if (typeof (unit["unitPattern-count-" + name]) !== 'undefined' && - longClipped !== longOther) { - if (longStr.length > 0) { - longStr += "|"; - } - temp = longClipped.replace("{0}", "{num}"); - longStr += name + "#" + temp; - } - if (typeof (unit["unitPattern-count-" + name]) !== 'undefined' && - unit["unitPattern-count-" + name] !== fullOther) { - if (fullStr.length > 0) { - fullStr += "|"; - } - fullStr += name + "#" + unit["unitPattern-count-" + name].replace("{0}", "{num}"); - } - } - if (typeof (unit["unitPattern-count-other-alt-short"]) !== 'undefined') { - if (mediumStr.length > 0) { - mediumStr += "|"; - } - temp = clipForMedium(unit["unitPattern-count-other-alt-short"], unit["unitPattern-count-other"]).replace("{0}", "{num}"); - mediumStr += "#" + temp; - } - if (typeof (unit["unitPattern-count-other"]) !== 'undefined') { - if (longStr.length > 0) { - longStr += "|"; - } - if (fullStr.length > 0) { - fullStr += "|"; - } - temp = clipForLong(unit["unitPattern-count-other"]).replace("{0}", "{num}"); - longStr += "#" + temp; - fullStr += "#" + unit["unitPattern-count-other"].replace("{0}", "{num}"); - } - if (mediumStr.length > 0) { - sysres[durationPropertiesMedium[duration]] = mediumStr; - } - if (longStr.length > 0) { - sysres[durationPropertiesLong[duration]] = longStr; - } - if (fullStr.length > 0) { - sysres[durationPropertiesFull[duration]] = fullStr; - } - } - } - unit = table; - str = ""; - if (typeof (unit["day-past"]["unitPattern-count-one"]) !== 'undefined' || typeof (unit["day-past"]["unitPattern-count-other"]) !== 'undefined') { - var day = table["day"]["unitPattern-count-one"] || table["day"]["unitPattern-count-other"]; - var dayPast = table["day-past"]["unitPattern-count-one"] || table["day-past"]["unitPattern-count-other"]; - //util.print("day"+ dayPast + "\n"); - //util.print("dayPast"+ dayPast + "\n"); - if (dayPast.indexOf(day) != -1) { - sysres["{duration} ago"] = dayPast.replace(day, "{duration}").toLowerCase(); - } else { - /* var dayPast_few = table["day-past"]["unitPattern-count-few"] || table["day-past"]["unitPattern-count-other"]; - if (dayPast_few != dayPast) { - dayPast_few = dayPast_few.replace("{0}", ""); - dayPast = dayPast.replace("{0}", ""); - arr_dayPast_few = dayPast_few.split(" "); - arr_dayPast = dayPast.split(" "); - var mismatch; - for (var i = 0; i < arr_dayPast.length; i++) { - if (arr_dayPast_few[i] != arr_dayPast[i]) { - mismatch = arr_dayPast[i]; - } - }*/ - //if(language === "th"){ - //util.print("dayPast"+ dayPast + "\n"); - //util.print("dayPast_few"+ dayPast_few + "\n"); - //util.print("mismatch"+ mismatch + "\n"); - //} - //sysres["{duration} ago"] = dayPast.replace(mismatch, "{duration}").toLowerCase(); - // sysres["{duration} ago"] = sysres["{duration} ago"].replace(" ", " "); - //if (sysres["{duration} ago"].indexOf("{duration}") === -1) { - //sysres["{duration} ago"] = "XXXXX"; - //} - //} else { - sysres["{duration} ago"] = "-{duration}"; - // } - } - } - - - unit = table; - str = ""; - if (typeof (table["day-future"]["unitPattern-count-one"]) !== 'undefined' || typeof (table["day-future"]["unitPattern-count-other"]) !== 'undefined') { - var day = table["day"]["unitPattern-count-one"] || table["day"]["unitPattern-count-other"]; - var dayFuture = table["day-future"]["unitPattern-count-one"] || table["day-future"]["unitPattern-count-other"]; - if (dayFuture.indexOf(day) != -1) { - sysres["in {duration}"] = dayFuture.replace(day, "{duration}").toLowerCase(); - } else { - /* var dayFuture_few = table["day-future"]["unitPattern-count-few"] || table["day-future"]["unitPattern-count-other"]; - if (dayFuture_few != dayFuture) { - dayFuture_few = dayFuture_few.replace("{0}", ""); - dayFuture = dayFuture.replace("{0}", ""); - arr_dayFuture_few = dayFuture_few.split(" "); - arr_dayFuture = dayFuture.split(" "); - var mismatch; - for (var i = 0; i < arr_dayFuture.length; i++) { - if (arr_dayFuture_few[i] != arr_dayFuture[i]) { - mismatch = arr_dayFuture[i]; - } - } - sysres["in {duration}"] = dayFuture.replace(mismatch, "{duration}").toLowerCase(); - sysres["in {duration}"] = sysres["in {duration}"].replace(" ", " "); - if (sysres["in {duration}"].indexOf("{duration}") === -1) { - sysres["in {duration}"] = "XXXXX"; - }*/ - // } else { - sysres["in {duration}"] = "+{duration}"; - //} - } - } - var listProperties = { - "separatorFull": "middle", - "finalSeparatorFull": "end" - }; - table = data.listPatterns.listPattern; - for (pattern in listProperties) { - if (pattern && listProperties[pattern]) { - var unit = table[listProperties[pattern]]; - if (unit.length > 0) { - sysres[pattern] = unit.replace(/\{.\}/g, ""); - } - } - } - sysres["separatorShort"] = " "; - sysres["separatorMedium"] = " "; - sysres["separatorLong"] = " "; - return sysres; -} -//code getting implemented - -function anyProperties(data) { - var count = 0; - for (var prop in data) { - if (prop && data[prop]) { - count++; - } - if (count > 1) { - return true; - } - } - return false; -} - -function writeSystemResources(language, script, region, data) { - var path = calcLocalePath(language, script, region, ""); - if (data.generated) { - if (anyProperties(data)) { - util.print("Writing " + path + "\n"); - makeDirs(path); - fs.writeFileSync(path + "/sysres.json", JSON.stringify(data, true, 4), "utf-8"); - } else { - util.print("Skipping empty " + path + "\n"); - } - } else { - util.print("Skipping existing " + path + "\n"); - } -} -// for each locale, get the data -var language, region, script, file, - files = fs.readdirSync(cldrDirName + "/main/"); -util.print("Reading locale data into memory...\n"); -for (var i = 0; i < files.length; i++) { - file = files[i]; - if (file === "root.json") { - // special case because "root" is not a valid locale specifier - getLocaleData(file, undefined, undefined, undefined); - } else { - locale = file.split(/\./)[0].replace(/_/g, "-"); - var l = new Locale(locale); - if (typeof (l.getVariant()) === 'undefined') { - getLocaleData(file, l.getLanguage(), l.getScript(), l.getRegion()); - } - } -} -util.print("\n"); -// find the system resources -util.print("Merging and pruning locale data...\n"); -mergeAndPrune(localeData); -var resources = {}; -var resources_dateformat_data = {}; -util.print("\nCalculating system resources...\n"); -resources.data = getSystemResources(undefined, undefined, undefined, localeData.data); -//resources_dateformat_data=resources.data; -for (language in localeData) { - if (language && localeData[language] && language !== 'data' && language !== 'merged') { - resources[language] = resources[language] || {}; - util.print(language + " "); - for (var subpart in localeData[language]) { - if (subpart && localeData[language][subpart] && subpart !== 'data' && subpart !== 'merged') { - resources[language][subpart] = resources[language][subpart] || {}; - if (Locale.isScriptCode(subpart)) { - script = subpart; - for (region in localeData[language][script]) { - resources[language][script][region] = resources[language][script][region] || {}; - if (region && localeData[language][script][region] && region !== 'data' && region !== 'merged') { - resources[language][script][region].data = getSystemResources(language, script, region, localeData[language][script][region].merged); - } - } - } - resources[language][subpart].data = getSystemResources(language, subpart, undefined, localeData[language][subpart].merged); - } - } - resources[language].data = getSystemResources(language, undefined, undefined, localeData[language].merged); - } -} -util.print("\nMerging and pruning resources...\n"); -mergeAndPrune(resources); -util.print("\nWriting system resources...\n"); - -for (language in resources) { - if (language && resources[language] && language !== 'data' && language !== 'merged') { - for (var subpart in resources[language]) { - if (subpart && resources[language][subpart] && subpart !== 'data' && subpart !== 'merged') { - if (Locale.isScriptCode(subpart)) { - script = subpart; - for (region in resources[language][script]) { - if (region && resources[language][script][region] && region !== 'data' && region !== 'merged') { - writeSystemResources(language, script, region, resources[language][script][region].data); - } - } - writeSystemResources(language, script, undefined, resources[language][script].data); - } else { - writeSystemResources(language, undefined, subpart, resources[language][subpart].data); - } - } - } - writeSystemResources(language, undefined, undefined, resources[language].data); - } -} -writeSystemResources(undefined, undefined, undefined, resources.data); - -resources_dateformat_data.data = getDateFormats(undefined, undefined, undefined, localeData.data); -for (language in localeData) { - if (language && localeData[language] && language !== 'data' && language !== 'merged') { - resources_dateformat_data[language] = resources_dateformat_data[language] || {}; - util.print(language + " "); - for (var subpart in localeData[language]) { - if (subpart && localeData[language][subpart] && subpart !== 'data' && subpart !== 'merged') { - resources_dateformat_data[language][subpart] = resources_dateformat_data[language][subpart] || {}; - if (Locale.isScriptCode(subpart)) { - script = subpart; - for (region in localeData[language][script]) { - resources_dateformat_data[language][script][region] = resources_dateformat_data[language][script][region] || {}; - if (region && localeData[language][script][region] && region !== 'data' && region !== 'merged') { - resources_dateformat_data[language][script][region].data = getDateFormats(language, script, region, localeData[language][script][region].merged); - } - } - } - resources_dateformat_data[language][subpart].data = getDateFormats(language, subpart, undefined, localeData[language][subpart].merged); - } - } - resources_dateformat_data[language].data = getDateFormats(language, undefined, undefined, localeData[language].merged); - } -} -util.print("\nMerging and pruning data for dateformats.\n"); -mergeAndPrune(resources_dateformat_data); - -function getDateFormats(language, script, region, data) { - // if it is already there and non-generated, return it - var dates = loadFileNonGenerated(language, script, region, "dateformats.json"); - // util.print("language: " + language + "\n"); - // util.print("script: " + script + "\n"); - // util.print("region: " + region + "\n"); - if (dates && (typeof (dates.generated) === 'undefined' || !dates.generated)) { - util.print("\nLoaded existing dateformats from " + calcLocalePath(language, script, region, "dateformats.json") + "\n"); - dates.generated = false; - return dates; - } - // else generate a new one - dates = { - generated: true - }; - var default_calendar = data.dates.calendars["default"]; - //util.print("default calendar is :" + default_calendar + "\n"); - var gregorian_order = data.dates.calendars[default_calendar]["dateTimeFormats"]["full"]["dateTimeFormat"]["pattern"]; - //util.print("default format is :" + JSON.stringify(gregorian_order_formats) + "\n"); - //var gregorian_order_full = gregorian_order_formats[full] ;//full"]["dateTimeFormat"]["pattern"]; - //var gregorian_order = gregorian_order_full["dateTimeFormat"]["pattern"]; - //util.print("default calendar format pattern is " + gregorian_order + "\n"); - var gregorian = {}; - //var output = {}; - //output["gregorian"]="gregorian"; - if (gregorian_order == "{0} {1}") { - //util.print("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"+"\n"); - gregorian["order"] = "{date} {time}"; - } else { - gregorian["order"] = "{time} {date}"; - } - //util.print("gregorian calendar order is :" + gregorian["order"] + "\n"); - var date_formats = data.dates.calendars[default_calendar]["dateFormats"]; - var available_formats = data.dates.calendars[default_calendar]["dateTimeFormats"]["availableFormats"]; - // util.print("available formats are :" + JSON.stringify(available_formats) + "+++++++++++++++++++++" + "\n"); - available_formats = JSON.parse(JSON.stringify(available_formats).replace(/L/g, "M")); - available_formats = JSON.parse(JSON.stringify(available_formats).replace(/G/g, "")); - //available_formats = JSON.parse(JSON.stringify(available_formats).replace(/'[^']+'/g, "")); - //util.print("available formats after conversion :" + JSON.stringify(available_formats) + "++++++++++++++++++++++++++++++++++++++++++++" + "\n"); - var keys_dateformats = Object.keys(available_formats); - //var values_dateformats = JSON.stringify(keys_dateformats); - var arr_values = []; - //util.print("date fomat keys are :" + keys_dateformats + "*********************************" + "\n"); - for (var i = 0; i < keys_dateformats.length; i++) { - arr_values[i] = available_formats[keys_dateformats[i]]; - - } - //util.print("date fomat keys are :" + JSON.stringify(arr_values) + "*********************************" + "\n"); - - - var date = {}; - var dm = {}; - var dmwy = {}; - var dmy = {}; - var dmw = {}; - var my = {}; - var d = {}; - var m = {}; - var y = {}; - var n = {}; - //for (var i=0;i arr_values[j].indexOf("d")) ? (arr_values[j].substring(arr_values[j].indexOf("d"), 1 + arr_values[j].lastIndexOf( - "M"))) : (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf("d"))); - //} - flag = true; - break; - } - } - if (flag == false) { - var short = date_formats["short"]["dateFormat"]["pattern"]; - dm["s"] = (short.indexOf("d") < short.indexOf("M")) ? short.substring(short.indexOf("d"), 1 + short.lastIndexOf("M")) : short.substring(short.indexOf("M"), - 1 + short.lastIndexOf("d")); - } - } - //end of short - if (available_formats["MMdd"] || available_formats["MMd"]) { - //if(available_formats["MMdd"]!=undefined) - //{ - dm["m"] = available_formats["MMdd"] || available_formats["MMd"]; - //} - //else - //dm["m"]=available_formats["MMd"]; - } else if ((available_formats["MMdd"] === undefined) && (available_formats["MMd"] === undefined)) { - var flag = false; - for (var j = 0; j < arr_values.length; j++) { - if (((arr_values[j].split("M").length - 1) == 2) && ((arr_values[j].split("d").length - 1) >= 1)) { - dm["m"] = (arr_values[j].indexOf("M") > arr_values[j].indexOf("d")) ? (arr_values[j].substring(arr_values[j].indexOf("d"), 1 + arr_values[j].indexOf("M"))) : - (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf("d"))); - flag = true; - break; - } - } - if (flag == false) { - var medium = date_formats["medium"]["dateFormat"]["pattern"]; - dm["m"] = (medium.indexOf("M") < medium.indexOf("d")) ? medium.substring(medium.indexOf("M"), 1 + medium.lastIndexOf("d")) : medium.substring(medium.indexOf( - "d"), 1 + medium.lastIndexOf("M")); - } - } - if (available_formats["MMMd"] || available_formats["MMMdd"]) { - dm["l"] = available_formats["MMMd"] || available_formats["MMMdd"]; - } else if ((available_formats["MMMdd"] === undefined) && (available_formats["MMMd"] === undefined)) { - var flag = false; - for (var j = 0; j < arr_values.length; j++) { - if (((arr_values[j].split("M").length - 1) == 3) && ((arr_values[j].split("d").length - 1) >= 1)) { - dm["l"] = (arr_values[j].indexOf("M") > arr_values[j].indexOf("d")) ? (arr_values[j].substring(arr_values[j].indexOf("d"), 1 + arr_values[j].lastIndexOf( - "M"))) : (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf("d"))); - flag = true; - break; - } - } - if (flag == false) { - var long = date_formats["long"]["dateFormat"]["pattern"]; - dm["l"] = (long.indexOf("M") < long.indexOf("d")) ? long.substring(long.indexOf("M"), 1 + long.lastIndexOf("d")) : (long.substring(long.indexOf("d"), 1 + - long.lastIndexOf("M"))); - } - } - if (available_formats["MMMMd"] || available_formats["MMMMdd"]) { - dm["f"] = available_formats["MMMMd"] || available_formats["MMMMdd"]; - } else if ((available_formats["MMMMdd"] === undefined) && (available_formats["MMMMd"] === undefined)) { - var flag = false; - for (var j = 0; j < arr_values.length; j++) { - if (((arr_values[j].split("M").length - 1) == 4) && ((arr_values[j].split("d").length - 1) >= 1)) { - dm["f"] = (arr_values[j].indexOf("M") > arr_values[j].indexOf("d")) ? (arr_values[j].substring(arr_values[j].indexOf("d"), 1 + arr_values[j].lastIndexOf( - "M"))) : (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf("d"))); - flag = true; - break; - } - } - if (flag == false) { - var full = date_formats["long"]["dateFormat"]["pattern"]; - dm["f"] = full.indexOf("M") < (full.indexOf("d")) ? full.substring(full.indexOf("M"), 1 + full.lastIndexOf("d")) : full.substring(full.indexOf("d"), 1 + - full.lastIndexOf("M")); - } - } - //end of combination dm - if (available_formats["yM"] || available_formats["yyM"] || available_formats["yyyyM"]) { - my["s"] = available_formats["yM"] || available_formats["yyM"] || available_formats["yyyyM"]; - } else if ((available_formats["yM"] === undefined) && (available_formats["yyM"] === undefined) && (available_formats["yyyyM"] === undefined)) { - var flag = false; - for (var j = 0; j < arr_values.length; j++) { - if (((arr_values[j].split("M").length - 1) == 1) && ((arr_values[j].split("y").length - 1) >= 1)) { - my["s"] = (arr_values[j].indexOf("y") > arr_values[j].indexOf("M")) ? (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf( - "y"))) : (arr_values[j].substring(arr_values[j].indexOf("y"), 1 + arr_values[j].lastIndexOf("M"))); - flag = true; - break; - } - } - if (flag == false) { - var short = date_formats["short"]["dateFormat"]["pattern"]; - my["s"] = (short.indexOf("M") < short.indexOf("y")) ? short.substring(short.indexOf("M"), 1 + short.lastIndexOf("y")) : short.substring(short.indexOf("y"), - 1 + short.lastIndexOf("M")); - } - } - if (available_formats["yyyyMM"] || available_formats["yyMM"] || available_formats["yMM"]) { - my["m"] = available_formats["yyyyMM"] || available_formats["yyMM"] || available_formats["yMM"]; - } else if ((available_formats["yMM"] === undefined) && (available_formats["yyMM"] === undefined) && (available_formats["yyyyMM"] === undefined)) { - var flag = false; - for (var j = 0; j < arr_values.length; j++) { - if (((arr_values[j].split("M").length - 1) == 2) && ((arr_values[j].split("y").length - 1) >= 1)) { - my["m"] = (arr_values[j].indexOf("y") > arr_values[j].indexOf("M")) ? (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf( - "y"))) : (arr_values[j].substring(arr_values[j].indexOf("y"), 1 + arr_values[j].lastIndexOf("M"))); - flag = true; - break; - } - } - if (flag == false) { - var medium = date_formats["medium"]["dateFormat"]["pattern"]; - my["m"] = medium.indexOf("M") < medium.indexOf("y") ? medium.substring(medium.indexOf("M"), 1 + medium.lastIndexOf("y")) : medium.substring(medium.indexOf( - "y"), 1 + medium.lastIndexOf("M")); - } - } - if (available_formats["yMMM"] || available_formats["yyMMM"] || available_formats["yyyyMMM"]) { - my["l"] = available_formats["yMMM"] || available_formats["yyMMM"] || available_formats["yyyyMMM"]; - } else if ((available_formats["yMMM"] === undefined) && (available_formats["yyMMM"] === undefined) && (available_formats["yyyyMMM"] === undefined)) { - var flag = false; - for (var j = 0; j < arr_values.length; j++) { - if (((arr_values[j].split("M").length - 1) == 3) && ((arr_values[j].split("y").length - 1) >= 1)) { - my["l"] = (arr_values[j].indexOf("y") > arr_values[j].indexOf("M")) ? (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf( - "y"))) : (arr_values[j].substring(arr_values[j].indexOf("y"), 1 + arr_values[j].lastIndexOf("M"))); - flag = true; - break; - } - } - if (flag == false) { - var long = date_formats["long"]["dateFormat"]["pattern"]; - my["l"] = (long.indexOf("M") < long.indexOf("y")) ? long.substring(long.indexOf("M"), 1 + long.lastIndexOf("y")) : long.substring(long.indexOf("y"), 1 + - long.lastIndexOf("M")); - } - } - if (available_formats["yyyyMMMM"] || available_formats["yyMMMM"] || available_formats["yMMMM"]) { - my["f"] = available_formats["yyyyMMMM"] || available_formats["yyMMMM"] || available_formats["yMMMM"]; - } else if ((available_formats["yyyyMMMM"] === undefined) && (available_formats["yyMMMM"] === undefined) && (available_formats["yMMMM"] === undefined)) { - var flag = false; - for (var j = 0; j < arr_values.length; j++) { - if (((arr_values[j].split("M").length - 1) == 4) && ((arr_values[j].split("y").length - 1) >= 1)) { - my["f"] = (arr_values[j].indexOf("y") > arr_values[j].indexOf("M")) ? (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf( - "y"))) : (arr_values[j].substring(arr_values[j].indexOf("y"), 1 + arr_values[j].lastIndexOf("M"))); - flag = true; - break; - } - } - if (flag == false) { - var full = date_formats["full"]["dateFormat"]["pattern"]; - my["f"] = (full.indexOf("M") < full.indexOf("y")) ? full.substring(full.indexOf("M"), 1 + full.lastIndexOf("y")) : full.substring(full.indexOf("y"), 1 + - full.lastIndexOf("M")); - } - } - //end of my combination - if (available_formats["yyyyMd"] || available_formats["yMd"]) { - dmy["s"] = available_formats["yyyyMd"] || available_formats["yMd"]; - } else if (available_formats["yyyyMd"] === undefined) { - var flag = false; - for (var j = 0; j < arr_values.length; j++) { - if (((arr_values[j].split("M").length - 1) == 1) && ((arr_values[j].split("y").length - 1) >= 1) && ((arr_values[j].split("d").length - 1) >= 1)) { - index_of_d = arr_values[j].indexOf("d"); - index_of_m = arr_values[j].indexOf("M"); - index_of_y = arr_values[j].indexOf("y"); - var max_index = Math.max(index_of_d, index_of_m, index_of_y); - var min_index = Math.min(index_of_d, index_of_m, index_of_y); - dmy["s"] = arr_values[j].substring(min_index, 1 + arr_values[j].lastIndexOf(arr_values[j].charAt(max_index))); - flag = true; - break; - } - } - if (flag == false) { - var short = date_formats["short"]["dateFormat"]["pattern"]; - index_of_d = short.indexOf("d"); - index_of_m = short.indexOf("M"); - index_of_y = short.indexOf("y"); - var max_index = Math.max(index_of_d, index_of_m, index_of_y); - var min_index = Math.min(index_of_d, index_of_m, index_of_y); - dmy["s"] = short.substring(min_index, 1 + short.lastIndexOf(short.charAt(max_index))); - } - } - if (available_formats["yyMMdd"]) { - dmy["m"] = available_formats["yyMMdd"]; - } else if (available_formats["yyMMdd"] === undefined) { - var flag = false; - for (var j = 0; j < arr_values.length; j++) { - if (((arr_values[j].split("M").length - 1) == 2) && ((arr_values[j].split("y").length - 1) >= 1) && ((arr_values[j].split("d").length - 1) >= 1)) { - index_of_d = arr_values[j].indexOf("d"); - index_of_m = arr_values[j].indexOf("M"); - index_of_y = arr_values[j].indexOf("y"); - var max_index = Math.max(index_of_d, index_of_m, index_of_y); - var min_index = Math.min(index_of_d, index_of_m, index_of_y); - dmy["m"] = arr_values[j].substring(min_index, 1 + arr_values[j].lastIndexOf(arr_values[j].charAt(max_index))); - flag = true; - break; - } - } - if (flag == false) { - var medium = date_formats["medium"]["dateFormat"]["pattern"]; - index_of_d = medium.indexOf("d"); - index_of_m = medium.indexOf("M"); - index_of_y = medium.indexOf("y"); - var max_index = Math.max(index_of_d, index_of_m, index_of_y); - var min_index = Math.min(index_of_d, index_of_m, index_of_y); - dmy["m"] = medium.substring(min_index, 1 + medium.lastIndexOf(medium.charAt(max_index))); - } - } - if (available_formats["yyMMMd"] || available_formats["yyyyMMMd"] || available_formats["yMMMd"]) { - dmy["l"] = available_formats["yyMMMd"] || available_formats["yyyyMMMd"] || available_formats["yMMMd"]; - } else if ((available_formats["yyMMMd"] === undefined) && (available_formats["yyyyMMMd"] === undefined) && (available_formats["yMMMd"] === undefined)) { - var flag = false; - for (var j = 0; j < arr_values.length; j++) { - if (((arr_values[j].split("M").length - 1) == 3) && ((arr_values[j].split("y").length - 1) >= 1) && ((arr_values[j].split("d").length - 1) >= 1)) { - index_of_d = arr_values[j].indexOf("d"); - index_of_m = arr_values[j].indexOf("M"); - index_of_y = arr_values[j].indexOf("y"); - var max_index = Math.max(index_of_d, index_of_m, index_of_y); - var min_index = Math.min(index_of_d, index_of_m, index_of_y); - dmy["l"] = arr_values[j].substring(min_index, 1 + arr_values[j].lastIndexOf(arr_values[j].charAt(max_index))); - flag = true; - break; - } - } - if (flag == false) { - var long = date_formats["long"]["dateFormat"]["pattern"]; - index_of_d = long.indexOf("d"); - index_of_m = long.indexOf("M"); - index_of_y = long.indexOf("y"); - var max_index = Math.max(index_of_d, index_of_m, index_of_y); - var min_index = Math.min(index_of_d, index_of_m, index_of_y); - dmy["l"] = long.substring(min_index, 1 + long.lastIndexOf(long.charAt(max_index))); - } - } - if (available_formats["yMMMMd"]) { - dmy["f"] = available_formats["yMMMMd"]; - } else if (available_formats["yMMMMd"] === undefined) { - var flag = false; - for (var j = 0; j < arr_values.length; j++) { - if (((arr_values[j].split("M").length - 1) == 4) && ((arr_values[j].split("y").length - 1) >= 1) && ((arr_values[j].split("d").length - 1) >= 1)) { - index_of_d = arr_values[j].indexOf("d"); - index_of_m = arr_values[j].indexOf("M"); - index_of_y = arr_values[j].indexOf("y"); - var max_index = Math.max(index_of_d, index_of_m, index_of_y); - var min_index = Math.min(index_of_d, index_of_m, index_of_y); - dmy["f"] = arr_values[j].substring(min_index, 1 + arr_values[j].lastIndexOf(arr_values[j].charAt(max_index))); - flag = true; - break; - } - } - if (flag == false) { - var full = date_formats["full"]["dateFormat"]["pattern"]; - index_of_d = full.indexOf("d"); - index_of_m = full.indexOf("M"); - index_of_y = full.indexOf("y"); - var max_index = Math.max(index_of_d, index_of_m, index_of_y); - var min_index = Math.min(index_of_d, index_of_m, index_of_y); - dmy["f"] = full.substring(min_index, 1 + full.lastIndexOf(full.charAt(max_index))); - } - } - //util.print("DMY combination"+JSON.stringify(dmy)+"\n"); - //end of dmy combination - if (available_formats["d"]) { - d["s"] = available_formats["d"]; - d["s"] = d["s"].replace(/\./, ""); - d["m"] = d["l"] = d["f"] = d["s"]; - } - if (available_formats["d"] === undefined) { - //var flag=false; - for (var j = 0; j < arr_values.length; j++) { - if ((arr_values[j].split("d").length - 1) == 1) { - d["s"] = "d"; - d["m"] = "d"; - d["l"] = "d"; - d["f"] = "d"; - break; - } - } - } - //if(d["s"]!="d") - //{ - for (var j = 0; j < arr_values.length; j++) { - if ((arr_values[j].split("d").length - 1) == 2) { - if (d["s"] != "d") { - d["s"] = "dd"; - } - d["m"] = "dd"; - d["l"] = "dd"; - d["f"] = "dd"; - break; - } - } - - //d = JSON.stringify(d).replace(/./g,""); - //} - //} - //end of d combination - if (available_formats["M"]) { - m["s"] = available_formats["M"]; - m["s"] = m["l"] = m["m"] = m["f"]; - } else if (available_formats["M"] === undefined) { - //var flag=false; - for (var j = 0; j < arr_values.length; j++) { - if ((arr_values[j].split("M").length - 1) == 1) { - m["s"] = "M"; - m["m"] = "M"; - m["l"] = "M"; - m["f"] = "M"; - break; - } - } - } - //if(m["s"]!="M") - //{ - for (var j = 0; j < arr_values.length; j++) { - if ((arr_values[j].split("M").length - 1) == 2) { - if (m["s"] != "M") { - m["s"] = "MM"; - } - m["m"] = "MM"; - m["l"] = "MM"; - m["f"] = "MM"; - break; - } - } - //} - if (available_formats["MMM"]) { - m["l"] = available_formats["MMM"]; - m["f"] = m["l"]; - } else if (available_formats["MMM"] === undefined) { - for (var j = 0; j < arr_values.length; j++) { - if ((arr_values[j].split("M").length - 1) == 3) { - m["l"] = "MMM"; - m["f"] = "MMM"; - break; - } - } - } - //if(m["l"]!="MMM") - //{ - for (var j = 0; j < arr_values.length; j++) { - if ((arr_values[j].split("M").length - 1) == 4) { - if (m["l"] != "MMM") { - m["l"] = "MMMM"; - } - m["f"] = "MMMM"; - //d["l"]="dd"; - //d["f"]="dd"; - break; - } - } - //} - //end of m combination - if (available_formats["y"]) { - //util.print("debugging"+"\n"); - y["s"] = available_formats["y"]; - y["s"] = y["m"] = y["l"] = y["f"]; - //util.print("year format is " +JSON.stringify(y)+"\n"); - } - //if(y["s"]!="y") - //{ - for (var j = 0; j < arr_values.length; j++) { - if ((arr_values[j].split("y").length - 1) == 2) { - //if (y["s"] != "y") { - y["s"] = "yy"; - //} - y["m"] = "yy"; - break; - } else { - y["s"] = y["m"] = "yyyy"; - } - } - - y["l"] = "yyyy"; - y["f"] = "yyyy"; - - - - //util.print("year format is " +JSON.stringify(y)+"\n"); - //end of y combination - if (available_formats["MEd"]) { - dmw["s"] = available_formats["MEd"]; - dmw["m"] = available_formats["MEd"].replace(/E+/g, "EE"); - } else if (available_formats["MEd"] === undefined) { - dmw["s"] = "E" + " " + dm["s"]; - dmw["m"] = "EE" + " " + dm["m"]; - } - //dmw["m"]="E"+dm["s"]; - if (available_formats["MMMEd"]) { - dmw["l"] = available_formats["MMMEd"].replace(/E+/g, "EEEE");; - dmw["f"] = available_formats["MMMEd"].replace(/E+/g, "EEEE"); - } else if (available_formats["MMMEd"] === undefined) { - dmw["l"] = "EEE" + " " + dm["l"]; - dmw["f"] = "EEEE" + " " + dm["f"]; - } - //dmw["l"]="EEE"+dm["l"]; - //end of dmw - if (available_formats["yMEd"]) { - dmwy["s"] = available_formats["yMEd"]; - dmwy["m"] = available_formats["yMEd"].replace(/E+/g, "EE"); - } else if (available_formats["yMEd"] === undefined) { - dmw["s"] = "EE" + " " + dmy["s"]; - } - if (available_formats["yMMMEd"]) { - dmwy["l"] = available_formats["yMMMEd"].replace(/E+/g, "EEE"); - dmwy["f"] = available_formats["yMMMEd"].replace(/E+/g, "EEEE"); - } else if (available_formats["yMMMEd"] === undefined) { - dmwy["l"] = "EEE" + " " + dmy["l"]; - dmwy["f"] = "EEEE" + " " + dmy["f"]; - } - n["s"] = "N"; - n["m"] = "N"; - n["l"] = "MMM"; - n["f"] = "MMMM"; - //} - /* var allkeys_datefmts = [dm, my, dmy, d, m, y, dmw, dmwy]; - for (var i = 0; i < allkeys_datefmts.length; i++) { - var array_keys = Object.keys(allkeys_datefmts[i]); - for (var j = 0; j < array_keys.length; j++) { - if (typeof (allkeys_datefmts[i][array_keys[j]]) === 'undefined') { - allkeys_datefmts[i][array_keys[j]] = "XXXXX"; - } - } - }*/ - - var keys_datefmts = [my, dmy, y, dmwy]; - //var values_dateformats = JSON.stringify(keys_dateformats); - //var datefmt_values = []; - //util.print("date fomat keys are :" + keys_dateformats + "*********************************" + "\n"); - for (var i = 0; i < keys_datefmts.length; i++) { - if (typeof (keys_datefmts[i] != 'undefined')) { - key = keys_datefmts[i]; - //util.print("date fomat key are :" + JSON.stringify(key) + "*********************************" + "\n"); - - // if ((key["s"].split(/y/g).length - 1 != 2) && (key["s"].split(/y/g).length - 1 != 4)) { - // if (key["m"].split(/y/g).length - 1 == 2) { - // key["s"] = key["s"].replace(/[y]+/g, "yy"); - //} - // - - key["s"] = key["s"].replace(/[y]+/g, "yy"); - - - if (key["m"].split(/y/g).length - 1 == 4) { - key["m"] = key["m"].replace(/[y]+/g, "yyyy"); - } else { - key["m"] = key["m"].replace(/[y]+/g, "yy"); - } - //} - if ((key["l"].split(/y/g).length - 1 != 2) && (key["l"].split(/y/g).length - 1 != 4)) { - key["l"] = key["l"].replace(/[y]+/g, "yyyy"); - } - if ((key["f"].split(/y/g).length - 1 != 2) && (key["f"].split(/y/g).length - 1 != 4)) { - key["f"] = key["f"].replace(/[y]+/g, "yyyy"); - } - } - } - date["dm"] = dm; - date["my"] = my; - date["dmy"] = dmy; - date["d"] = d; - date["m"] = m; - date["y"] = y; - date["dmw"] = dmw; - date["dmwy"] = dmwy; - date["n"] = n; - gregorian["date"] = date; - - //dates["gregorian"]=gregorian; - //} - //util.print("gregorian date formats are :"+JSON.stringify(gregorian)+"++++++++++++++++++++++++++++++++++++++++++++"+"\n"); - //code to map Time Formats - var time_24 = {}; - var time_12 = {}; - var time_fmt = {}; - available_formats = JSON.parse(JSON.stringify(available_formats).replace(/HH/g, "H")); - var timeformat = data.dates.calendars[default_calendar]["timeFormats"]; - //util.print("time formats are :"+JSON.stringify(timeformat)+"++++++++++++++++++++++++++++++++++++++++++++"+"\n"); - if (available_formats["Hms"]) { - //var index_of_a = available_formats["hms"].indexOf("a"); - //var index_of_h = available_formats["hms"].indexOf("h"); - //var max_index = Math.max(index_of_a, index_of_h); - //available_formats["Hms"] = available_formats["Hms"].replace(/h/g, "H"); - //available_formats["Hms"] = available_formats["Hms"].substring(available_formats["Hms"].indexOf("H"), 1 + available_formats["Hms"].lastIndexOf("s")); - available_formats["Hms"] == available_formats["Hms"].replace(/a/g, ""); - //if (max_index == index_of_a) { - //time["ahmsz"] = available_formats["Hms"] + " " + "z"; - //time["ahms"] = available_formats["HH:mm:ssHms"] ; - //} else { - //time_24["ahmsz"] = "XXXXX" + available_formats["Hms"] + " " + "z"; - time_24["ahmsz"] = timeformat["long"]["timeFormat"]["pattern"].replace(/a/g, ""); - time_24["ahmsz"] = time_24["ahmsz"].replace(/h/g, "H"); - time_24["ahms"] = available_formats["Hms"]; - //} - time_24["hmsz"] = time_24["ahmsz"]; - time_24["hms"] = available_formats["Hms"]; - //time_24["ms"] = available_formats["Hms"].substring(available_formats["Hms"].indexOf("m"), 1 + available_formats["Hms"].lastIndexOf("s")); - time_24["ms"] = available_formats["Hms"].substring(available_formats["Hms"].indexOf("m"), available_formats["Hms"].length); - } - if (available_formats["Hm"]) { - //var index_of_a = available_formats["Hm"].indexOf("a"); - //var index_of_h = available_formats["Hm"].indexOf("H"); - //var max_index = Math.max(index_of_a, index_of_h); - //available_formats["hm"] = available_formats["hm"].replace(/h/g, "H"); - // available_formats["Hm"] = available_formats["Hm"].substring(available_formats["Hm"].indexOf("H"), 1 + available_formats["Hm"].lastIndexOf("m")); - available_formats["Hm"] = available_formats["Hm"].replace(/a/g, ""); //.substring(available_formats["Hm"].indexOf("H"), available_formats["Hm"].indexOf("s") - 1); - //if (max_index == index_of_a) { - //time_24["ahmz"] = available_formats["Hm"] + " " + "z"; - //time_24["ahm"] = available_formats["Hm"] ; - //time_24["ah"] = "H"; - //} else { - //time_24["ahmz"] = "XXXXX " + available_formats["Hm"] + " " + "z"; - if (time_24["ahmsz"].indexOf(":ss") != -1) { - time_24["ahmz"] = time_24["ahmsz"].replace(":ss", ""); - } else { - time_24["ahmz"] = time_24["ahmsz"].replace(".ss", ""); - } - time_24["ahm"] = available_formats["Hm"]; - time_24["hmz"] = time_24["ahmz"]; - time_24["ah"] = available_formats["H"]; - time_24["h"] = available_formats["H"]; - //} - time_24["hm"] = available_formats["Hm"]; - } - time_24["m"] = "mm"; - time_24["s"] = "ss"; - time_fmt["24"] = time_24; - //code for 12 hour clock setting - if (available_formats["hms"]) { - //available_formats["Hms"] = available_formats["Hms"].substring(available_formats["Hms"].indexOf("H"), 1 + available_formats["Hms"].lastIndexOf("s")); - //time_12["ahmsz"] = "XXXXX" + available_formats["hms"] + " " + "z"; - if (timeformat["long"]["timeFormat"]["pattern"].indexOf("HH:mm:ss") != -1) { - time_12["ahmsz"] = timeformat["long"]["timeFormat"]["pattern"].replace("HH:mm:ss", available_formats["hms"]); - // util.print("HHMMSS" + time_12["ahmsz"] + "\n"); - } else { - time_12["ahmsz"] = timeformat["long"]["timeFormat"]["pattern"].replace("H:mm:ss", available_formats["hms"]); - //util.print("HMMSS" + time_12["ahmsz"] + "\n"); - } - time_12["ahmsz"] = time_12["ahmsz"].replace(/H/g, "h"); - time_12["hmsz"] = time_12["ahmsz"].replace("\\s?a", ""); - time_12["ahms"] = available_formats["hms"].replace(/H/g, "h");; - time_12["hms"] = available_formats["hms"].replace("\\s?a", "").replace(/H/g, "h"); - //time_12["ms"] = available_formats["hms"].substring(available_formats["hms"].indexOf("m"), available_formats["hms"].lastIndexOf("s")); - time_12["ms"] = available_formats["hms"].substring(available_formats["hms"].indexOf("m"), 1 + available_formats["Hms"].lastIndexOf("s")).replace(/H/g, "h"); - } - if (available_formats["hm"]) { - //time_12["ahmz"] = "XXXXX" + available_formats["hm"] + " " + "z"; - if (time_12["ahmsz"].indexOf(":ss") != -1) { - time_12["ahmz"] = time_12["ahmsz"].replace(":ss", ""); - } else { - time_12["ahmz"] = time_12["ahmsz"].replace(".ss", ""); - } - time_12["ahm"] = available_formats["hm"].replace(/H/g, "h"); - time_12["hm"] = available_formats["hm"].replace("\\s?a", "").replace(/H/g, "h"); - } - time_12["hmz"] = time_12["ahmz"].replace("\\s?a", ""); - time_12["ah"] = available_formats["h"]; - time_12["h"] = available_formats["H"].replace(/H/g,"h"); - //} - time_12["m"] = "mm"; - time_12["s"] = "ss"; - time_fmt["12"] = time_12; - time_fmt = JSON.parse(JSON.stringify(time_fmt).replace(/ /g, " ")); - gregorian["time"] = time_fmt; - //util.print("gregorian date formats are :" + JSON.stringify(gregorian.time) + "++++++++++++++++++++++++++++++++++++++++++++" + "\n"); - //code to get the date range - var range = {}; - var intervalFormats = data.dates.calendars[default_calendar]["dateTimeFormats"]["intervalFormats"]; - intervalFormats = JSON.parse(JSON.stringify(intervalFormats).replace(/L/g, "M")); - intervalFormats = JSON.parse(JSON.stringify(intervalFormats).replace(/G/g, "")); - //intervalFormats =JSON.parse(JSON.stringify(intervalFormats).replace(/'[^']+'/, "")); - //util.print("interval formats "+JSON.stringify(intervalFormats)+"++++++++++++++++++++++++++++++++++++++++++++"+"\n"); - //intervalFormats=JSON.parse(JSON.stringify(intervalFormats).replace(/[^.–\s\/Mdy]/g,"")); - //var start_time = intervalFormats["Hm"]["H"].substring(0, intervalFormats["Hm"]["H"].length / 2); - //var end_time = intervalFormats["Hm"]["H"].substring(intervalFormats["Hm"]["H"].length / 2 + 1, intervalFormats["Hm"]["H"].length); - //intervalFormats["Hm"]["H"] = intervalFormats["Hm"]["H"].replace(start_time, ""); - //intervalFormats["Hm"]["H"] = intervalFormats["Hm"]["H"].replace(end_time, ""); - intervalFormats["Hm"]["H"] = intervalFormats["intervalFormatFallback"].charAt((intervalFormats["intervalFormatFallback"].length - 1) / 2); - //util.print("time format after replace "+intervalFormats["Hm"]["H"]+"++++++++++++++++++++++++++++++++++++++++++++"+"\n"); - var ymd_d = intervalFormats["yMd"]["d"]; //.replace(/'[^']+'/g, ""); - var ymd_m = intervalFormats["yMd"]["M"]; //.replace(/'[^']+'/g, ""); - var ymd_y = intervalFormats["yMd"]["y"]; //.replace(/'[^']+'/g, ""); - var ymmmd_d = intervalFormats["yMMMd"]["d"]; //.replace(/'[^']+'/g, ""); - var ymmmd_m = intervalFormats["yMMMd"]["M"]; //.replace(/'[^']+'/g, ""); - var ymmmd_y = intervalFormats["yMMMd"]["y"]; //.replace(/'[^']+'/g, ""); - //var ym_d=intervalFormats["yM"]["d"]; - var ym_m = intervalFormats["yM"]["M"]; //.replace(/'[^']+'/g, ""); - var ym_y = intervalFormats["yM"]["y"]; //.replace(/'[^']+'/g, ""); - //var ymmm_d=intervalFormats["yMMM"]["d"]; - var ymmm_m = intervalFormats["yMMM"]["M"]; //.replace(/'[^']+'/g, ""); - var ymmm_y = intervalFormats["yMMM"]["y"]; //.replace(/'[^']+'/g, ""); - var ymmmm_m = intervalFormats["yMMMM"]["M"]; //.replace(/'[^']+'/g, ""); - var ymmmm_y = intervalFormats["yMMMM"]["y"]; //.replace(/'[^']+'/g, ""); - //for coo - //intervalFormats =JSON.parse(JSON.stringify(intervalFormats).replace(/'[^']+'/g, "")); - var c00 = {}; - var c01 = {}; - var c02 = {}; - var c03 = {}; - var c10 = {}; - var c11 = {}; - var c12 = {}; - var c20 = {}; - var c30 = {}; - //var s_sd = []; - //var s_sm = []; - //var s_sy = []; - //var array=[date["dmy"]["s"],date["dmy"]["m"],date["dmy"]["l"],date["dmy"]["f"]] - var array = [dmy["s"], dmy["m"], dmy["l"], dmy["f"]]; - //var arr_dm = []; - //var arr_y = []; - for (var i = 0; i < array.length; i++) { - - var k; - var arr = array[i].split("'"); - - if (arr.length > 1) { - if (array[i].indexOf("'") != 0) { - k = 0; - } else { - - k = 1; - } - //var count = 0; - - for (; k < arr.length; k = k + 2) { - // count++; - - arr[k] = arr[k].replace(/[d]+/g, "{sd}"); - arr[k] = arr[k].replace(/[M]+/g, "{sm}"); - arr[k] = arr[k].replace(/[y]+/g, "{sy}"); - - } - - array[i] = arr.join(""); - } else { - array[i] = array[i].replace(/[d]+/g, "{sd}"); - array[i] = array[i].replace(/[M]+/g, "{sm}"); - array[i] = array[i].replace(/[y]+/g, "{sy}"); - } - } - /* - for (var i = 0; i < array.length; i++) { - var index_of_st = array[i].indexOf("{st}"); - var index_of_sd = array[i].indexOf("{sd}"); - var index_of_sm = array[i].indexOf("{sm}"); - var index_of_sm = array[i].indexOf("{sy}"); - } - */ - var array_interval_dmy = [ymd_d, ymd_m, ymd_y, ymmmd_d, ymmmd_m, ymmmd_y]; - var start_dmy = []; - var end_dmy = []; - var start_my = []; - var end_my = []; - var index_of_sd, index_of_sm, index_of_sy; - var last_index_of_sd = -1, - last_index_of_sm = -1, - last_index_of_sy = -1; - //var sy=[]; - for (var i = 0; i < array_interval_dmy.length; i++) { - - array_interval_dmy[i] = array_interval_dmy[i].replace(intervalFormats["Hm"]["H"], "–"); - array_interval_dmy[i] = array_interval_dmy[i].replace(/[-]+/g, "–"); - - var k; - var arr = array_interval_dmy[i].split("'"); - - if (arr.length > 1) { - if (array_interval_dmy[i].indexOf("'") != 0) { - k = 0; - } else { - - k = 1; - } - //var count = 0; - - for (; k < arr.length; k = k + 2) { - //count++; - - arr[k] = arr[k].replace(/[^Mdy–.\/\s]/g, ""); - arr[k] = arr[k].replace(/[d]+/g, "{sd}"); - arr[k] = arr[k].replace(/[M]+/g, "{sm}"); - arr[k] = arr[k].replace(/[y]+/g, "{sy}"); - - } - - array_interval_dmy[i] = arr.join(""); - } else { - array_interval_dmy[i] = array_interval_dmy[i].replace(/[^Mdy–.,\/\s]/g, ""); - array_interval_dmy[i] = array_interval_dmy[i].replace(/[d]+/g, "{sd}"); - array_interval_dmy[i] = array_interval_dmy[i].replace(/[M]+/g, "{sm}"); - array_interval_dmy[i] = array_interval_dmy[i].replace(/[y]+/g, "{sy}"); - } - // util.print("array_interval_dmy " + array_interval_dmy[i] + "\n"); - - index_of_sd = array_interval_dmy[i].indexOf("{sd}"); - index_of_sm = array_interval_dmy[i].indexOf("{sm}"); - index_of_sy = array_interval_dmy[i].indexOf("{sy}"); - if (array_interval_dmy[i].indexOf("{sd}") != array_interval_dmy[i].lastIndexOf("{sd}")) { - last_index_of_sd = array_interval_dmy[i].lastIndexOf("{sd}"); - } - if (array_interval_dmy[i].indexOf("{sm}") != array_interval_dmy[i].lastIndexOf("{sm}")) { - last_index_of_sm = array_interval_dmy[i].lastIndexOf("{sm}"); - } - if (array_interval_dmy[i].indexOf("{sy}") != array_interval_dmy[i].lastIndexOf("{sy}")) { - last_index_of_sy = array_interval_dmy[i].lastIndexOf("{sy}"); - } - var arr_min = [ /*index_of_sd,index_of_sm,index_of_sy,*/ last_index_of_sd, last_index_of_sm, last_index_of_sy]; - - var arr_max = [index_of_sd, index_of_sm, index_of_sy]; - var minimum = arr_min.filter(function (x) { - return x >= 0; - }) - .reduce(function (a, b) { - return Math.min(a, b); - }, Infinity); - - var curr = arr_max[0]; - var diff = Math.abs(minimum - curr); - - for (var val = 0; val < arr_max.length; val++) { - var newdiff = Math.abs(minimum - arr_max[val]); - if ((newdiff < diff) && (minimum > arr_max[val])) { - diff = newdiff; - curr = arr_max[val]; - } - } - var maximum = curr; - - // util.print("Minimum Index is :" + minimum + "\n"); - //util.print("Maximum Index is :" + maximum + "\n"); - - separaor_substring = array_interval_dmy[i].substring(maximum + 5, minimum); - // util.print(" separaor_substring" + separaor_substring + "\n"); - index_of_separator = maximum + 5 + separaor_substring.indexOf("–"); - //util.print(" index_of_separator" + index_of_separator + "\n"); - //util.print("start_interval_dmy " + start_dmy[i] + "\n"); - start_dmy[i] = array_interval_dmy[i].substring(0, index_of_separator); - //util.print("start_interval_dmy " + start_dmy[i] + "\n"); - end_dmy[i] = array_interval_dmy[i].substring(1 + index_of_separator, array_interval_dmy[i].length); - end_dmy[i] = end_dmy[i].replace("{sd}", "{ed}"); - end_dmy[i] = end_dmy[i].replace("{sm}", "{em}"); - end_dmy[i] = end_dmy[i].replace("{sy}", "{ey}"); - //end_dmy[i] = end_dmy[i].replace("{sy}", "{ey}"); - //end_dmy[i] = end_dmy[i].replace("{sy}", "{ey}"); - if (start_dmy[i].charAt(start_dmy[i].length - 1) === " ") { - start_dmy[i] = start_dmy[i].slice(0, -1); - intervalFormats["Hm"]["H"] = " " + intervalFormats["Hm"]["H"] + " "; - end_dmy[i] = end_dmy[i].slice(1); - } - - if (start_dmy[i].charAt(0) === " ") { - start_dmy[i] = start_dmy[i].slice(1); - } - - if (end_dmy[i].charAt(0) === "–") { - end_dmy[i] = end_dmy[i].slice(1); - } - //util.print("array_interval_dmy " + array_interval_dmy[i] + "\n"); - // util.print("start_interval_dmy " + i + start_dmy[i] + "\n"); - //util.print("end_interval_dmy " + i + end_dmy[i] + "\n"); - } - last_index_of_sd = -1, last_index_of_sm = -1, last_index_of_sy = -1; - maximum = minimum = 0; - var array_interval_my = [ym_m, ym_y, ymmm_m, ymmm_y, ymmmm_m, ymmmm_y]; - for (var i = 0; i < array_interval_my.length; i++) { - - array_interval_my[i] = array_interval_my[i].replace(intervalFormats["Hm"]["H"], "–"); - array_interval_my[i] = array_interval_my[i].replace(/[-]+/g, "–"); - var k; - var arr = array_interval_my[i].split("'"); - - if (arr.length > 1) { - if (array_interval_my[i].indexOf("'") != 0) { - k = 0; - } else { - - k = 1; - } - //var count = 0; - - for (; k < arr.length; k = k + 2) { - // count++; - - arr[k] = arr[k].replace(/[^Mdy–.\/\s]/g, ""); - arr[k] = arr[k].replace(/[d]+/g, "{sd}"); - arr[k] = arr[k].replace(/[M]+/g, "{sm}"); - arr[k] = arr[k].replace(/[y]+/g, "{sy}"); - - } - - array_interval_my[i] = arr.join(""); - } else { - array_interval_my[i] = array_interval_my[i].replace(/[^Mdy–.\/\s]/g, ""); - //array_interval_my[i] = array_interval_my[i].replace(/[d]+/g, "{sd}"); - array_interval_my[i] = array_interval_my[i].replace(/[M]+/g, "{sm}"); - array_interval_my[i] = array_interval_my[i].replace(/[y]+/g, "{sy}"); - } - //index_of_sd = array_interval_my[i].lastIndexOf("{sd}"); - index_of_sm = array_interval_my[i].indexOf("{sm}"); - index_of_sy = array_interval_my[i].indexOf("{sy}"); - //if ( array_interval_dmy[i].indexOf("{sd}") != array_interval_dmy[i].lastIndexOf("{sd}") ) { - //last_index_of_sd = array_interval_dmy[i].lastIndexOf("{sd}"); - // } - if (array_interval_my[i].indexOf("{sm}") != array_interval_my[i].lastIndexOf("{sm}")) { - last_index_of_sm = array_interval_my[i].lastIndexOf("{sm}"); - } - if (array_interval_my[i].indexOf("{sy}") != array_interval_my[i].lastIndexOf("{sy}")) { - last_index_of_sy = array_interval_my[i].lastIndexOf("{sy}"); - } - var arr_min = [ /*index_of_sd,index_of_sm,index_of_sy,last_index_of_sd,*/ last_index_of_sm, last_index_of_sy]; - - var arr_max = [index_of_sm, index_of_sy]; - minimum = arr_min.filter(function (x) { - return x >= 0; - }) - .reduce(function (a, b) { - return Math.min(a, b); - }, Infinity); - - var curr = arr_max[0]; - var diff = Math.abs(minimum - curr); - //util.print("Minimum Index is :" + minimum + "\n"); - // util.print(" Index of sm is :" + index_of_sm + "\n"); - // util.print(" Index of sy is :" + index_of_sy + "\n"); - //util.print("Maximum Index is :" + maximum + "\n"); - //var maximum = arr_max.filter(function (x) { return x < minimum; }) - // .reduce(function (a, b) { return Math.max(a, b); }, Infinity); - for (var val = 0; val < arr_max.length; val++) { - var newdiff = Math.abs(minimum - arr_max[val]); - if (newdiff < diff) { - diff = newdiff; - curr = arr_max[val]; - } - } - maximum = curr; - // util.print("Maximum Index is :" + maximum + "\n"); - //index_of_separator = array_interval_my[i].indexOf("–"); - //index_of_separator = Math.min(index_of_sd,index_of_sm,index_of_sy); - //start_my[i] = array_interval_my[i].substring(0, index_of_separator); - //end_my[i] = array_interval_my[i].substring(1 + index_of_separator, array_interval_my[i].length); - separaor_substring = array_interval_my[i].substring(maximum + 5, minimum); - //util.print(" separaor_substring" + separaor_substring + "\n"); - index_of_separator = maximum + 5 + separaor_substring.indexOf("–"); - // util.print(" index_of_separator" + index_of_separator + "\n"); - start_my[i] = array_interval_my[i].substring(0, index_of_separator); - //util.print("start_interval_my " + start_my[i] + "\n"); - end_my[i] = array_interval_my[i].substring(1 + index_of_separator, array_interval_my[i].length); - end_my[i] = end_my[i].replace("{sd}", "{ed}"); - end_my[i] = end_my[i].replace("{sm}", "{em}"); - end_my[i] = end_my[i].replace("{sy}", "{ey}"); - /*if (start_my[i].charAt(start_my[i].length - 1) === " ") { - start_my[i] = start_my[i].slice(0, -1); - //intervalFormats["Hm"]["H"] = " "+ intervalFormats["Hm"]["H"] + " "; - end_my[i] = end_my[i].slice(1); - }*/ - - if (start_my[i].charAt(start_my[i].length - 1) === " ") { - start_my[i] = start_my[i].slice(0, -1); - - intervalFormats["Hm"]["H"] = " " + intervalFormats["Hm"]["H"] + " "; - end_my[i] = end_my[i].slice(1); - } - if (end_my[i].charAt(0) === "–") { - end_my[i] = end_my[i].slice(1); - } - //util.print("array_interval_my " + array_interval_my[i] + "\n"); - //util.print("start_interval_my " + start_my[i] + "\n"); - //util.print("end_interval_my " + end_my[i] + "\n"); - } - //c01 - //c01["s"]=array_interval_dmy[0]+ - if (gregorian["order"] === "{time} {date}") { - c00["s"] = "{st}" + intervalFormats["Hm"]["H"] + "{et}" + " " + array[0]; - c00["m"] = "{st}" + intervalFormats["Hm"]["H"] + "{et}" + " " + array[1]; - c00["l"] = "{st}" + intervalFormats["Hm"]["H"] + "{et}" + " " + array[2]; - c00["f"] = "{st}" + intervalFormats["Hm"]["H"] + "{et}" + " " + array[3]; - } else { - c00["s"] = array[0] + " " + "{st}" + intervalFormats["Hm"]["H"] + "{et}"; - c00["m"] = array[1] + " " + "{st}" + intervalFormats["Hm"]["H"] + "{et}"; - c00["l"] = array[2] + " " + "{st}" + intervalFormats["Hm"]["H"] + "{et}"; - c00["f"] = array[3] + " " + "{st}" + intervalFormats["Hm"]["H"] + "{et}"; - } - //for c01 - if (gregorian["order"] === "{time} {date}") { - c01["s"] = "{st}" + " " + start_dmy[0] + intervalFormats["Hm"]["H"] + "{et}" + " " + end_dmy[0]; - c01["l"] = "{st}" + " " + start_dmy[3] + intervalFormats["Hm"]["H"] + "{et}" + " " + end_dmy[3]; - } else { - c01["s"] = start_dmy[0] + " " + "{st}" + intervalFormats["Hm"]["H"] + end_dmy[0] + " " + "{et}"; - c01["l"] = start_dmy[3] + " " + "{st}" + intervalFormats["Hm"]["H"] + end_dmy[3] + " " + "{et}"; - } - c01["m"] = c01["s"]; - c01["f"] = c01["l"]; - //for c02 - if (gregorian["order"] === "{time} {date}") { - c02["s"] = "{st}" + " " + start_dmy[1] + intervalFormats["Hm"]["H"] + "{et}" + " " + end_dmy[1]; - c02["l"] = "{st}" + " " + start_dmy[4] + intervalFormats["Hm"]["H"] + "{et}" + " " + end_dmy[4]; - } else { - c02["s"] = start_dmy[1] + " " + "{st}" + intervalFormats["Hm"]["H"] + end_dmy[1] + " " + "{et}"; - c02["l"] = start_dmy[4] + " " + "{st}" + intervalFormats["Hm"]["H"] + end_dmy[4] + " " + "{et}"; - } - c02["f"] = c02["l"]; - c02["m"] = c02["s"]; - //for c03 - if (gregorian["order"] === "{time} {date}") { - c03["s"] = "{st}" + " " + start_dmy[2] + intervalFormats["Hm"]["H"] + "{et}" + " " + end_dmy[2]; - c03["l"] = "{st}" + " " + start_dmy[5] + intervalFormats["Hm"]["H"] + "{et}" + " " + end_dmy[5]; - } else { - c03["s"] = start_dmy[2] + " " + "{st}" + intervalFormats["Hm"]["H"] + end_dmy[2] + " " + "{et}"; - c03["l"] = start_dmy[5] + " " + "{st}" + intervalFormats["Hm"]["H"] + end_dmy[5] + " " + "{et}"; - } - c03["f"] = c03["l"]; - c03["m"] = c03["s"]; - //for c10 - c10["s"] = start_dmy[0] + intervalFormats["Hm"]["H"] + end_dmy[0]; - c10["l"] = start_dmy[3] + intervalFormats["Hm"]["H"] + end_dmy[3]; - c10["f"] = c10["l"]; - c10["m"] = c10["s"]; - //for c11 - c11["s"] = start_dmy[1] + intervalFormats["Hm"]["H"] + end_dmy[1]; - c11["m"] = c11["s"]; - c11["l"] = start_dmy[4] + intervalFormats["Hm"]["H"] + end_dmy[4]; - c11["f"] = c11["l"]; - //for c12 - c12["s"] = start_dmy[2] + intervalFormats["Hm"]["H"] + end_dmy[2]; - c12["m"] = c12["s"]; - c12["l"] = start_dmy[5] + intervalFormats["Hm"]["H"] + end_dmy[5]; - c12["f"] = c12["l"]; - //for c20 - c20["s"] = start_my[1] + intervalFormats["Hm"]["H"] + end_my[1]; - c20["m"] = c20["s"]; - c20["l"] = start_my[3] + intervalFormats["Hm"]["H"] + end_my[3]; - c20["f"] = start_my[5] + intervalFormats["Hm"]["H"] + end_my[5]; - //for c30 - c30 = "{sy}" + intervalFormats["Hm"]["H"] + "{ey}"; - //var array_intervalcodes=[c00,c01,c02,c10,c11,c12,c20]; - /*for(var i=0;i= 0) { + i += 3; + while (str.charAt(i) === ' ') { + i++; + } + if (i + size <= str.length) { + if (i + size + 1 === str.length) { + return str.substring(0, i + size + 1); + } + return str.substring(0, i + size); + } + return undefined; + } + return undefined; + } + + function clip(shortStr, longStr, size) { + var truncated = undefined; + if (shortStr) { + truncated = truncToSize(shortStr, size); + } + if (truncated) { + return truncated; + } + if (longStr) { + truncated = truncToSize(longStr, size); + } + if (truncated) { + return truncated; + } + return shortStr || longStr; + } + + function clipForMedium(shortStr, longStr) { + return clip(shortStr, longStr, 2); + } + + function clipForLong(longStr) { + return clip(longStr, undefined, 3); + } + var durationPropertiesFull = { + "second": "1#1 second|#{num} seconds", + "minute": "1#1 minute|#{num} minutes", + "hour": "1#1 hour|#{num} hours", + "day": "1#1 day|#{num} days", + "week": "1#1 week|#{num} weeks", + "month": "1#1 month|#{num} months", + "year": "1#1 year|#{num} years" + }; + var durationPropertiesLong = { + "second": "1#1 sec|#{num} sec", + "minute": "1#1 min|#{num} min", + "hour": "1#1 hr|#{num} hrs", + "day": "durationLongDays", + "week": "1#1 wk|#{num} wks", + "month": "1#1 mon|#{num} mons", + "year": "1#1 yr|#{num} yrs" + }; + var durationPropertiesMedium = { + "second": "1#1 se|#{num} sec", + "minute": "1#1 mi|#{num} min", + "hour": "durationMediumHours", + "day": "1#1 dy|#{num} dys", + "week": "durationMediumWeeks", + "month": "1#1 mo|#{num} mos", + "year": "durationMediumYears" + }; + var durationPropertiesShort = { + "second": "#{num}s", + "minute": "durationShortMinutes", + "hour": "#{num}h", + "day": "#{num}d", + "week": "#{num}w", + "month": "durationShortMonths", + "year": "#{num}y" + }; + table = data.units; + for (duration in durationPropertiesMedium) { + if (duration && durationPropertiesMedium[duration]) { + var unit = table[duration]; + var shortStr = unit["unitPattern-count-one"]; + if (!shortStr) { + shortStr = unit["unitPattern-count-other"]; + } + if (shortStr) { + var unitOnly = shortStr.replace("{0}", ""); + var initial = unitOnly.trim().charAt(0); + shortStr = shortStr.replace(unitOnly, initial).replace("{0}", "{num}"); + if (shortStr.length > 0) { + sysres[durationPropertiesShort[duration]] = "#" + shortStr; + } + } + var mediumOther = "", + longOther = "", + fullOther = ""; + var temp, mediumClipped, longClipped, mediumStr = "", + longStr = "", + fullStr = ""; + if (typeof (unit["unitPattern-count-other-alt-short"]) !== 'undefined') { + mediumOther = clipForMedium( + unit["unitPattern-count-other-alt-short"], + unit["unitPattern-count-other"]); + } + if (typeof (unit["unitPattern-count-other"]) !== 'undefined') { + longOther = clipForLong(unit["unitPattern-count-other"]); + fullOther = unit["unitPattern-count-other"]; + } + var unitNames = [ + "0", + "1", + "zero", + "one", + "two", + "few", + "many" + ]; + for (var j = 0; j < unitNames.length; j++) { + name = unitNames[j]; + mediumClipped = clipForMedium( + unit["unitPattern-count-" + name + "-alt-short"], + unit["unitPattern-count-" + name]); + if (typeof (unit["unitPattern-count-" + name + "-alt-short"]) !== 'undefined' && + mediumClipped !== mediumOther) { + if (mediumStr.length > 0) { + mediumStr += "|"; + } + temp = mediumClipped.replace("{0}", "{num}"); + mediumStr += name + "#" + temp; + } + longClipped = clipForLong(unit["unitPattern-count-" + name]); + if (typeof (unit["unitPattern-count-" + name]) !== 'undefined' && + longClipped !== longOther) { + if (longStr.length > 0) { + longStr += "|"; + } + temp = longClipped.replace("{0}", "{num}"); + longStr += name + "#" + temp; + } + if (typeof (unit["unitPattern-count-" + name]) !== 'undefined' && + unit["unitPattern-count-" + name] !== fullOther) { + if (fullStr.length > 0) { + fullStr += "|"; + } + fullStr += name + "#" + unit["unitPattern-count-" + name].replace("{0}", "{num}"); + } + } + if (typeof (unit["unitPattern-count-other-alt-short"]) !== 'undefined') { + if (mediumStr.length > 0) { + mediumStr += "|"; + } + temp = clipForMedium(unit["unitPattern-count-other-alt-short"], unit["unitPattern-count-other"]).replace("{0}", "{num}"); + mediumStr += "#" + temp; + } + if (typeof (unit["unitPattern-count-other"]) !== 'undefined') { + if (longStr.length > 0) { + longStr += "|"; + } + if (fullStr.length > 0) { + fullStr += "|"; + } + temp = clipForLong(unit["unitPattern-count-other"]).replace("{0}", "{num}"); + longStr += "#" + temp; + fullStr += "#" + unit["unitPattern-count-other"].replace("{0}", "{num}"); + } + if (mediumStr.length > 0) { + sysres[durationPropertiesMedium[duration]] = mediumStr; + } + if (longStr.length > 0) { + sysres[durationPropertiesLong[duration]] = longStr; + } + if (fullStr.length > 0) { + sysres[durationPropertiesFull[duration]] = fullStr; + } + } + } + unit = table; + str = ""; + if (typeof (unit["day-past"]["unitPattern-count-one"]) !== 'undefined' || typeof (unit["day-past"]["unitPattern-count-other"]) !== 'undefined') { + var day = table["day"]["unitPattern-count-one"] || table["day"]["unitPattern-count-other"]; + var dayPast = table["day-past"]["unitPattern-count-one"] || table["day-past"]["unitPattern-count-other"]; + //console.log("day"+ dayPast); + //console.log("dayPast"+ dayPast); + if (dayPast.indexOf(day) != -1) { + sysres["{duration} ago"] = dayPast.replace(day, "{duration}").toLowerCase(); + } else { + /* var dayPast_few = table["day-past"]["unitPattern-count-few"] || table["day-past"]["unitPattern-count-other"]; + if (dayPast_few != dayPast) { + dayPast_few = dayPast_few.replace("{0}", ""); + dayPast = dayPast.replace("{0}", ""); + arr_dayPast_few = dayPast_few.split(" "); + arr_dayPast = dayPast.split(" "); + var mismatch; + for (var i = 0; i < arr_dayPast.length; i++) { + if (arr_dayPast_few[i] != arr_dayPast[i]) { + mismatch = arr_dayPast[i]; + } + }*/ + //if(language === "th"){ + //console.log("dayPast"+ dayPast); + //console.log("dayPast_few"+ dayPast_few); + //console.log("mismatch"+ mismatch); + //} + //sysres["{duration} ago"] = dayPast.replace(mismatch, "{duration}").toLowerCase(); + // sysres["{duration} ago"] = sysres["{duration} ago"].replace(" ", " "); + //if (sysres["{duration} ago"].indexOf("{duration}") === -1) { + //sysres["{duration} ago"] = "XXXXX"; + //} + //} else { + sysres["{duration} ago"] = "-{duration}"; + // } + } + } + + + unit = table; + str = ""; + if (typeof (table["day-future"]["unitPattern-count-one"]) !== 'undefined' || typeof (table["day-future"]["unitPattern-count-other"]) !== 'undefined') { + var day = table["day"]["unitPattern-count-one"] || table["day"]["unitPattern-count-other"]; + var dayFuture = table["day-future"]["unitPattern-count-one"] || table["day-future"]["unitPattern-count-other"]; + if (dayFuture.indexOf(day) != -1) { + sysres["in {duration}"] = dayFuture.replace(day, "{duration}").toLowerCase(); + } else { + /* var dayFuture_few = table["day-future"]["unitPattern-count-few"] || table["day-future"]["unitPattern-count-other"]; + if (dayFuture_few != dayFuture) { + dayFuture_few = dayFuture_few.replace("{0}", ""); + dayFuture = dayFuture.replace("{0}", ""); + arr_dayFuture_few = dayFuture_few.split(" "); + arr_dayFuture = dayFuture.split(" "); + var mismatch; + for (var i = 0; i < arr_dayFuture.length; i++) { + if (arr_dayFuture_few[i] != arr_dayFuture[i]) { + mismatch = arr_dayFuture[i]; + } + } + sysres["in {duration}"] = dayFuture.replace(mismatch, "{duration}").toLowerCase(); + sysres["in {duration}"] = sysres["in {duration}"].replace(" ", " "); + if (sysres["in {duration}"].indexOf("{duration}") === -1) { + sysres["in {duration}"] = "XXXXX"; + }*/ + // } else { + sysres["in {duration}"] = "+{duration}"; + //} + } + } + var listProperties = { + "separatorFull": "middle", + "finalSeparatorFull": "end" + }; + table = data.listPatterns.listPattern; + for (pattern in listProperties) { + if (pattern && listProperties[pattern]) { + var unit = table[listProperties[pattern]]; + if (unit.length > 0) { + sysres[pattern] = unit.replace(/\{.\}/g, ""); + } + } + } + sysres["separatorShort"] = " "; + sysres["separatorMedium"] = " "; + sysres["separatorLong"] = " "; + return sysres; +} +//code getting implemented + +function anyProperties(data) { + var count = 0; + for (var prop in data) { + if (prop && data[prop]) { + count++; + } + if (count > 1) { + return true; + } + } + return false; +} + +function writeSystemResources(language, script, region, data) { + var path = calcLocalePath(language, script, region, ""); + if (data.generated) { + if (anyProperties(data)) { + console.log("Writing " + path); + makeDirs(path); + fs.writeFileSync(path + "/sysres.json", JSON.stringify(data, true, 4), "utf-8"); + } else { + console.log("Skipping empty " + path); + } + } else { + console.log("Skipping existing " + path); + } +} +// for each locale, get the data +var language, region, script, file, + files = fs.readdirSync(cldrDirName + "/main/"); +console.log("Reading locale data into memory..."); +for (var i = 0; i < files.length; i++) { + file = files[i]; + if (file === "root.json") { + // special case because "root" is not a valid locale specifier + getLocaleData(file, undefined, undefined, undefined); + } else { + locale = file.split(/\./)[0].replace(/_/g, "-"); + var l = new Locale(locale); + if (typeof (l.getVariant()) === 'undefined') { + getLocaleData(file, l.getLanguage(), l.getScript(), l.getRegion()); + } + } +} +console.log(""); +// find the system resources +console.log("Merging and pruning locale data..."); +mergeAndPrune(localeData); +var resources = {}; +var resources_dateformat_data = {}; +console.log("\nCalculating system resources..."); +resources.data = getSystemResources(undefined, undefined, undefined, localeData.data); +//resources_dateformat_data=resources.data; +for (language in localeData) { + if (language && localeData[language] && language !== 'data' && language !== 'merged') { + resources[language] = resources[language] || {}; + console.log(language + " "); + for (var subpart in localeData[language]) { + if (subpart && localeData[language][subpart] && subpart !== 'data' && subpart !== 'merged') { + resources[language][subpart] = resources[language][subpart] || {}; + if (Locale.isScriptCode(subpart)) { + script = subpart; + for (region in localeData[language][script]) { + resources[language][script][region] = resources[language][script][region] || {}; + if (region && localeData[language][script][region] && region !== 'data' && region !== 'merged') { + resources[language][script][region].data = getSystemResources(language, script, region, localeData[language][script][region].merged); + } + } + } + resources[language][subpart].data = getSystemResources(language, subpart, undefined, localeData[language][subpart].merged); + } + } + resources[language].data = getSystemResources(language, undefined, undefined, localeData[language].merged); + } +} +console.log("\nMerging and pruning resources..."); +mergeAndPrune(resources); +console.log("\nWriting system resources..."); + +for (language in resources) { + if (language && resources[language] && language !== 'data' && language !== 'merged') { + for (var subpart in resources[language]) { + if (subpart && resources[language][subpart] && subpart !== 'data' && subpart !== 'merged') { + if (Locale.isScriptCode(subpart)) { + script = subpart; + for (region in resources[language][script]) { + if (region && resources[language][script][region] && region !== 'data' && region !== 'merged') { + writeSystemResources(language, script, region, resources[language][script][region].data); + } + } + writeSystemResources(language, script, undefined, resources[language][script].data); + } else { + writeSystemResources(language, undefined, subpart, resources[language][subpart].data); + } + } + } + writeSystemResources(language, undefined, undefined, resources[language].data); + } +} +writeSystemResources(undefined, undefined, undefined, resources.data); + +resources_dateformat_data.data = getDateFormats(undefined, undefined, undefined, localeData.data); +for (language in localeData) { + if (language && localeData[language] && language !== 'data' && language !== 'merged') { + resources_dateformat_data[language] = resources_dateformat_data[language] || {}; + console.log(language + " "); + for (var subpart in localeData[language]) { + if (subpart && localeData[language][subpart] && subpart !== 'data' && subpart !== 'merged') { + resources_dateformat_data[language][subpart] = resources_dateformat_data[language][subpart] || {}; + if (Locale.isScriptCode(subpart)) { + script = subpart; + for (region in localeData[language][script]) { + resources_dateformat_data[language][script][region] = resources_dateformat_data[language][script][region] || {}; + if (region && localeData[language][script][region] && region !== 'data' && region !== 'merged') { + resources_dateformat_data[language][script][region].data = getDateFormats(language, script, region, localeData[language][script][region].merged); + } + } + } + resources_dateformat_data[language][subpart].data = getDateFormats(language, subpart, undefined, localeData[language][subpart].merged); + } + } + resources_dateformat_data[language].data = getDateFormats(language, undefined, undefined, localeData[language].merged); + } +} +console.log("\nMerging and pruning data for dateformats."); +mergeAndPrune(resources_dateformat_data); + +function getDateFormats(language, script, region, data) { + // if it is already there and non-generated, return it + var dates = loadFileNonGenerated(language, script, region, "dateformats.json"); + // console.log("language: " + language); + // console.log("script: " + script); + // console.log("region: " + region); + if (dates && (typeof (dates.generated) === 'undefined' || !dates.generated)) { + console.log("\nLoaded existing dateformats from " + calcLocalePath(language, script, region, "dateformats.json")); + dates.generated = false; + return dates; + } + // else generate a new one + dates = { + generated: true + }; + var default_calendar = data.dates.calendars["default"]; + //console.log("default calendar is :" + default_calendar); + var gregorian_order = data.dates.calendars[default_calendar]["dateTimeFormats"]["full"]["dateTimeFormat"]["pattern"]; + //console.log("default format is :" + JSON.stringify(gregorian_order_formats)); + //var gregorian_order_full = gregorian_order_formats[full] ;//full"]["dateTimeFormat"]["pattern"]; + //var gregorian_order = gregorian_order_full["dateTimeFormat"]["pattern"]; + //console.log("default calendar format pattern is " + gregorian_order); + var gregorian = {}; + //var output = {}; + //output["gregorian"]="gregorian"; + if (gregorian_order == "{0} {1}") { + //console.log("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"); + gregorian["order"] = "{date} {time}"; + } else { + gregorian["order"] = "{time} {date}"; + } + //console.log("gregorian calendar order is :" + gregorian["order"]); + var date_formats = data.dates.calendars[default_calendar]["dateFormats"]; + var available_formats = data.dates.calendars[default_calendar]["dateTimeFormats"]["availableFormats"]; + // console.log("available formats are :" + JSON.stringify(available_formats) + "+++++++++++++++++++++"); + available_formats = JSON.parse(JSON.stringify(available_formats).replace(/L/g, "M")); + available_formats = JSON.parse(JSON.stringify(available_formats).replace(/G/g, "")); + //available_formats = JSON.parse(JSON.stringify(available_formats).replace(/'[^']+'/g, "")); + //console.log("available formats after conversion :" + JSON.stringify(available_formats) + "++++++++++++++++++++++++++++++++++++++++++++"); + var keys_dateformats = Object.keys(available_formats); + //var values_dateformats = JSON.stringify(keys_dateformats); + var arr_values = []; + //console.log("date fomat keys are :" + keys_dateformats + "*********************************"); + for (var i = 0; i < keys_dateformats.length; i++) { + arr_values[i] = available_formats[keys_dateformats[i]]; + + } + //console.log("date fomat keys are :" + JSON.stringify(arr_values) + "*********************************"); + + + var date = {}; + var dm = {}; + var dmwy = {}; + var dmy = {}; + var dmw = {}; + var my = {}; + var d = {}; + var m = {}; + var y = {}; + var n = {}; + //for (var i=0;i arr_values[j].indexOf("d")) ? (arr_values[j].substring(arr_values[j].indexOf("d"), 1 + arr_values[j].lastIndexOf( + "M"))) : (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf("d"))); + //} + flag = true; + break; + } + } + if (flag == false) { + var short = date_formats["short"]["dateFormat"]["pattern"]; + dm["s"] = (short.indexOf("d") < short.indexOf("M")) ? short.substring(short.indexOf("d"), 1 + short.lastIndexOf("M")) : short.substring(short.indexOf("M"), + 1 + short.lastIndexOf("d")); + } + } + //end of short + if (available_formats["MMdd"] || available_formats["MMd"]) { + //if(available_formats["MMdd"]!=undefined) + //{ + dm["m"] = available_formats["MMdd"] || available_formats["MMd"]; + //} + //else + //dm["m"]=available_formats["MMd"]; + } else if ((available_formats["MMdd"] === undefined) && (available_formats["MMd"] === undefined)) { + var flag = false; + for (var j = 0; j < arr_values.length; j++) { + if (((arr_values[j].split("M").length - 1) == 2) && ((arr_values[j].split("d").length - 1) >= 1)) { + dm["m"] = (arr_values[j].indexOf("M") > arr_values[j].indexOf("d")) ? (arr_values[j].substring(arr_values[j].indexOf("d"), 1 + arr_values[j].indexOf("M"))) : + (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf("d"))); + flag = true; + break; + } + } + if (flag == false) { + var medium = date_formats["medium"]["dateFormat"]["pattern"]; + dm["m"] = (medium.indexOf("M") < medium.indexOf("d")) ? medium.substring(medium.indexOf("M"), 1 + medium.lastIndexOf("d")) : medium.substring(medium.indexOf( + "d"), 1 + medium.lastIndexOf("M")); + } + } + if (available_formats["MMMd"] || available_formats["MMMdd"]) { + dm["l"] = available_formats["MMMd"] || available_formats["MMMdd"]; + } else if ((available_formats["MMMdd"] === undefined) && (available_formats["MMMd"] === undefined)) { + var flag = false; + for (var j = 0; j < arr_values.length; j++) { + if (((arr_values[j].split("M").length - 1) == 3) && ((arr_values[j].split("d").length - 1) >= 1)) { + dm["l"] = (arr_values[j].indexOf("M") > arr_values[j].indexOf("d")) ? (arr_values[j].substring(arr_values[j].indexOf("d"), 1 + arr_values[j].lastIndexOf( + "M"))) : (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf("d"))); + flag = true; + break; + } + } + if (flag == false) { + var long = date_formats["long"]["dateFormat"]["pattern"]; + dm["l"] = (long.indexOf("M") < long.indexOf("d")) ? long.substring(long.indexOf("M"), 1 + long.lastIndexOf("d")) : (long.substring(long.indexOf("d"), 1 + + long.lastIndexOf("M"))); + } + } + if (available_formats["MMMMd"] || available_formats["MMMMdd"]) { + dm["f"] = available_formats["MMMMd"] || available_formats["MMMMdd"]; + } else if ((available_formats["MMMMdd"] === undefined) && (available_formats["MMMMd"] === undefined)) { + var flag = false; + for (var j = 0; j < arr_values.length; j++) { + if (((arr_values[j].split("M").length - 1) == 4) && ((arr_values[j].split("d").length - 1) >= 1)) { + dm["f"] = (arr_values[j].indexOf("M") > arr_values[j].indexOf("d")) ? (arr_values[j].substring(arr_values[j].indexOf("d"), 1 + arr_values[j].lastIndexOf( + "M"))) : (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf("d"))); + flag = true; + break; + } + } + if (flag == false) { + var full = date_formats["long"]["dateFormat"]["pattern"]; + dm["f"] = full.indexOf("M") < (full.indexOf("d")) ? full.substring(full.indexOf("M"), 1 + full.lastIndexOf("d")) : full.substring(full.indexOf("d"), 1 + + full.lastIndexOf("M")); + } + } + //end of combination dm + if (available_formats["yM"] || available_formats["yyM"] || available_formats["yyyyM"]) { + my["s"] = available_formats["yM"] || available_formats["yyM"] || available_formats["yyyyM"]; + } else if ((available_formats["yM"] === undefined) && (available_formats["yyM"] === undefined) && (available_formats["yyyyM"] === undefined)) { + var flag = false; + for (var j = 0; j < arr_values.length; j++) { + if (((arr_values[j].split("M").length - 1) == 1) && ((arr_values[j].split("y").length - 1) >= 1)) { + my["s"] = (arr_values[j].indexOf("y") > arr_values[j].indexOf("M")) ? (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf( + "y"))) : (arr_values[j].substring(arr_values[j].indexOf("y"), 1 + arr_values[j].lastIndexOf("M"))); + flag = true; + break; + } + } + if (flag == false) { + var short = date_formats["short"]["dateFormat"]["pattern"]; + my["s"] = (short.indexOf("M") < short.indexOf("y")) ? short.substring(short.indexOf("M"), 1 + short.lastIndexOf("y")) : short.substring(short.indexOf("y"), + 1 + short.lastIndexOf("M")); + } + } + if (available_formats["yyyyMM"] || available_formats["yyMM"] || available_formats["yMM"]) { + my["m"] = available_formats["yyyyMM"] || available_formats["yyMM"] || available_formats["yMM"]; + } else if ((available_formats["yMM"] === undefined) && (available_formats["yyMM"] === undefined) && (available_formats["yyyyMM"] === undefined)) { + var flag = false; + for (var j = 0; j < arr_values.length; j++) { + if (((arr_values[j].split("M").length - 1) == 2) && ((arr_values[j].split("y").length - 1) >= 1)) { + my["m"] = (arr_values[j].indexOf("y") > arr_values[j].indexOf("M")) ? (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf( + "y"))) : (arr_values[j].substring(arr_values[j].indexOf("y"), 1 + arr_values[j].lastIndexOf("M"))); + flag = true; + break; + } + } + if (flag == false) { + var medium = date_formats["medium"]["dateFormat"]["pattern"]; + my["m"] = medium.indexOf("M") < medium.indexOf("y") ? medium.substring(medium.indexOf("M"), 1 + medium.lastIndexOf("y")) : medium.substring(medium.indexOf( + "y"), 1 + medium.lastIndexOf("M")); + } + } + if (available_formats["yMMM"] || available_formats["yyMMM"] || available_formats["yyyyMMM"]) { + my["l"] = available_formats["yMMM"] || available_formats["yyMMM"] || available_formats["yyyyMMM"]; + } else if ((available_formats["yMMM"] === undefined) && (available_formats["yyMMM"] === undefined) && (available_formats["yyyyMMM"] === undefined)) { + var flag = false; + for (var j = 0; j < arr_values.length; j++) { + if (((arr_values[j].split("M").length - 1) == 3) && ((arr_values[j].split("y").length - 1) >= 1)) { + my["l"] = (arr_values[j].indexOf("y") > arr_values[j].indexOf("M")) ? (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf( + "y"))) : (arr_values[j].substring(arr_values[j].indexOf("y"), 1 + arr_values[j].lastIndexOf("M"))); + flag = true; + break; + } + } + if (flag == false) { + var long = date_formats["long"]["dateFormat"]["pattern"]; + my["l"] = (long.indexOf("M") < long.indexOf("y")) ? long.substring(long.indexOf("M"), 1 + long.lastIndexOf("y")) : long.substring(long.indexOf("y"), 1 + + long.lastIndexOf("M")); + } + } + if (available_formats["yyyyMMMM"] || available_formats["yyMMMM"] || available_formats["yMMMM"]) { + my["f"] = available_formats["yyyyMMMM"] || available_formats["yyMMMM"] || available_formats["yMMMM"]; + } else if ((available_formats["yyyyMMMM"] === undefined) && (available_formats["yyMMMM"] === undefined) && (available_formats["yMMMM"] === undefined)) { + var flag = false; + for (var j = 0; j < arr_values.length; j++) { + if (((arr_values[j].split("M").length - 1) == 4) && ((arr_values[j].split("y").length - 1) >= 1)) { + my["f"] = (arr_values[j].indexOf("y") > arr_values[j].indexOf("M")) ? (arr_values[j].substring(arr_values[j].indexOf("M"), 1 + arr_values[j].lastIndexOf( + "y"))) : (arr_values[j].substring(arr_values[j].indexOf("y"), 1 + arr_values[j].lastIndexOf("M"))); + flag = true; + break; + } + } + if (flag == false) { + var full = date_formats["full"]["dateFormat"]["pattern"]; + my["f"] = (full.indexOf("M") < full.indexOf("y")) ? full.substring(full.indexOf("M"), 1 + full.lastIndexOf("y")) : full.substring(full.indexOf("y"), 1 + + full.lastIndexOf("M")); + } + } + //end of my combination + if (available_formats["yyyyMd"] || available_formats["yMd"]) { + dmy["s"] = available_formats["yyyyMd"] || available_formats["yMd"]; + } else if (available_formats["yyyyMd"] === undefined) { + var flag = false; + for (var j = 0; j < arr_values.length; j++) { + if (((arr_values[j].split("M").length - 1) == 1) && ((arr_values[j].split("y").length - 1) >= 1) && ((arr_values[j].split("d").length - 1) >= 1)) { + index_of_d = arr_values[j].indexOf("d"); + index_of_m = arr_values[j].indexOf("M"); + index_of_y = arr_values[j].indexOf("y"); + var max_index = Math.max(index_of_d, index_of_m, index_of_y); + var min_index = Math.min(index_of_d, index_of_m, index_of_y); + dmy["s"] = arr_values[j].substring(min_index, 1 + arr_values[j].lastIndexOf(arr_values[j].charAt(max_index))); + flag = true; + break; + } + } + if (flag == false) { + var short = date_formats["short"]["dateFormat"]["pattern"]; + index_of_d = short.indexOf("d"); + index_of_m = short.indexOf("M"); + index_of_y = short.indexOf("y"); + var max_index = Math.max(index_of_d, index_of_m, index_of_y); + var min_index = Math.min(index_of_d, index_of_m, index_of_y); + dmy["s"] = short.substring(min_index, 1 + short.lastIndexOf(short.charAt(max_index))); + } + } + if (available_formats["yyMMdd"]) { + dmy["m"] = available_formats["yyMMdd"]; + } else if (available_formats["yyMMdd"] === undefined) { + var flag = false; + for (var j = 0; j < arr_values.length; j++) { + if (((arr_values[j].split("M").length - 1) == 2) && ((arr_values[j].split("y").length - 1) >= 1) && ((arr_values[j].split("d").length - 1) >= 1)) { + index_of_d = arr_values[j].indexOf("d"); + index_of_m = arr_values[j].indexOf("M"); + index_of_y = arr_values[j].indexOf("y"); + var max_index = Math.max(index_of_d, index_of_m, index_of_y); + var min_index = Math.min(index_of_d, index_of_m, index_of_y); + dmy["m"] = arr_values[j].substring(min_index, 1 + arr_values[j].lastIndexOf(arr_values[j].charAt(max_index))); + flag = true; + break; + } + } + if (flag == false) { + var medium = date_formats["medium"]["dateFormat"]["pattern"]; + index_of_d = medium.indexOf("d"); + index_of_m = medium.indexOf("M"); + index_of_y = medium.indexOf("y"); + var max_index = Math.max(index_of_d, index_of_m, index_of_y); + var min_index = Math.min(index_of_d, index_of_m, index_of_y); + dmy["m"] = medium.substring(min_index, 1 + medium.lastIndexOf(medium.charAt(max_index))); + } + } + if (available_formats["yyMMMd"] || available_formats["yyyyMMMd"] || available_formats["yMMMd"]) { + dmy["l"] = available_formats["yyMMMd"] || available_formats["yyyyMMMd"] || available_formats["yMMMd"]; + } else if ((available_formats["yyMMMd"] === undefined) && (available_formats["yyyyMMMd"] === undefined) && (available_formats["yMMMd"] === undefined)) { + var flag = false; + for (var j = 0; j < arr_values.length; j++) { + if (((arr_values[j].split("M").length - 1) == 3) && ((arr_values[j].split("y").length - 1) >= 1) && ((arr_values[j].split("d").length - 1) >= 1)) { + index_of_d = arr_values[j].indexOf("d"); + index_of_m = arr_values[j].indexOf("M"); + index_of_y = arr_values[j].indexOf("y"); + var max_index = Math.max(index_of_d, index_of_m, index_of_y); + var min_index = Math.min(index_of_d, index_of_m, index_of_y); + dmy["l"] = arr_values[j].substring(min_index, 1 + arr_values[j].lastIndexOf(arr_values[j].charAt(max_index))); + flag = true; + break; + } + } + if (flag == false) { + var long = date_formats["long"]["dateFormat"]["pattern"]; + index_of_d = long.indexOf("d"); + index_of_m = long.indexOf("M"); + index_of_y = long.indexOf("y"); + var max_index = Math.max(index_of_d, index_of_m, index_of_y); + var min_index = Math.min(index_of_d, index_of_m, index_of_y); + dmy["l"] = long.substring(min_index, 1 + long.lastIndexOf(long.charAt(max_index))); + } + } + if (available_formats["yMMMMd"]) { + dmy["f"] = available_formats["yMMMMd"]; + } else if (available_formats["yMMMMd"] === undefined) { + var flag = false; + for (var j = 0; j < arr_values.length; j++) { + if (((arr_values[j].split("M").length - 1) == 4) && ((arr_values[j].split("y").length - 1) >= 1) && ((arr_values[j].split("d").length - 1) >= 1)) { + index_of_d = arr_values[j].indexOf("d"); + index_of_m = arr_values[j].indexOf("M"); + index_of_y = arr_values[j].indexOf("y"); + var max_index = Math.max(index_of_d, index_of_m, index_of_y); + var min_index = Math.min(index_of_d, index_of_m, index_of_y); + dmy["f"] = arr_values[j].substring(min_index, 1 + arr_values[j].lastIndexOf(arr_values[j].charAt(max_index))); + flag = true; + break; + } + } + if (flag == false) { + var full = date_formats["full"]["dateFormat"]["pattern"]; + index_of_d = full.indexOf("d"); + index_of_m = full.indexOf("M"); + index_of_y = full.indexOf("y"); + var max_index = Math.max(index_of_d, index_of_m, index_of_y); + var min_index = Math.min(index_of_d, index_of_m, index_of_y); + dmy["f"] = full.substring(min_index, 1 + full.lastIndexOf(full.charAt(max_index))); + } + } + //console.log("DMY combination"+JSON.stringify(dmy)); + //end of dmy combination + if (available_formats["d"]) { + d["s"] = available_formats["d"]; + d["s"] = d["s"].replace(/\./, ""); + d["m"] = d["l"] = d["f"] = d["s"]; + } + if (available_formats["d"] === undefined) { + //var flag=false; + for (var j = 0; j < arr_values.length; j++) { + if ((arr_values[j].split("d").length - 1) == 1) { + d["s"] = "d"; + d["m"] = "d"; + d["l"] = "d"; + d["f"] = "d"; + break; + } + } + } + //if(d["s"]!="d") + //{ + for (var j = 0; j < arr_values.length; j++) { + if ((arr_values[j].split("d").length - 1) == 2) { + if (d["s"] != "d") { + d["s"] = "dd"; + } + d["m"] = "dd"; + d["l"] = "dd"; + d["f"] = "dd"; + break; + } + } + + //d = JSON.stringify(d).replace(/./g,""); + //} + //} + //end of d combination + if (available_formats["M"]) { + m["s"] = available_formats["M"]; + m["s"] = m["l"] = m["m"] = m["f"]; + } else if (available_formats["M"] === undefined) { + //var flag=false; + for (var j = 0; j < arr_values.length; j++) { + if ((arr_values[j].split("M").length - 1) == 1) { + m["s"] = "M"; + m["m"] = "M"; + m["l"] = "M"; + m["f"] = "M"; + break; + } + } + } + //if(m["s"]!="M") + //{ + for (var j = 0; j < arr_values.length; j++) { + if ((arr_values[j].split("M").length - 1) == 2) { + if (m["s"] != "M") { + m["s"] = "MM"; + } + m["m"] = "MM"; + m["l"] = "MM"; + m["f"] = "MM"; + break; + } + } + //} + if (available_formats["MMM"]) { + m["l"] = available_formats["MMM"]; + m["f"] = m["l"]; + } else if (available_formats["MMM"] === undefined) { + for (var j = 0; j < arr_values.length; j++) { + if ((arr_values[j].split("M").length - 1) == 3) { + m["l"] = "MMM"; + m["f"] = "MMM"; + break; + } + } + } + //if(m["l"]!="MMM") + //{ + for (var j = 0; j < arr_values.length; j++) { + if ((arr_values[j].split("M").length - 1) == 4) { + if (m["l"] != "MMM") { + m["l"] = "MMMM"; + } + m["f"] = "MMMM"; + //d["l"]="dd"; + //d["f"]="dd"; + break; + } + } + //} + //end of m combination + if (available_formats["y"]) { + //console.log("debugging"); + y["s"] = available_formats["y"]; + y["s"] = y["m"] = y["l"] = y["f"]; + //console.log("year format is " +JSON.stringify(y)); + } + //if(y["s"]!="y") + //{ + for (var j = 0; j < arr_values.length; j++) { + if ((arr_values[j].split("y").length - 1) == 2) { + //if (y["s"] != "y") { + y["s"] = "yy"; + //} + y["m"] = "yy"; + break; + } else { + y["s"] = y["m"] = "yyyy"; + } + } + + y["l"] = "yyyy"; + y["f"] = "yyyy"; + + + + //console.log("year format is " +JSON.stringify(y)); + //end of y combination + if (available_formats["MEd"]) { + dmw["s"] = available_formats["MEd"]; + dmw["m"] = available_formats["MEd"].replace(/E+/g, "EE"); + } else if (available_formats["MEd"] === undefined) { + dmw["s"] = "E" + " " + dm["s"]; + dmw["m"] = "EE" + " " + dm["m"]; + } + //dmw["m"]="E"+dm["s"]; + if (available_formats["MMMEd"]) { + dmw["l"] = available_formats["MMMEd"].replace(/E+/g, "EEEE");; + dmw["f"] = available_formats["MMMEd"].replace(/E+/g, "EEEE"); + } else if (available_formats["MMMEd"] === undefined) { + dmw["l"] = "EEE" + " " + dm["l"]; + dmw["f"] = "EEEE" + " " + dm["f"]; + } + //dmw["l"]="EEE"+dm["l"]; + //end of dmw + if (available_formats["yMEd"]) { + dmwy["s"] = available_formats["yMEd"]; + dmwy["m"] = available_formats["yMEd"].replace(/E+/g, "EE"); + } else if (available_formats["yMEd"] === undefined) { + dmw["s"] = "EE" + " " + dmy["s"]; + } + if (available_formats["yMMMEd"]) { + dmwy["l"] = available_formats["yMMMEd"].replace(/E+/g, "EEE"); + dmwy["f"] = available_formats["yMMMEd"].replace(/E+/g, "EEEE"); + } else if (available_formats["yMMMEd"] === undefined) { + dmwy["l"] = "EEE" + " " + dmy["l"]; + dmwy["f"] = "EEEE" + " " + dmy["f"]; + } + n["s"] = "N"; + n["m"] = "N"; + n["l"] = "MMM"; + n["f"] = "MMMM"; + //} + /* var allkeys_datefmts = [dm, my, dmy, d, m, y, dmw, dmwy]; + for (var i = 0; i < allkeys_datefmts.length; i++) { + var array_keys = Object.keys(allkeys_datefmts[i]); + for (var j = 0; j < array_keys.length; j++) { + if (typeof (allkeys_datefmts[i][array_keys[j]]) === 'undefined') { + allkeys_datefmts[i][array_keys[j]] = "XXXXX"; + } + } + }*/ + + var keys_datefmts = [my, dmy, y, dmwy]; + //var values_dateformats = JSON.stringify(keys_dateformats); + //var datefmt_values = []; + //console.log("date fomat keys are :" + keys_dateformats + "*********************************"); + for (var i = 0; i < keys_datefmts.length; i++) { + if (typeof (keys_datefmts[i] != 'undefined')) { + key = keys_datefmts[i]; + //console.log("date fomat key are :" + JSON.stringify(key) + "*********************************"); + + // if ((key["s"].split(/y/g).length - 1 != 2) && (key["s"].split(/y/g).length - 1 != 4)) { + // if (key["m"].split(/y/g).length - 1 == 2) { + // key["s"] = key["s"].replace(/[y]+/g, "yy"); + //} + // + + key["s"] = key["s"].replace(/[y]+/g, "yy"); + + + if (key["m"].split(/y/g).length - 1 == 4) { + key["m"] = key["m"].replace(/[y]+/g, "yyyy"); + } else { + key["m"] = key["m"].replace(/[y]+/g, "yy"); + } + //} + if ((key["l"].split(/y/g).length - 1 != 2) && (key["l"].split(/y/g).length - 1 != 4)) { + key["l"] = key["l"].replace(/[y]+/g, "yyyy"); + } + if ((key["f"].split(/y/g).length - 1 != 2) && (key["f"].split(/y/g).length - 1 != 4)) { + key["f"] = key["f"].replace(/[y]+/g, "yyyy"); + } + } + } + date["dm"] = dm; + date["my"] = my; + date["dmy"] = dmy; + date["d"] = d; + date["m"] = m; + date["y"] = y; + date["dmw"] = dmw; + date["dmwy"] = dmwy; + date["n"] = n; + gregorian["date"] = date; + + //dates["gregorian"]=gregorian; + //} + //console.log("gregorian date formats are :"+JSON.stringify(gregorian)+"++++++++++++++++++++++++++++++++++++++++++++"); + //code to map Time Formats + var time_24 = {}; + var time_12 = {}; + var time_fmt = {}; + available_formats = JSON.parse(JSON.stringify(available_formats).replace(/HH/g, "H")); + var timeformat = data.dates.calendars[default_calendar]["timeFormats"]; + //console.log("time formats are :"+JSON.stringify(timeformat)+"++++++++++++++++++++++++++++++++++++++++++++"); + if (available_formats["Hms"]) { + //var index_of_a = available_formats["hms"].indexOf("a"); + //var index_of_h = available_formats["hms"].indexOf("h"); + //var max_index = Math.max(index_of_a, index_of_h); + //available_formats["Hms"] = available_formats["Hms"].replace(/h/g, "H"); + //available_formats["Hms"] = available_formats["Hms"].substring(available_formats["Hms"].indexOf("H"), 1 + available_formats["Hms"].lastIndexOf("s")); + available_formats["Hms"] == available_formats["Hms"].replace(/a/g, ""); + //if (max_index == index_of_a) { + //time["ahmsz"] = available_formats["Hms"] + " " + "z"; + //time["ahms"] = available_formats["HH:mm:ssHms"] ; + //} else { + //time_24["ahmsz"] = "XXXXX" + available_formats["Hms"] + " " + "z"; + time_24["ahmsz"] = timeformat["long"]["timeFormat"]["pattern"].replace(/a/g, ""); + time_24["ahmsz"] = time_24["ahmsz"].replace(/h/g, "H"); + time_24["ahms"] = available_formats["Hms"]; + //} + time_24["hmsz"] = time_24["ahmsz"]; + time_24["hms"] = available_formats["Hms"]; + //time_24["ms"] = available_formats["Hms"].substring(available_formats["Hms"].indexOf("m"), 1 + available_formats["Hms"].lastIndexOf("s")); + time_24["ms"] = available_formats["Hms"].substring(available_formats["Hms"].indexOf("m"), available_formats["Hms"].length); + } + if (available_formats["Hm"]) { + //var index_of_a = available_formats["Hm"].indexOf("a"); + //var index_of_h = available_formats["Hm"].indexOf("H"); + //var max_index = Math.max(index_of_a, index_of_h); + //available_formats["hm"] = available_formats["hm"].replace(/h/g, "H"); + // available_formats["Hm"] = available_formats["Hm"].substring(available_formats["Hm"].indexOf("H"), 1 + available_formats["Hm"].lastIndexOf("m")); + available_formats["Hm"] = available_formats["Hm"].replace(/a/g, ""); //.substring(available_formats["Hm"].indexOf("H"), available_formats["Hm"].indexOf("s") - 1); + //if (max_index == index_of_a) { + //time_24["ahmz"] = available_formats["Hm"] + " " + "z"; + //time_24["ahm"] = available_formats["Hm"] ; + //time_24["ah"] = "H"; + //} else { + //time_24["ahmz"] = "XXXXX " + available_formats["Hm"] + " " + "z"; + if (time_24["ahmsz"].indexOf(":ss") != -1) { + time_24["ahmz"] = time_24["ahmsz"].replace(":ss", ""); + } else { + time_24["ahmz"] = time_24["ahmsz"].replace(".ss", ""); + } + time_24["ahm"] = available_formats["Hm"]; + time_24["hmz"] = time_24["ahmz"]; + time_24["ah"] = available_formats["H"]; + time_24["h"] = available_formats["H"]; + //} + time_24["hm"] = available_formats["Hm"]; + } + time_24["m"] = "mm"; + time_24["s"] = "ss"; + time_fmt["24"] = time_24; + //code for 12 hour clock setting + if (available_formats["hms"]) { + //available_formats["Hms"] = available_formats["Hms"].substring(available_formats["Hms"].indexOf("H"), 1 + available_formats["Hms"].lastIndexOf("s")); + //time_12["ahmsz"] = "XXXXX" + available_formats["hms"] + " " + "z"; + if (timeformat["long"]["timeFormat"]["pattern"].indexOf("HH:mm:ss") != -1) { + time_12["ahmsz"] = timeformat["long"]["timeFormat"]["pattern"].replace("HH:mm:ss", available_formats["hms"]); + // console.log("HHMMSS" + time_12["ahmsz"]); + } else { + time_12["ahmsz"] = timeformat["long"]["timeFormat"]["pattern"].replace("H:mm:ss", available_formats["hms"]); + //console.log("HMMSS" + time_12["ahmsz"]); + } + time_12["ahmsz"] = time_12["ahmsz"].replace(/H/g, "h"); + time_12["hmsz"] = time_12["ahmsz"].replace("\\s?a", ""); + time_12["ahms"] = available_formats["hms"].replace(/H/g, "h");; + time_12["hms"] = available_formats["hms"].replace("\\s?a", "").replace(/H/g, "h"); + //time_12["ms"] = available_formats["hms"].substring(available_formats["hms"].indexOf("m"), available_formats["hms"].lastIndexOf("s")); + time_12["ms"] = available_formats["hms"].substring(available_formats["hms"].indexOf("m"), 1 + available_formats["Hms"].lastIndexOf("s")).replace(/H/g, "h"); + } + if (available_formats["hm"]) { + //time_12["ahmz"] = "XXXXX" + available_formats["hm"] + " " + "z"; + if (time_12["ahmsz"].indexOf(":ss") != -1) { + time_12["ahmz"] = time_12["ahmsz"].replace(":ss", ""); + } else { + time_12["ahmz"] = time_12["ahmsz"].replace(".ss", ""); + } + time_12["ahm"] = available_formats["hm"].replace(/H/g, "h"); + time_12["hm"] = available_formats["hm"].replace("\\s?a", "").replace(/H/g, "h"); + } + time_12["hmz"] = time_12["ahmz"].replace("\\s?a", ""); + time_12["ah"] = available_formats["h"]; + time_12["h"] = available_formats["H"].replace(/H/g,"h"); + //} + time_12["m"] = "mm"; + time_12["s"] = "ss"; + time_fmt["12"] = time_12; + time_fmt = JSON.parse(JSON.stringify(time_fmt).replace(/ /g, " ")); + gregorian["time"] = time_fmt; + //console.log("gregorian date formats are :" + JSON.stringify(gregorian.time) + "++++++++++++++++++++++++++++++++++++++++++++"); + //code to get the date range + var range = {}; + var intervalFormats = data.dates.calendars[default_calendar]["dateTimeFormats"]["intervalFormats"]; + intervalFormats = JSON.parse(JSON.stringify(intervalFormats).replace(/L/g, "M")); + intervalFormats = JSON.parse(JSON.stringify(intervalFormats).replace(/G/g, "")); + //intervalFormats =JSON.parse(JSON.stringify(intervalFormats).replace(/'[^']+'/, "")); + //console.log("interval formats "+JSON.stringify(intervalFormats)+"++++++++++++++++++++++++++++++++++++++++++++"); + //intervalFormats=JSON.parse(JSON.stringify(intervalFormats).replace(/[^.–\s\/Mdy]/g,"")); + //var start_time = intervalFormats["Hm"]["H"].substring(0, intervalFormats["Hm"]["H"].length / 2); + //var end_time = intervalFormats["Hm"]["H"].substring(intervalFormats["Hm"]["H"].length / 2 + 1, intervalFormats["Hm"]["H"].length); + //intervalFormats["Hm"]["H"] = intervalFormats["Hm"]["H"].replace(start_time, ""); + //intervalFormats["Hm"]["H"] = intervalFormats["Hm"]["H"].replace(end_time, ""); + intervalFormats["Hm"]["H"] = intervalFormats["intervalFormatFallback"].charAt((intervalFormats["intervalFormatFallback"].length - 1) / 2); + //console.log("time format after replace "+intervalFormats["Hm"]["H"]+"++++++++++++++++++++++++++++++++++++++++++++"); + var ymd_d = intervalFormats["yMd"]["d"]; //.replace(/'[^']+'/g, ""); + var ymd_m = intervalFormats["yMd"]["M"]; //.replace(/'[^']+'/g, ""); + var ymd_y = intervalFormats["yMd"]["y"]; //.replace(/'[^']+'/g, ""); + var ymmmd_d = intervalFormats["yMMMd"]["d"]; //.replace(/'[^']+'/g, ""); + var ymmmd_m = intervalFormats["yMMMd"]["M"]; //.replace(/'[^']+'/g, ""); + var ymmmd_y = intervalFormats["yMMMd"]["y"]; //.replace(/'[^']+'/g, ""); + //var ym_d=intervalFormats["yM"]["d"]; + var ym_m = intervalFormats["yM"]["M"]; //.replace(/'[^']+'/g, ""); + var ym_y = intervalFormats["yM"]["y"]; //.replace(/'[^']+'/g, ""); + //var ymmm_d=intervalFormats["yMMM"]["d"]; + var ymmm_m = intervalFormats["yMMM"]["M"]; //.replace(/'[^']+'/g, ""); + var ymmm_y = intervalFormats["yMMM"]["y"]; //.replace(/'[^']+'/g, ""); + var ymmmm_m = intervalFormats["yMMMM"]["M"]; //.replace(/'[^']+'/g, ""); + var ymmmm_y = intervalFormats["yMMMM"]["y"]; //.replace(/'[^']+'/g, ""); + //for coo + //intervalFormats =JSON.parse(JSON.stringify(intervalFormats).replace(/'[^']+'/g, "")); + var c00 = {}; + var c01 = {}; + var c02 = {}; + var c03 = {}; + var c10 = {}; + var c11 = {}; + var c12 = {}; + var c20 = {}; + var c30 = {}; + //var s_sd = []; + //var s_sm = []; + //var s_sy = []; + //var array=[date["dmy"]["s"],date["dmy"]["m"],date["dmy"]["l"],date["dmy"]["f"]] + var array = [dmy["s"], dmy["m"], dmy["l"], dmy["f"]]; + //var arr_dm = []; + //var arr_y = []; + for (var i = 0; i < array.length; i++) { + + var k; + var arr = array[i].split("'"); + + if (arr.length > 1) { + if (array[i].indexOf("'") != 0) { + k = 0; + } else { + + k = 1; + } + //var count = 0; + + for (; k < arr.length; k = k + 2) { + // count++; + + arr[k] = arr[k].replace(/[d]+/g, "{sd}"); + arr[k] = arr[k].replace(/[M]+/g, "{sm}"); + arr[k] = arr[k].replace(/[y]+/g, "{sy}"); + + } + + array[i] = arr.join(""); + } else { + array[i] = array[i].replace(/[d]+/g, "{sd}"); + array[i] = array[i].replace(/[M]+/g, "{sm}"); + array[i] = array[i].replace(/[y]+/g, "{sy}"); + } + } + /* + for (var i = 0; i < array.length; i++) { + var index_of_st = array[i].indexOf("{st}"); + var index_of_sd = array[i].indexOf("{sd}"); + var index_of_sm = array[i].indexOf("{sm}"); + var index_of_sm = array[i].indexOf("{sy}"); + } + */ + var array_interval_dmy = [ymd_d, ymd_m, ymd_y, ymmmd_d, ymmmd_m, ymmmd_y]; + var start_dmy = []; + var end_dmy = []; + var start_my = []; + var end_my = []; + var index_of_sd, index_of_sm, index_of_sy; + var last_index_of_sd = -1, + last_index_of_sm = -1, + last_index_of_sy = -1; + //var sy=[]; + for (var i = 0; i < array_interval_dmy.length; i++) { + + array_interval_dmy[i] = array_interval_dmy[i].replace(intervalFormats["Hm"]["H"], "–"); + array_interval_dmy[i] = array_interval_dmy[i].replace(/[-]+/g, "–"); + + var k; + var arr = array_interval_dmy[i].split("'"); + + if (arr.length > 1) { + if (array_interval_dmy[i].indexOf("'") != 0) { + k = 0; + } else { + + k = 1; + } + //var count = 0; + + for (; k < arr.length; k = k + 2) { + //count++; + + arr[k] = arr[k].replace(/[^Mdy–.\/\s]/g, ""); + arr[k] = arr[k].replace(/[d]+/g, "{sd}"); + arr[k] = arr[k].replace(/[M]+/g, "{sm}"); + arr[k] = arr[k].replace(/[y]+/g, "{sy}"); + + } + + array_interval_dmy[i] = arr.join(""); + } else { + array_interval_dmy[i] = array_interval_dmy[i].replace(/[^Mdy–.,\/\s]/g, ""); + array_interval_dmy[i] = array_interval_dmy[i].replace(/[d]+/g, "{sd}"); + array_interval_dmy[i] = array_interval_dmy[i].replace(/[M]+/g, "{sm}"); + array_interval_dmy[i] = array_interval_dmy[i].replace(/[y]+/g, "{sy}"); + } + // console.log("array_interval_dmy " + array_interval_dmy[i]); + + index_of_sd = array_interval_dmy[i].indexOf("{sd}"); + index_of_sm = array_interval_dmy[i].indexOf("{sm}"); + index_of_sy = array_interval_dmy[i].indexOf("{sy}"); + if (array_interval_dmy[i].indexOf("{sd}") != array_interval_dmy[i].lastIndexOf("{sd}")) { + last_index_of_sd = array_interval_dmy[i].lastIndexOf("{sd}"); + } + if (array_interval_dmy[i].indexOf("{sm}") != array_interval_dmy[i].lastIndexOf("{sm}")) { + last_index_of_sm = array_interval_dmy[i].lastIndexOf("{sm}"); + } + if (array_interval_dmy[i].indexOf("{sy}") != array_interval_dmy[i].lastIndexOf("{sy}")) { + last_index_of_sy = array_interval_dmy[i].lastIndexOf("{sy}"); + } + var arr_min = [ /*index_of_sd,index_of_sm,index_of_sy,*/ last_index_of_sd, last_index_of_sm, last_index_of_sy]; + + var arr_max = [index_of_sd, index_of_sm, index_of_sy]; + var minimum = arr_min.filter(function (x) { + return x >= 0; + }) + .reduce(function (a, b) { + return Math.min(a, b); + }, Infinity); + + var curr = arr_max[0]; + var diff = Math.abs(minimum - curr); + + for (var val = 0; val < arr_max.length; val++) { + var newdiff = Math.abs(minimum - arr_max[val]); + if ((newdiff < diff) && (minimum > arr_max[val])) { + diff = newdiff; + curr = arr_max[val]; + } + } + var maximum = curr; + + // console.log("Minimum Index is :" + minimum); + //console.log("Maximum Index is :" + maximum); + + separaor_substring = array_interval_dmy[i].substring(maximum + 5, minimum); + // console.log(" separaor_substring" + separaor_substring); + index_of_separator = maximum + 5 + separaor_substring.indexOf("–"); + //console.log(" index_of_separator" + index_of_separator); + //console.log("start_interval_dmy " + start_dmy[i]); + start_dmy[i] = array_interval_dmy[i].substring(0, index_of_separator); + //console.log("start_interval_dmy " + start_dmy[i]); + end_dmy[i] = array_interval_dmy[i].substring(1 + index_of_separator, array_interval_dmy[i].length); + end_dmy[i] = end_dmy[i].replace("{sd}", "{ed}"); + end_dmy[i] = end_dmy[i].replace("{sm}", "{em}"); + end_dmy[i] = end_dmy[i].replace("{sy}", "{ey}"); + //end_dmy[i] = end_dmy[i].replace("{sy}", "{ey}"); + //end_dmy[i] = end_dmy[i].replace("{sy}", "{ey}"); + if (start_dmy[i].charAt(start_dmy[i].length - 1) === " ") { + start_dmy[i] = start_dmy[i].slice(0, -1); + intervalFormats["Hm"]["H"] = " " + intervalFormats["Hm"]["H"] + " "; + end_dmy[i] = end_dmy[i].slice(1); + } + + if (start_dmy[i].charAt(0) === " ") { + start_dmy[i] = start_dmy[i].slice(1); + } + + if (end_dmy[i].charAt(0) === "–") { + end_dmy[i] = end_dmy[i].slice(1); + } + //console.log("array_interval_dmy " + array_interval_dmy[i]); + // console.log("start_interval_dmy " + i + start_dmy[i]); + //console.log("end_interval_dmy " + i + end_dmy[i]); + } + last_index_of_sd = -1, last_index_of_sm = -1, last_index_of_sy = -1; + maximum = minimum = 0; + var array_interval_my = [ym_m, ym_y, ymmm_m, ymmm_y, ymmmm_m, ymmmm_y]; + for (var i = 0; i < array_interval_my.length; i++) { + + array_interval_my[i] = array_interval_my[i].replace(intervalFormats["Hm"]["H"], "–"); + array_interval_my[i] = array_interval_my[i].replace(/[-]+/g, "–"); + var k; + var arr = array_interval_my[i].split("'"); + + if (arr.length > 1) { + if (array_interval_my[i].indexOf("'") != 0) { + k = 0; + } else { + + k = 1; + } + //var count = 0; + + for (; k < arr.length; k = k + 2) { + // count++; + + arr[k] = arr[k].replace(/[^Mdy–.\/\s]/g, ""); + arr[k] = arr[k].replace(/[d]+/g, "{sd}"); + arr[k] = arr[k].replace(/[M]+/g, "{sm}"); + arr[k] = arr[k].replace(/[y]+/g, "{sy}"); + + } + + array_interval_my[i] = arr.join(""); + } else { + array_interval_my[i] = array_interval_my[i].replace(/[^Mdy–.\/\s]/g, ""); + //array_interval_my[i] = array_interval_my[i].replace(/[d]+/g, "{sd}"); + array_interval_my[i] = array_interval_my[i].replace(/[M]+/g, "{sm}"); + array_interval_my[i] = array_interval_my[i].replace(/[y]+/g, "{sy}"); + } + //index_of_sd = array_interval_my[i].lastIndexOf("{sd}"); + index_of_sm = array_interval_my[i].indexOf("{sm}"); + index_of_sy = array_interval_my[i].indexOf("{sy}"); + //if ( array_interval_dmy[i].indexOf("{sd}") != array_interval_dmy[i].lastIndexOf("{sd}") ) { + //last_index_of_sd = array_interval_dmy[i].lastIndexOf("{sd}"); + // } + if (array_interval_my[i].indexOf("{sm}") != array_interval_my[i].lastIndexOf("{sm}")) { + last_index_of_sm = array_interval_my[i].lastIndexOf("{sm}"); + } + if (array_interval_my[i].indexOf("{sy}") != array_interval_my[i].lastIndexOf("{sy}")) { + last_index_of_sy = array_interval_my[i].lastIndexOf("{sy}"); + } + var arr_min = [ /*index_of_sd,index_of_sm,index_of_sy,last_index_of_sd,*/ last_index_of_sm, last_index_of_sy]; + + var arr_max = [index_of_sm, index_of_sy]; + minimum = arr_min.filter(function (x) { + return x >= 0; + }) + .reduce(function (a, b) { + return Math.min(a, b); + }, Infinity); + + var curr = arr_max[0]; + var diff = Math.abs(minimum - curr); + //console.log("Minimum Index is :" + minimum); + // console.log(" Index of sm is :" + index_of_sm); + // console.log(" Index of sy is :" + index_of_sy); + //console.log("Maximum Index is :" + maximum); + //var maximum = arr_max.filter(function (x) { return x < minimum; }) + // .reduce(function (a, b) { return Math.max(a, b); }, Infinity); + for (var val = 0; val < arr_max.length; val++) { + var newdiff = Math.abs(minimum - arr_max[val]); + if (newdiff < diff) { + diff = newdiff; + curr = arr_max[val]; + } + } + maximum = curr; + // console.log("Maximum Index is :" + maximum); + //index_of_separator = array_interval_my[i].indexOf("–"); + //index_of_separator = Math.min(index_of_sd,index_of_sm,index_of_sy); + //start_my[i] = array_interval_my[i].substring(0, index_of_separator); + //end_my[i] = array_interval_my[i].substring(1 + index_of_separator, array_interval_my[i].length); + separaor_substring = array_interval_my[i].substring(maximum + 5, minimum); + //console.log(" separaor_substring" + separaor_substring); + index_of_separator = maximum + 5 + separaor_substring.indexOf("–"); + // console.log(" index_of_separator" + index_of_separator); + start_my[i] = array_interval_my[i].substring(0, index_of_separator); + //console.log("start_interval_my " + start_my[i]); + end_my[i] = array_interval_my[i].substring(1 + index_of_separator, array_interval_my[i].length); + end_my[i] = end_my[i].replace("{sd}", "{ed}"); + end_my[i] = end_my[i].replace("{sm}", "{em}"); + end_my[i] = end_my[i].replace("{sy}", "{ey}"); + /*if (start_my[i].charAt(start_my[i].length - 1) === " ") { + start_my[i] = start_my[i].slice(0, -1); + //intervalFormats["Hm"]["H"] = " "+ intervalFormats["Hm"]["H"] + " "; + end_my[i] = end_my[i].slice(1); + }*/ + + if (start_my[i].charAt(start_my[i].length - 1) === " ") { + start_my[i] = start_my[i].slice(0, -1); + + intervalFormats["Hm"]["H"] = " " + intervalFormats["Hm"]["H"] + " "; + end_my[i] = end_my[i].slice(1); + } + if (end_my[i].charAt(0) === "–") { + end_my[i] = end_my[i].slice(1); + } + //console.log("array_interval_my " + array_interval_my[i]); + //console.log("start_interval_my " + start_my[i]); + //console.log("end_interval_my " + end_my[i]); + } + //c01 + //c01["s"]=array_interval_dmy[0]+ + if (gregorian["order"] === "{time} {date}") { + c00["s"] = "{st}" + intervalFormats["Hm"]["H"] + "{et}" + " " + array[0]; + c00["m"] = "{st}" + intervalFormats["Hm"]["H"] + "{et}" + " " + array[1]; + c00["l"] = "{st}" + intervalFormats["Hm"]["H"] + "{et}" + " " + array[2]; + c00["f"] = "{st}" + intervalFormats["Hm"]["H"] + "{et}" + " " + array[3]; + } else { + c00["s"] = array[0] + " " + "{st}" + intervalFormats["Hm"]["H"] + "{et}"; + c00["m"] = array[1] + " " + "{st}" + intervalFormats["Hm"]["H"] + "{et}"; + c00["l"] = array[2] + " " + "{st}" + intervalFormats["Hm"]["H"] + "{et}"; + c00["f"] = array[3] + " " + "{st}" + intervalFormats["Hm"]["H"] + "{et}"; + } + //for c01 + if (gregorian["order"] === "{time} {date}") { + c01["s"] = "{st}" + " " + start_dmy[0] + intervalFormats["Hm"]["H"] + "{et}" + " " + end_dmy[0]; + c01["l"] = "{st}" + " " + start_dmy[3] + intervalFormats["Hm"]["H"] + "{et}" + " " + end_dmy[3]; + } else { + c01["s"] = start_dmy[0] + " " + "{st}" + intervalFormats["Hm"]["H"] + end_dmy[0] + " " + "{et}"; + c01["l"] = start_dmy[3] + " " + "{st}" + intervalFormats["Hm"]["H"] + end_dmy[3] + " " + "{et}"; + } + c01["m"] = c01["s"]; + c01["f"] = c01["l"]; + //for c02 + if (gregorian["order"] === "{time} {date}") { + c02["s"] = "{st}" + " " + start_dmy[1] + intervalFormats["Hm"]["H"] + "{et}" + " " + end_dmy[1]; + c02["l"] = "{st}" + " " + start_dmy[4] + intervalFormats["Hm"]["H"] + "{et}" + " " + end_dmy[4]; + } else { + c02["s"] = start_dmy[1] + " " + "{st}" + intervalFormats["Hm"]["H"] + end_dmy[1] + " " + "{et}"; + c02["l"] = start_dmy[4] + " " + "{st}" + intervalFormats["Hm"]["H"] + end_dmy[4] + " " + "{et}"; + } + c02["f"] = c02["l"]; + c02["m"] = c02["s"]; + //for c03 + if (gregorian["order"] === "{time} {date}") { + c03["s"] = "{st}" + " " + start_dmy[2] + intervalFormats["Hm"]["H"] + "{et}" + " " + end_dmy[2]; + c03["l"] = "{st}" + " " + start_dmy[5] + intervalFormats["Hm"]["H"] + "{et}" + " " + end_dmy[5]; + } else { + c03["s"] = start_dmy[2] + " " + "{st}" + intervalFormats["Hm"]["H"] + end_dmy[2] + " " + "{et}"; + c03["l"] = start_dmy[5] + " " + "{st}" + intervalFormats["Hm"]["H"] + end_dmy[5] + " " + "{et}"; + } + c03["f"] = c03["l"]; + c03["m"] = c03["s"]; + //for c10 + c10["s"] = start_dmy[0] + intervalFormats["Hm"]["H"] + end_dmy[0]; + c10["l"] = start_dmy[3] + intervalFormats["Hm"]["H"] + end_dmy[3]; + c10["f"] = c10["l"]; + c10["m"] = c10["s"]; + //for c11 + c11["s"] = start_dmy[1] + intervalFormats["Hm"]["H"] + end_dmy[1]; + c11["m"] = c11["s"]; + c11["l"] = start_dmy[4] + intervalFormats["Hm"]["H"] + end_dmy[4]; + c11["f"] = c11["l"]; + //for c12 + c12["s"] = start_dmy[2] + intervalFormats["Hm"]["H"] + end_dmy[2]; + c12["m"] = c12["s"]; + c12["l"] = start_dmy[5] + intervalFormats["Hm"]["H"] + end_dmy[5]; + c12["f"] = c12["l"]; + //for c20 + c20["s"] = start_my[1] + intervalFormats["Hm"]["H"] + end_my[1]; + c20["m"] = c20["s"]; + c20["l"] = start_my[3] + intervalFormats["Hm"]["H"] + end_my[3]; + c20["f"] = start_my[5] + intervalFormats["Hm"]["H"] + end_my[5]; + //for c30 + c30 = "{sy}" + intervalFormats["Hm"]["H"] + "{ey}"; + //var array_intervalcodes=[c00,c01,c02,c10,c11,c12,c20]; + /*for(var i=0;i 2) { } console.log("genmeasurementsystem - generate the localeinfo units.jf files.\n" + -"Copyright (c) 2013, 2018 JEDLSoft\n"); +"Copyright (c) 2013, 2018 JEDLSoft"); -console.log("output dir: " + toDir + "\n"); +console.log("output dir: " + toDir ); if (!fs.existsSync(toDir)) { console.log("Could not access target directory " + toDir); diff --git a/tools/cldr/gennorm.js b/tools/cldr/gennorm.js index c5b2476acc..c2246a7ad9 100644 --- a/tools/cldr/gennorm.js +++ b/tools/cldr/gennorm.js @@ -2,7 +2,7 @@ * gennorm.js - ilib tool to generate the json UNA normalization data from the Unicode * data files * - * Copyright © 2013-2018, JEDLSoft + * Copyright © 2013-2018, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ */ var fs = require('fs'); -var util = require('util'); var uniData = require('./uniData.js'); var unifile = require('./unifile.js'); var common = require('./common.js'); @@ -47,7 +46,7 @@ function usage() { "dataDir\n" + " directory to output the normalization data json files. Default: current_dir/locale.\n" + "codeDir\n" + - " directory to output the generated code files. Default: current_dir/lib.\n"); + " directory to output the generated code files. Default: current_dir/lib."); process.exit(1); } @@ -62,7 +61,7 @@ process.argv.forEach(function (val, index, array) { }); if (process.argv.length < 3) { - util.error('Error: not enough arguments'); + console.error('Error: not enough arguments'); usage(); } @@ -77,10 +76,10 @@ if (process.argv.length > 3) { } console.log("gennorm - generate normalization data.\n" + - "Copyright (c) 2012 JEDLSoft\n"); + "Copyright (c) 2012 JEDLSoft"); if (!fs.existsSync(unicodeDirName)) { - util.error("Could not access UCD dir " + unicodeDirName); + console.error("Could not access UCD dir " + unicodeDirName); usage(); } @@ -90,28 +89,28 @@ var unicodeFileName = unicodeDirName + "/UnicodeData.txt", scriptFileName = unicodeDirName + "/Scripts.txt"; if (!fs.existsSync(unicodeFileName)) { - util.error("Could not find file " + unicodeFileName); + console.error("Could not find file " + unicodeFileName); usage(); } if (!fs.existsSync(exclusionFileName)) { - util.error("Could not find file " + exclusionFileName); + console.error("Could not find file " + exclusionFileName); usage(); } if (!fs.existsSync(scriptFileName)) { - util.error("Could not find file " + scriptFileName); + console.error("Could not find file " + scriptFileName); usage(); } if (!fs.existsSync(toDir)) { mkdirs(toDir); if (!fs.existsSync(toDir)) { - util.error("Could not access target data directory " + toDir); + console.error("Could not access target data directory " + toDir); usage(); } } if (!fs.existsSync(codeDir)) { mkdirs(codeDir); if (!fs.existsSync(codeDir)) { - util.error("Could not access target code directory " + codeDir); + console.error("Could not access target code directory " + codeDir); usage(); } } @@ -172,7 +171,7 @@ for (var i = 0; i < len; i++ ) { if (!isMember(compositionExclusions, common.UTF16ToCodePoint(c))) { canonicalComp[row.getDecomposition()] = c; //} else { - // console.log("Composition from " + common.UTF16ToCodePoint(c) + " to " + common.UTF16ToCodePoint(row.getDecomposition()) + " is on the exclusion list.\n"); + // console.log("Composition from " + common.UTF16ToCodePoint(c) + " to " + common.UTF16ToCodePoint(row.getDecomposition()) + " is on the exclusion list."); } } else { compatibilityMappings[c] = row.getDecomposition(); diff --git a/tools/cldr/gennormtest.js b/tools/cldr/gennormtest.js index 3248e6fdd5..a66b7a75b1 100644 --- a/tools/cldr/gennormtest.js +++ b/tools/cldr/gennormtest.js @@ -2,7 +2,7 @@ * gennormtest.js - ilib tool to generate the UNA normalization test data from the Unicode * data files * - * Copyright © 2012 - 2015, JEDLSoft + * Copyright © 2012-2015, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,21 +23,20 @@ */ var fs = require('fs'); -var util = require('util'); var unifile = require('./unifile.js'); var UnicodeFile = unifile.UnicodeFile; var common = require('./common.js'); var fromCodePoint = common.codePointToUTF16; function usage() { - util.print("Usage: gennormtest [-h] NormalizationTest.txt [toDir]\n" + + console.log("Usage: gennormtest [-h] NormalizationTest.txt [toDir]\n" + "Generate the normalization test data.\n\n" + "-h or --help\n" + " this help\n" + "NormalizationTest.txt\n" + " the normalization test data from the Unicode character database\n" + "toDir\n" + - " directory to output the output files. Default: current dir.\n"); + " directory to output the output files. Default: current dir."); process.exit(1); } @@ -60,7 +59,7 @@ process.argv.forEach(function (val, index, array) { }); if (process.argv.length < 3) { - util.error('Error: not enough arguments'); + console.error('Error: not enough arguments'); usage(); } @@ -69,19 +68,19 @@ if (process.argv.length > 3) { toDir = process.argv[3]; } -util.print("gennorm - generate normalization test data.\n" + - "Copyright (c) 2013 JEDLSoft\n"); +console.log("gennorm - generate normalization test data.\n" + + "Copyright (c) 2013 JEDLSoft"); fs.exists(unicodeFileName, function (exists) { if (!exists) { - util.error("Could not access file " + unicodeFileName); + console.error("Could not access file " + unicodeFileName); usage(); } }); fs.exists(toDir, function (exists) { if (!exists) { - util.error("Could not access target directory " + toDir); + console.error("Could not access target directory " + toDir); usage(); } }); diff --git a/tools/cldr/gennumfmt.js b/tools/cldr/gennumfmt.js index 508c1e2e8a..d0f862156a 100644 --- a/tools/cldr/gennumfmt.js +++ b/tools/cldr/gennumfmt.js @@ -22,12 +22,10 @@ */ var fs = require('fs'); var path = require('path'); -var util = require('util'); var cldr = require("cldr-data"); var numberingSystemsData = require("cldr-data/supplemental/numberingSystems.json"); var common = require('./common'); -var merge = common.merge; var Locale = common.Locale; var mergeAndPrune = common.mergeAndPrune; var makeDirs = common.makeDirs; @@ -39,7 +37,7 @@ function usage() { "-h or --help\n" + " this help\n" + "toDir\n" + - " directory to output the currency.jf json files. Default: current dir.\n"); + " directory to output the currency.jf json files. Default: current dir."); process.exit(1); } @@ -59,12 +57,12 @@ if (process.argv.length <= 2) { } console.log("gennumfmts - generate number formats information files.\n" + - "Copyright (c) 2013-2018, 2020 JEDLSoft\n"); + "Copyright (c) 2013-2018, 2020 JEDLSoft"); -console.log("Output dir: " + toDir + "\n"); +console.log("Output dir: " + toDir ); if (!fs.existsSync(toDir)) { - util.error("Could not access Output directory " + toDir); + console.error("Could not access Output directory " + toDir); usage(); } @@ -137,9 +135,9 @@ function getLocaleData(dirname, locale) { localeData.data = numData; } - //console.log("dirname: " + dirname + " data: ", numData + "\n"); + //console.log("dirname: " + dirname + " data: ", numData ); } catch (e) { - console.log("Error: Could not load file " + e + "\n"); + console.log("Error: Could not load file " + e ); } return numData; @@ -160,19 +158,19 @@ function anyProperties(data) { function writeNumberFormats(language, script, region, data) { var path = calcLocalePath(language, script, region, ""); - //console.log("data to be written into jf files" + path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"+JSON.stringify(data)+"\n"); + //console.log("data to be written into jf files" + path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"+JSON.stringify(data)); if (data.generated) { if (anyProperties(data)) { - console.log("Writing " + path + "\n"); + console.log("Writing " + path ); var empty_data_default = data["numfmt"]; var empty_data_native = data["native_numfmt"]; if (isEmpty(empty_data_default) && isEmpty(empty_data_native)) { - //console.log("no need to create the file " + "\n"); + //console.log("no need to create the file " ); return; } - //console.log("data to be written into jf files" + path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"+JSON.stringify(numfmt)+"\n"); */ + //console.log("data to be written into jf files" + path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"+JSON.stringify(numfmt)); */ if (!isEmpty(data)) { data.generated = true; makeDirs(path); @@ -185,10 +183,10 @@ function writeNumberFormats(language, script, region, data) { }*/ //fs.writeFileSync(path + "/numfmt.jf",JSON.stringify(data), "utf-8"); } else { - console.log("Skipping empty " + path + "\n"); + console.log("Skipping empty " + path ); } } else { - console.log("Skipping existing " + path + "\n"); + console.log("Skipping existing " + path ); } } function getNumberFormats(language, script, region, data) { @@ -228,7 +226,7 @@ function getNumberFormats_num_system(def_num_system, data) { var percentage_number_system = percentage.concat(def_num_system); var currency_number_system = currency.concat(def_num_system); - //console.log("the symbol numbering system " + symbol_number_system + "\n"); + //console.log("the symbol numbering system " + symbol_number_system ); var symbol_format = data.numbers[symbol_number_system]; var decimal_format = data.numbers[decimal_number_system]["standard"]; var percent_format = data.numbers[percentage_number_system]["standard"]; @@ -299,7 +297,7 @@ function getNumberFormats_num_system(def_num_system, data) { if (currency_format.indexOf(";") != -1) { index_of_semi_colon = currency_format.indexOf(";"); var cur_fmt = currency_format.substring(0, index_of_semi_colon); - //console.log("cur_fmt is ...................." + cur_fmt + "===================" + "\n"); + //console.log("cur_fmt is ...................." + cur_fmt + "===================" ); var curFmt = cur_fmt.replace(/[0#,\.]+/, "{n}"); curFmt = curFmt.replace(/¤/g, "{s}"); symbol_format_data.currencyFormats.common = curFmt.trim(); @@ -381,22 +379,22 @@ function getNumberFormats_num_system(def_num_system, data) { function getNativeDigits(script) { //var digits=[]; - //console.log("script for native digits " + script + "\n"); + //console.log("script for native digits " + script ); digitsData = numberingSystemsData.supplemental["numberingSystems"] digits_script = digitsData[script]; - //console.log("digits for script are:" + JSON.stringify(digits_script) + "\n"); + //console.log("digits for script are:" + JSON.stringify(digits_script) ); if (typeof (digits_script) != 'undefined' && digits_script !== "latn") { if (digits_script["_type"] == "numeric") { var digits = digits_script["_digits"]; - //console.log("digits for script are:" + JSON.stringify(digits) + "\n"); + //console.log("digits for script are:" + JSON.stringify(digits) ); return digits; } } } -console.log("Reading locale data into memory...\n"); +console.log("Reading locale data into memory..."); var list = cldr.availableLocales; @@ -413,11 +411,11 @@ list.forEach(function(loc) { } }); -console.log("\n"); -console.log("Merging and pruning locale data...\n"); +console.log(""); +console.log("Merging and pruning locale data..."); mergeAndPrune(localeData); -console.log("Extracting number formats...\n"); +console.log("Extracting number formats..."); var resources = {}; resources.data = getNumberFormats(undefined, undefined, undefined, localeData.data); @@ -445,11 +443,11 @@ for (language in localeData) { } } -console.log("\nMerging and pruning formats...\n"); +console.log("\nMerging and pruning formats..."); mergeAndPrune(resources); -console.log("\nWriting formats...\n"); +console.log("\nWriting formats..."); for (language in resources) { if (language && resources[language] && language !== 'data' && language !== 'merged') { diff --git a/tools/cldr/genpapersizes.js b/tools/cldr/genpapersizes.js index 5f7b94d7cf..da8d5ebd66 100644 --- a/tools/cldr/genpapersizes.js +++ b/tools/cldr/genpapersizes.js @@ -1,7 +1,7 @@ /* * genpapersizes.js - ilib tool to generate the json data about paper sizes * - * Copyright © 2013 - 2018, JEDLSoft + * Copyright © 2013-2018, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ function usage() { "-h or --help\n" + " this help\n" + "toDir\n" + - " directory to output the papersize.jf json files. Default: current dir.\n"); + " directory to output the papersize.jf json files. Default: current dir."); process.exit(1); } @@ -78,12 +78,12 @@ for (var territories in paperSizeData) { if (paperSizeData[territories] === "US-Letter") { directory = path.join(toDir, 'und', territories); filename = path.join(directory, "papersizes.jf"); - //console.log(filename + "\n"); + //console.log(filename ); paperSizes["regular"] = "8x11"; if (!fs.existsSync(directory)) { mkdirs(directory); - //console.log(territories + "\n"); + //console.log(territories ); } papersize["paperSizes"] = paperSizes; papersize.generated = true; diff --git a/tools/cldr/genphone.js b/tools/cldr/genphone.js index 80db4b6b29..33b7f9507c 100644 --- a/tools/cldr/genphone.js +++ b/tools/cldr/genphone.js @@ -2,7 +2,7 @@ * genphone.js - ilib tool to generate the json data for parsing and * formatting phone numbers * - * Copyright © 2014, JEDLSoft + * Copyright © 2014, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ * This code is intended to be run under node.js */ var fs = require("fs"); -var util = require('util'); var path = require('path'); var common = require('./common.js'); var unifile = require("./unifile.js"); @@ -29,14 +28,14 @@ var mkdirs = common.makeDirs; var UnicodeFile = unifile.UnicodeFile; function usage() { - util.print("Usage: genphone [-h] phone_data_dir [toDir]\n" + + console.log("Usage: genphone [-h] phone_data_dir [toDir]\n" + "Generate the locale data for phone numbers.\n\n" + "-h or --help\n" + " this help\n" + "phone_data_dir\n" + " directory with raw phone number source files\n" + "toDir\n" + - " directory to output the json files. Default: current dir.\n"); + " directory to output the json files. Default: current dir."); process.exit(1); } @@ -50,7 +49,7 @@ process.argv.forEach(function (val, index, array) { }); if (process.argv.length < 3) { - util.error('Error: not enough arguments'); + console.error('Error: not enough arguments'); usage(); } @@ -59,19 +58,19 @@ if (process.argv.length > 3) { toDir = process.argv[3]; } -util.print("genphone - generate the phone parsing/geolocation data files.\n" + - "Copyright (c) 2014 JEDLSoft\n"); +console.log("genphone - generate the phone parsing/geolocation data files.\n" + + "Copyright (c) 2014 JEDLSoft"); -util.print("Phone data dir: " + phoneDir + "\n"); -util.print("output dir: " + toDir + "\n"); +console.log("Phone data dir: " + phoneDir); +console.log("output dir: " + toDir); if (!fs.existsSync(phoneDir)) { - util.error("Could not access phone data directory " + phoneDir); + console.error("Could not access phone data directory " + phoneDir); usage(); } if (!fs.existsSync(toDir)) { - util.error("Could not access target directory " + toDir); + console.error("Could not access target directory " + toDir); usage(); } @@ -170,21 +169,21 @@ function processFile(file) { var area = {}; var ch; - util.print("processing file " + file + "\n"); + console.log("processing file " + file); for (var i = 0; i < f.length(); i++) { var fields = f.get(i); if (fields.length > 1) { var digits = fields[0]; var state = states.indexOf(fields[1]); if (state === -1) { - util.print("Error: could not get type in line " + i + ": " + f.getLine(i) + "\n"); + console.log("Error: could not get type in line " + i + ": " + f.getLine(i)); } else { current = trie; - //util.print("Encoding " + digits + " in state " + state + "(" + fields[1] + ")\n"); + //console.log("Encoding " + digits + " in state " + state + "(" + fields[1] + ")"); for (var j = 0; j < digits.length-1; j++) { ch = getCharacterCode(digits.charAt(j)); if (ch >= 0) { - // util.print("doing " + ch + "\n"); + // console.log("doing " + ch); if (typeof(current.s) === 'undefined') { current.s = []; } @@ -206,7 +205,7 @@ function processFile(file) { } } // if (!current) { - // util.print("current is undefined. trie is\n" + JSON.stringify(trie, undefined, 4) + "\n"); + // console.log("current is undefined. trie is\n" + JSON.stringify(trie, undefined, 4)); // } // now we have reached the final state ch = getCharacterCode(digits.charAt(digits.length - 1)); @@ -233,7 +232,7 @@ function processFile(file) { } function deNullify(arr) { - // util.print("denullifying an object\n"); + // console.log("denullifying an object"); var node = {}; if (typeof(arr.digits) !== 'undefined') { node.digits = arr.digits; @@ -242,11 +241,11 @@ function processFile(file) { node.l = arr.l; } if (typeof(arr.s) !== 'undefined') { - // util.print("denullifying an array\n"); + // console.log("denullifying an array"); node.s = []; for (var i = 0; i < arr.s.length; i++) { var value = arr.s[i]; - // util.print("value " + i + " is " + value + "\n"); + // console.log("value " + i + " is " + value); if (value === null || typeof(value) === 'undefined') { node.s.push(0); } else if (typeof(value) === 'number') { diff --git a/tools/cldr/genplurals.js b/tools/cldr/genplurals.js index b55a895312..9f51645a34 100644 --- a/tools/cldr/genplurals.js +++ b/tools/cldr/genplurals.js @@ -36,7 +36,7 @@ function usage() { "-h or --help\n" + " this help\n" + "toDir\n" + - " directory to output the plurals.json files\n"); + " directory to output the plurals.json files"); process.exit(1); } diff --git a/tools/cldr/genscripts.js b/tools/cldr/genscripts.js index c95787a503..7afc9d6eb3 100644 --- a/tools/cldr/genscripts.js +++ b/tools/cldr/genscripts.js @@ -42,7 +42,7 @@ function usage() { " path to the Unicode Character Database files downloaded from the Unicode site\n" + " i.e) https://unicode.org/Public/13.0.0/ucd/ \n" + "toDir\n" + - " directory to output the normalization json files. Default: current dir.\n"); + " directory to output the normalization json files. Default: current dir."); process.exit(1); } diff --git a/tools/cldr/gentzinfo.js b/tools/cldr/gentzinfo.js index c0740b2368..ac1456d460 100644 --- a/tools/cldr/gentzinfo.js +++ b/tools/cldr/gentzinfo.js @@ -1,7 +1,7 @@ /* * gentzinfo.js - ilib tool to generate the tzinfo about time zones in a locale * - * Copyright © 2013-2015, 2018, JEDLSoft + * Copyright © 2013-2015, 2018, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,12 +22,10 @@ */ var fs = require('fs'); -var util = require('util'); var path = require('path'); var unifile = require('./unifile.js'); var common = require('./common.js'); var UnicodeFile = unifile.UnicodeFile; -var coelesce = common.coelesce; var windowsZones = require("cldr-data/supplemental/windowsZones.json"); function usage() { @@ -38,7 +36,7 @@ function usage() { "tzdata-dir\n" + " path to the tzdata dir downloaded from the IANA site.\n" + "toDir\n" + - " directory to output the normalized json files. Default: current-dir.\n"); + " directory to output the normalized json files. Default: current-dir."); process.exit(1); } @@ -63,7 +61,7 @@ process.argv.forEach(function (val, index, array) { }); if (process.argv.length < 2) { - util.error('Error: not enough arguments'); + console.error('Error: not enough arguments'); usage(); } @@ -74,15 +72,15 @@ if (process.argv.length > 3) { console.log("gentzinfo - generate time zone info data.\n" + "Copyright (c) 2013, 2018 JEDLSoft\n"); -console.log("To dir: " + toDir + "\n"); +console.log("To dir: " + toDir ); if (!fs.existsSync(tzDataDir)) { - util.error("Could not access tzdata directory " + tzDataDir); + console.error("Could not access tzdata directory " + tzDataDir); usage(); } if (!fs.existsSync(toDir)) { - util.error("Could not access target directory " + toDir); + console.error("Could not access target directory " + toDir); usage(); } @@ -106,7 +104,7 @@ var backwardsMap = {}; for (var i = 0; i < backwardsFile.length(); i++) { var row = backwardsFile.get(i); backwardsMap[row[2].trim()] = row[1].trim(); - console.log("mapped old id " + row[2] + " to modern " + row[1] + "\n"); + console.log("mapped old id " + row[2] + " to modern " + row[1] ); } function isDirectory(dir) { @@ -120,7 +118,7 @@ function scanDir(rootDir, dirName, zones) { dirpath = path.join(rootDir, dirName); files = fs.readdirSync(dirpath); - console.log("Scanning dir " + dirpath + "\n"); + console.log("Scanning dir " + dirpath ); for (var i = 0; i < files.length; i++) { file = files[i]; @@ -131,14 +129,14 @@ function scanDir(rootDir, dirName, zones) { var ext = filepath.search(".json"); if (ext !== -1) { - console.log("Found file " + filepath + "\n"); + console.log("Found file " + filepath ); zones[filepath.substring(0, ext).replace(/^zoneinfo\//, "")] = loadFile(path.join(rootDir, filepath)) || {}; } } } } -console.log("\n"); +console.log(""); var timezones = {}; scanDir(toDir, "", timezones); @@ -148,7 +146,7 @@ var countryToZones = {}; for (var i = 0; i < zoneTab.length(); i++) { var row = zoneTab.get(i); - console.log("map " + row[2] + " to " + row[0] + "\n"); + console.log("map " + row[2] + " to " + row[0] ); countries[row[2]] = row[0]; if (!countryToZones[row[0]]) { countryToZones[row[0]] = []; @@ -160,12 +158,12 @@ for (var zone in timezones) { var zoneDef = timezones[zone]; if (typeof(countries[zone]) !== 'undefined') { zoneDef.c = countries[zone]; - console.log("zone " + zone + " country " + zoneDef.c + "\n"); + console.log("zone " + zone + " country " + zoneDef.c ); } else if (typeof(countries[backwardsMap[zone]]) !== 'undefined') { zoneDef.c = countries[backwardsMap[zone]]; - console.log("zone (old) " + zone + " country " + zoneDef.c + "\n"); + console.log("zone (old) " + zone + " country " + zoneDef.c ); } else { - console.log("zone " + zone + " has no country.\n"); + console.log("zone " + zone + " has no country."); } } @@ -188,9 +186,9 @@ for (var zone = 0; zone < windowsZones.windowsZones.mapTimezones.length; zone++) if (timezones[name]) { var other = mapZone["@other"] || mapZone["_other"]; timezones[name].n = other.replace(/[Ss]tandard/, "{c}"); - console.log("zone " + name + " long name is " + timezones[name].n + "\n"); + console.log("zone " + name + " long name is " + timezones[name].n ); } else { - console.log("zone " + name + " long name is missing\n"); + console.log("zone " + name + " long name is missing"); } } } @@ -201,7 +199,7 @@ if (!fs.existsSync(path.join(toDir, "zoneinfo"))) { for (var zone in timezones) { var filepath = path.join(toDir, "zoneinfo", zone + ".json"); - console.log("Writing out zone info file " + filepath + "\n"); + console.log("Writing out zone info file " + filepath ); fs.writeFile(filepath, JSON.stringify(timezones[zone], true, 4), function (err) { if (err) { throw err; @@ -210,7 +208,7 @@ for (var zone in timezones) { } var filepath = path.join(toDir, "zoneinfo/zonetab.json"); -console.log("Writing out zone tab file " + filepath + "\n"); +console.log("Writing out zone tab file " + filepath ); for (var country in countryToZones) { countryToZones[country].sort(); } @@ -220,4 +218,4 @@ fs.writeFile(filepath, JSON.stringify(countryToZones, true, 4), function (err) { } }); -console.log("Done\n"); \ No newline at end of file +console.log("Done"); \ No newline at end of file diff --git a/tools/cldr/genunits.js b/tools/cldr/genunits.js index 3aa62a1342..02df330e6f 100644 --- a/tools/cldr/genunits.js +++ b/tools/cldr/genunits.js @@ -1,7 +1,7 @@ /* * genunits.js - ilib tool to generate the json data about unit formats * - * Copyright © 2013, 2018 JEDLSoft + * Copyright © 2013, 2018, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ function usage() { "-h or --help\n" + " this help\n" + "locale_data_dir\n" + - " the top level of the ilib locale data directory\n"); + " the top level of the ilib locale data directory"); process.exit(1); } @@ -50,9 +50,9 @@ process.argv.forEach(function (val, index, array) { localeDirName = process.argv[2] || "tmp"; console.log("genunits - tool to generate the json data about unit formats from the CLDR data.\n" + - "Copyright (c) 2013, 2018 JEDLSoft\n"); + "Copyright (c) 2013, 2018 JEDLSoft"); -console.log("locale dir: " + localeDirName + "\n"); +console.log("locale dir: " + localeDirName ); if (!fs.existsSync(localeDirName)) { common.makeDirs(localeDirName); @@ -588,7 +588,7 @@ function frameUnits(data, locale, localeData) { return localeData; } -console.log("Loading locale data...\n"); +console.log("Loading locale data..."); cldrData.availableLocales.forEach(function(locale) { var path = "main/" + locale + "/units"; diff --git a/tools/cldr/genweekdata.js b/tools/cldr/genweekdata.js index 14a89c6b8a..a6f04ee5c4 100644 --- a/tools/cldr/genweekdata.js +++ b/tools/cldr/genweekdata.js @@ -1,7 +1,7 @@ /* * genDayofWeek.js - ilib tool to generate the json data about day of the week * - * Copyright © 2013-2018, JEDLSoft + * Copyright © 2013-2018, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,11 +64,11 @@ if (!fs.existsSync(toDir)) { var dayProperties = {"sun":0, "mon":1, "tue":2, "wed":3, "thu":4, "fri":5, "sat":6}; var firstDayOfWeekData = supplementalData.supplemental.weekData.firstDay; var fstOfWeek = {}; -//util.print("data is "+ JSON.stringify(firstDayOfWeekData)); +//console.log("data is "+ JSON.stringify(firstDayOfWeekData)); for (var locale in firstDayOfWeekData) { var filename; - //util.print("day of the week is :"+locale+"\n"); - //util.print("firstDayOfWeekData is "+firstDayOfWeekData[locale]); + //console.log("day of the week is :"+locale); + //console.log("firstDayOfWeekData is "+firstDayOfWeekData[locale]); if (locale && firstDayOfWeekData[locale]) { if (locale.length < 9) { if (locale == "001") { diff --git a/tools/cldr/reversectry.js b/tools/cldr/reversectry.js index 3a4d971e91..ebf3e5fee4 100644 --- a/tools/cldr/reversectry.js +++ b/tools/cldr/reversectry.js @@ -2,7 +2,7 @@ * reversectry.js - ilib tool to generate the ctryreverse.json from * ctrynames.json files for LG specific country data * - * Copyright © 2017, LGE + * Copyright © 2017, 2020 LGE * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ function usage() { "-h or --help\n" + " this help\n" + "source_dir\n" + - ' Where to find json files to compress. Default "."\n'); + ' Where to find json files to compress. Default "."'); process.exit(1); } @@ -46,12 +46,12 @@ if (process.argv.length > 2) { fs.exists(sourcedir, function (exists) { if (!exists) { - console.log("Could not access source directory " + sourcedir + "\n"); + console.log("Could not access source directory " + sourcedir ); usage(); } }); -console.log("source dir: " + sourcedir + "\n"); +console.log("source dir: " + sourcedir ); function walk(root, dir) { var reverse = {}; @@ -81,7 +81,7 @@ function walk(root, dir) { } } catch (err) { console.log("File " + sourcePath + " is not readable or does not contain valid JSON.\n"); - console.log(err + "\n"); + console.log(err ); process.exit(2); } } diff --git a/tools/cldr/test/testcommon.js b/tools/cldr/test/testcommon.js index eb6e2efee8..05939d7b82 100644 --- a/tools/cldr/test/testcommon.js +++ b/tools/cldr/test/testcommon.js @@ -833,7 +833,7 @@ module.exports.testcommon = { } }; common.mergeAndPrune(data); - //util.print("data.a.m.data is " + JSON.stringify(data.a.m.data) + "\n"); + //console.log("data.a.m.data is " + JSON.stringify(data.a.m.data)); test.ok(common.isEmpty(data.a.m.data)); test.done(); }, diff --git a/tools/locmaker/locmaker.js b/tools/locmaker/locmaker.js index a580c91ff4..f7b7d4927a 100644 --- a/tools/locmaker/locmaker.js +++ b/tools/locmaker/locmaker.js @@ -3,7 +3,7 @@ * all of the locale data needed for a particular set of classes with * a particular set of locales. * - * Copyright © 2017, JEDLSoft + * Copyright © 2017, 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ function usage() { "-h or --help\n" + " this help\n" + "toDir\n" + - " directory where the output should go\n"); + " directory where the output should go"); process.exit(1); } @@ -58,7 +58,7 @@ if (!fs.existsSync(localeDir)) { } console.log("locmaker - generate js files containing ilib data for particular locales.\n" + - "Copyright (c) 2017 JEDLSoft\n"); + "Copyright (c) 2017 JEDLSoft"); util.print("output dir: " + toDir + "\n"); diff --git a/tools/phone/gengeoinfo.js b/tools/phone/gengeoinfo.js index 3f1e4516ae..3e82b103a7 100644 --- a/tools/phone/gengeoinfo.js +++ b/tools/phone/gengeoinfo.js @@ -2,7 +2,7 @@ * gennumplan.js - ilib tool to generate the json numplan information from the libphonefmt-js * library * - * Copyright © 2019 JEDLSoft + * Copyright © 2019-2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ if (process.argv.length > 2) { function usage() { console.log("Usage: gengeoinfo.js [-h] [ output_dir ]\n" + - "-h or --help\n" + " this help\n"); + "-h or --help\n" + " this help"); process.exit(1); } @@ -49,7 +49,7 @@ process.argv.forEach(function (val, index, array) { } }); -console.log("gengeoinfo.js - generate the areaInfo.json file.\n"); +console.log("gengeoinfo.js - generate the areaInfo.json file."); function getCountry(file) { var country; @@ -60,7 +60,7 @@ function getCountry(file) { country = metadata["country_calling_codes"][filename]; if (country.length > 1) { - console.log("\n\n"); + console.log(""); console.log("country is more than one......: ", country.length); for (var i=0; i < country.length; i++) { console.log("Country..... ", country[i]); diff --git a/tools/phone/geniddarea.js b/tools/phone/geniddarea.js index 5cae3304fc..7e21ec8f2a 100644 --- a/tools/phone/geniddarea.js +++ b/tools/phone/geniddarea.js @@ -1,7 +1,7 @@ /* * geniddarea.js - ilib tool to generate the json numplan information from the libphonenumber-js library * - * Copyright © 2019 JEDLSoft + * Copyright © 2019-2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ if (process.argv.length > 2) { function usage() { console.log("Usage: geniddarea.js [-h] [ output_dir ]\n" + - "-h or --help\n" + " this help\n"); + "-h or --help\n" + " this help"); process.exit(1); } @@ -46,7 +46,7 @@ process.argv.forEach(function (val, index, array) { } }); -console.log("geniddarea.js - generate the iddarea.json file.\n"); +console.log("geniddarea.js - generate the iddarea.json file."); var metadata = require("./libphonenumber-js/metadata.json"); var countries = require("../../js/data/locale/ctryreverse.json"); diff --git a/tools/phone/gennumplan.js b/tools/phone/gennumplan.js index 224ff9ea34..910bc16953 100644 --- a/tools/phone/gennumplan.js +++ b/tools/phone/gennumplan.js @@ -1,7 +1,7 @@ /* * gennumplan.js - ilib tool to generate the json numplan information from the libphonenumber-js library * - * Copyright © 2019 JEDLSoft + * Copyright © 2019-2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ if (process.argv.length > 2) { function usage() { console.log("Usage: gengeoinfo.js [-h] [ output_dir ]\n" + - "-h or --help\n" + " this help\n"); + "-h or --help\n" + " this help"); process.exit(1); } @@ -59,7 +59,7 @@ process.argv.forEach(function (val, index, array) { } }); -console.log("gennumplan.js - generate the numplan.json file.\n"); +console.log("gennumplan.js - generate the numplan.json file."); var metadata = require("./libphonenumber-js/metadata.json"); var countryData = metadata.countries; diff --git a/tools/phone/genphonefmt.js b/tools/phone/genphonefmt.js index 946e4a621e..96af1b0cce 100644 --- a/tools/phone/genphonefmt.js +++ b/tools/phone/genphonefmt.js @@ -2,7 +2,7 @@ * genphonefmt.js - ilib tool to generate the json phonefmt information from the libphonefmt-js * library * - * Copyright © 2019 JEDLSoft + * Copyright © 2019-2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ if (process.argv.length > 2) { } function usage() { console.log("Usage: gengeoinfo.js [-h] [ output_dir ]\n" + - "-h or --help\n" + " this help\n"); + "-h or --help\n" + " this help"); process.exit(1); } @@ -52,7 +52,7 @@ process.argv.forEach(function (val, index, array) { } }); -console.log("gennumplan.js - generate the numplan.json file.\n"); +console.log("gennumplan.js - generate the numplan.json file."); for (country in sampleNums) { wholeTemplate = {}; diff --git a/tools/phone/genphoneloc.js b/tools/phone/genphoneloc.js index 76a4d47d35..7b3921431e 100644 --- a/tools/phone/genphoneloc.js +++ b/tools/phone/genphoneloc.js @@ -1,7 +1,7 @@ /* * genphoneloc.js - ilib tool to generate the json phoneloc information * - * Copyright © 2019 JEDLSoft + * Copyright © 2019-2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -367,7 +367,7 @@ if (process.argv.length > 2) { function usage() { console.log("Usage: genphoneloc.js [-h] [ output_dir ]\n" + - "-h or --help\n" + " this help\n"); + "-h or --help\n" + " this help"); process.exit(1); } @@ -377,7 +377,7 @@ process.argv.forEach(function (val, index, array) { } }); -console.log("genphoneloc.js - generate the phoneloc.json file.\n"); +console.log("genphoneloc.js - generate the phoneloc.json file."); var metadata = require("./libphonenumber-js/metadata.json"); var countryData = metadata.countries; var callingCode = metadata.country_calling_codes; From dd91bb6e2c6ca255d74081abcd41b116025d2edc Mon Sep 17 00:00:00 2001 From: Edwin Hoogerbeets Date: Thu, 4 Jun 2020 13:51:23 -0700 Subject: [PATCH 10/48] Minor whitespace cleanup --- tools/cldr/gendatefmts.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/cldr/gendatefmts.js b/tools/cldr/gendatefmts.js index 74fcb68312..8ce8fb2abc 100644 --- a/tools/cldr/gendatefmts.js +++ b/tools/cldr/gendatefmts.js @@ -1371,7 +1371,7 @@ function getDateFormats(language, script, region, data) { // if ((key["s"].split(/y/g).length - 1 != 2) && (key["s"].split(/y/g).length - 1 != 4)) { // if (key["m"].split(/y/g).length - 1 == 2) { // key["s"] = key["s"].replace(/[y]+/g, "yy"); - //} + //} // key["s"] = key["s"].replace(/[y]+/g, "yy"); @@ -1404,7 +1404,7 @@ function getDateFormats(language, script, region, data) { //dates["gregorian"]=gregorian; //} - //console.log("gregorian date formats are :"+JSON.stringify(gregorian)+"++++++++++++++++++++++++++++++++++++++++++++"); + //console.log("gregorian date formats are :"+JSON.stringify(gregorian)+"++++++++++++++++++++++++++++++++++++++++++++"); //code to map Time Formats var time_24 = {}; var time_12 = {}; @@ -1901,7 +1901,7 @@ function getDateFormats(language, script, region, data) { //console.log("interval codes are "+JSON.stringify(range)+"++++++++++++++++++++++++++++++++++++++++++++"); gregorian["range"] = range; dates[default_calendar] = gregorian; - //console.log("gregorian date formats are :"+JSON.stringify(gregorian)+"++++++++++++++++++++++++++++++++++++++++++++"); + //console.log("gregorian date formats are :"+JSON.stringify(gregorian)+"++++++++++++++++++++++++++++++++++++++++++++"); return dates; } //console.log("\nMerging and pruning resources..."); @@ -1915,8 +1915,8 @@ function writeDateFormats(language, script, region, data) { } else { def_calendar = "buddhist"; } - //console.log("date formats are :"+JSON.stringify(data)+"++++++++++++++++++++++++++++++++++++++++++++"); - // console.log("default calendar is :"+def_calendar+"++++++++++++++++++++++++++++++++++++++++++++"); + //console.log("date formats are :"+JSON.stringify(data)+"++++++++++++++++++++++++++++++++++++++++++++"); + // console.log("default calendar is :"+def_calendar+"++++++++++++++++++++++++++++++++++++++++++++"); var empty_data = data[def_calendar]["date"]; //var empty_data_time = data["gregorian"]["time"]; From e3f3e6fdebcce1b5b14f7408f270a92e906d6699 Mon Sep 17 00:00:00 2001 From: Edwin Hoogerbeets Date: Thu, 4 Jun 2020 13:51:40 -0700 Subject: [PATCH 11/48] Add rel notes and add travis testing for node 12-14 --- .travis.yml | 3 +++ docs/ReleaseNotes.md | 1 + 2 files changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8cd6eee4fa..041910298e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ node_js: - "9" - "10" - "11" + - "12" + - "13" + - "14" env: - CXX=g++-4.8 before_install: diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index b3a02896ef..591e93ffec 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -10,6 +10,7 @@ New Features: Bug Fixes: * Updated to IANA time zone data 2020a * Put base option back on ResBundle +* Fixed a few tools and dependencies so that ilib works on node v14 Build 009 ------- From d75737a970b65ef1c3a14dea4ed83d5b60dbe0d3 Mon Sep 17 00:00:00 2001 From: Edwin Hoogerbeets Date: Thu, 4 Jun 2020 13:58:19 -0700 Subject: [PATCH 12/48] Make dep on node-expat be 2.3.18 and above --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 54b94a784a..103f274d1e 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "ilib-webpack-plugin": "^1.3.0", "iso-15924": "^2.1.0", "jsdoc2": "^2.4.0", - "node-expat": "2.3.18", + "node-expat": "^2.3.18", "nodeunit": "^0.11.0", "should": "^13.2.3", "tap": "^10.0.2", From ab220a0bf7684d4128823b64a7c14c9bcc143b65 Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Tue, 18 Aug 2020 17:50:26 +0900 Subject: [PATCH 13/48] Add test cases to verify be-BY(Belarusian-Belarus) --- js/test/date/testMeridiems.js | 10 + js/test/date/testMonthTranslation.js | 25 + js/test/date/testSuiteFiles.js | 1 + js/test/date/testWeekdayTranslation.js | 71 + js/test/date/testcalendar.js | 4 +- js/test/date/testclock.js | 9 + js/test/date/testdatefmt_be_BY.js | 1788 +++++++++++++++++++ js/test/date/testdatetimefmt.js | 26 + js/test/daterange/testSuiteFiles.js | 1 + js/test/daterange/testdatefmtrange_be_BY.js | 692 +++++++ js/test/durfmt/testdurfmt2.js | 53 + js/test/number/testcurrency.js | 9 + js/test/number/testnumfmt2.js | 19 + js/test/root/testlocaleinfo.js | 10 + js/test/root/testlocalematch.js | 43 + js/test/root/testscriptinfo.js | 10 + js/test/root/teststrings.js | 70 + js/test/strings-ext/testSuiteFiles.js | 1 + js/test/strings-ext/testlistfmt_be_BY.js | 253 +++ js/test/units/testmeasurement.js | 6 + js/test/units/testunitfmt.js | 24 + 21 files changed, 3123 insertions(+), 2 deletions(-) create mode 100644 js/test/date/testdatefmt_be_BY.js create mode 100644 js/test/daterange/testdatefmtrange_be_BY.js create mode 100644 js/test/strings-ext/testlistfmt_be_BY.js diff --git a/js/test/date/testMeridiems.js b/js/test/date/testMeridiems.js index 44fb518658..6cdf4450cc 100644 --- a/js/test/date/testMeridiems.js +++ b/js/test/date/testMeridiems.js @@ -1972,6 +1972,16 @@ module.exports.testmeridiems = { test.equal(fmt[0].name, "AM"); test.equal(fmt[1].name, "PM"); + test.done(); + }, + testMeridiem_be_BY: function(test) { + test.expect(3); + var fmt = DateFmt.getMeridiemsRange({locale:"be-BY"}); + test.ok(fmt !== null); + + test.equal(fmt[0].name, "AM"); + test.equal(fmt[1].name, "PM"); + test.done(); } } \ No newline at end of file diff --git a/js/test/date/testMonthTranslation.js b/js/test/date/testMonthTranslation.js index d468675dc9..ba4c276bc1 100644 --- a/js/test/date/testMonthTranslation.js +++ b/js/test/date/testMonthTranslation.js @@ -7315,6 +7315,31 @@ module.exports.testmonthtranslation = { test.equal(value[10], "ნოე"); test.equal(value[11], "დეკ"); + test.done(); + }, + testMonthTranslate_be_BY: function(test) { + test.expect(12); + + // full, long: MMMM + // short, medium: MM + + var value = [], i; + var fmt = new DateFmt({locale:"be-BY", date:"m", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + test.equal(value[0], "студзень"); + test.equal(value[1], "люты"); + test.equal(value[2], "сакавік"); + test.equal(value[3], "красавік"); + test.equal(value[4], "май"); + test.equal(value[5], "чэрвень"); + test.equal(value[6], "ліпень"); + test.equal(value[7], "жнівень"); + test.equal(value[8], "верасень"); + test.equal(value[9], "кастрычнік"); + test.equal(value[10], "лістапад"); + test.equal(value[11], "снежань"); test.done(); } } diff --git a/js/test/date/testSuiteFiles.js b/js/test/date/testSuiteFiles.js index dbf16c1a08..e2fbea047f 100644 --- a/js/test/date/testSuiteFiles.js +++ b/js/test/date/testSuiteFiles.js @@ -36,6 +36,7 @@ module.exports.files = [ "testdatefmt_ar_SA.js", "testdatefmt_as_IN.js", "testdatefmt_az_Latn_AZ.js", + "testdatefmt_be_BY.js", "testdatefmt_bg.js", "testdatefmt_bn_IN.js", "testdatefmt_bs_Cyrl_BA.js", diff --git a/js/test/date/testWeekdayTranslation.js b/js/test/date/testWeekdayTranslation.js index ff7f370ff3..73686e5cbe 100644 --- a/js/test/date/testWeekdayTranslation.js +++ b/js/test/date/testWeekdayTranslation.js @@ -11222,6 +11222,77 @@ module.exports.testWeekdayTranslation = { test.equal(value[5], "პ"); test.equal(value[6], "შ"); + test.done(); + }, + testWeekdayTranslationFull_be_BY: function(test) { + // full -> wide + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"be-BY", date:"w", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "нядзеля"); + test.equal(value[1], "панядзелак"); + test.equal(value[2], "аўторак"); + test.equal(value[3], "серада"); + test.equal(value[4], "чацвер"); + test.equal(value[5], "пятніца"); + test.equal(value[6], "субота"); + test.done(); + }, + testWeekdayTranslationLong_be_BY: function(test) { + // long -> abbreviate + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"be-BY", date:"w", length: "long", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "нд"); + test.equal(value[1], "пн"); + test.equal(value[2], "аў"); + test.equal(value[3], "ср"); + test.equal(value[4], "чц"); + test.equal(value[5], "пт"); + test.equal(value[6], "сб"); + + test.done(); + }, + testWeekdayTranslationMedium_be_BY: function(test) { + // medium -> short + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"be-BY", date:"w", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "нд"); + test.equal(value[1], "пн"); + test.equal(value[2], "аў"); + test.equal(value[3], "ср"); + test.equal(value[4], "чц"); + test.equal(value[5], "пт"); + test.equal(value[6], "сб"); + + test.done(); + }, + testWeekdayTranslationShort_be_BY: function(test) { + // short: narrow + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"be-BY", date:"w", length: "short", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "н"); + test.equal(value[1], "п"); + test.equal(value[2], "а"); + test.equal(value[3], "с"); + test.equal(value[4], "ч"); + test.equal(value[5], "п"); + test.equal(value[6], "с"); + test.done(); } } \ No newline at end of file diff --git a/js/test/date/testcalendar.js b/js/test/date/testcalendar.js index aa4593303b..a947bb59a1 100644 --- a/js/test/date/testcalendar.js +++ b/js/test/date/testcalendar.js @@ -23,9 +23,9 @@ if (typeof(LocaleInfo) === "undefined") { module.exports.testcalendar = { testDefaultCalendar_GregorianCaseAll: function(test) { - test.expect(193); + test.expect(194); var localeList = ["ar-AE","ar-BH","ar-DJ","ar-DZ","ar-EG","ar-IQ","ar-JO","ar-KW","ar-LB","ar-LY","ar-MA","ar-MR", - "ar-OM","ar-QA","ar-SA","ar-SD","ar-SY","ar-TN","ar-YE","as-IN","az-Latn-AZ","bg-BG","bn-IN","bs-Latn-BA,bs-Latn-ME", + "ar-OM","ar-QA","ar-SA","ar-SD","ar-SY","ar-TN","ar-YE","as-IN","az-Latn-AZ","be-BY","bg-BG","bn-IN","bs-Latn-BA,bs-Latn-ME", "cs-CZ","da-DK","de-AT","de-CH","de-DE","de-LU","et-EE","el-CY","el-GR","en-AM","en-AU","en-AZ","en-CA","en-GB","en-GH", "en-GM","en-HK","en-IE","en-IN","en-IS","en-JP","en-KE","en-KR","en-LK","en-LR","en-MM","en-MW","en-MY","en-NG","en-NZ", "en-PH","en-PK","en-PR","en-RW","en-SD","en-SG","en-SL","en-TW","en-TZ","en-UG","en-US","en-ZA","en-ZM","es-AR","es-BO", diff --git a/js/test/date/testclock.js b/js/test/date/testclock.js index f6cc085945..bb8840b636 100644 --- a/js/test/date/testclock.js +++ b/js/test/date/testclock.js @@ -1773,6 +1773,15 @@ module.exports.testclock = { test.equal(info.getClock(), 24); + test.done(); + }, + testClock_be_BY: function(test) { + test.expect(2); + var info = new LocaleInfo("be-BY"); + test.ok(info !== null); + + test.equal(info.getClock(), 24); + test.done(); } } diff --git a/js/test/date/testdatefmt_be_BY.js b/js/test/date/testdatefmt_be_BY.js new file mode 100644 index 0000000000..5b1d84c21c --- /dev/null +++ b/js/test/date/testdatefmt_be_BY.js @@ -0,0 +1,1788 @@ +/* + * testdatefmt_be_BY.js - test the date formatter object in Georgian + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(JulianDate) === "undefined") { + var JulianDate = require("../../lib/JulianDate.js"); +} +if (typeof(GregorianDate) === "undefined") { + var GregorianDate = require("../../lib/GregorianDate.js"); +} +if (typeof(DateFmt) === "undefined") { + var DateFmt = require("../../lib/DateFmt.js"); +} +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testdatefmt_be_BY = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + + testDateFmtConstructorEmpty_be_BY: function(test) { + test.expect(1); + var fmt = new DateFmt({locale: "be-BY"}); + + test.ok(fmt !== null); + test.done(); + }, + + testDateFmtSimpleShort_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29.09.11"); + test.done(); + }, + + testDateFmtSimpleMedium_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29.09.2011"); + test.done(); + }, + + testDateFmtSimpleLong_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29 верасня 2011 г."); + test.done(); + }, + + testDateFmtSimpleFull_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 верасня 2011 г.'); + test.done(); + }, + + testDateFmtSimpleTimeShort_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "short", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeMedium_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "medium", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeLong_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", timelength: "long", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeFull_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 1, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '01:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleShort_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "short", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11, 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleMedium_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "medium", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.2011, 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleLong_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "long", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 верасня 2011 г. у 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleFull_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 верасня 2011 г. у 13:45'); + test.done(); + }, + + + testDateFmtTemplateCalendar_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", calendar: "julian", template: "yyyy-MM-dd"}); + test.ok(fmt !== null); + + var date = new JulianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011-09-29"); + test.done(); + }, + + testDateFmtTemplateCalendarIncompatibleDateType_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", calendar: "julian", template: "yyyy-MM-dd HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + // convert automatically to a Julian calendar date + test.equal(fmt.format(date), "2011-09-16 13:45"); + test.done(); + }, + + testDateFmtTemplateClock12SwitchHH_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", clock: "12", template: "HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateClock12Switchkk_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", clock: "12", template: "kk:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateClock24Switchhh_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", clock: "24", template: "hh:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateClock24SwitchKK: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", clock: "24", template: "KK:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault12hh_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", template: "hh:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault12KK: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", template: "KK:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault24HH_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", template: "HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault24kk_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", template: "kk:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + + testDateFmtTypeDate_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "date"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11'); + test.done(); + }, + + testDateFmtTypeTime_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtTypeDateTime_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11, 13:45'); + test.done(); + }, + + testDateFmtShortDateComponentsY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "y"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "11"); + test.done(); + }, + + testDateFmtShortDateComponentsM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "ве"); + test.done(); + }, + + testDateFmtShortDateComponentsN_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "n"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'в'); + test.done(); + }, + + testDateFmtShortDateComponentsD_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "d"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29"); + test.done(); + }, + + testDateFmtShortDateComponentsDM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "dm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09'); + test.done(); + }, + + testDateFmtShortDateComponentsMY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "my"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '09.11'); + test.done(); + }, + + testDateFmtShortDateComponentsDMY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "dmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11'); + test.done(); + }, + + testDateFmtShortDateComponentsWDM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "wdm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'ч, 29.09'); + test.done(); + }, + + testDateFmtShortDateComponentsWDMY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "wdmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'ч, 29.09.11'); + test.done(); + }, + + testDateFmtLongDateComponentsWDM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "wdm", length: "long"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'чц, 29 верасня'); + test.done(); + }, + + testDateFmtFullDateComponentsY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "y"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011"); + test.done(); + }, + + testDateFmtFullDateComponentsM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "верасень"); + test.done(); + }, + + testDateFmtFullDateComponentsD_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "d"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29"); + test.done(); + }, + + testDateFmtFullDateComponentsDM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "dm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 верасня'); + test.done(); + }, + + testDateFmtFullDateComponentsMY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "my"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'верасень 2011 г.'); + test.done(); + }, + + testDateFmtFullDateComponentsDMY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "dmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 верасня 2011 г.'); + test.done(); + }, + + testDateFmtFullDateComponentsWDM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "wdm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'чацвер, 29 верасня'); + test.done(); + }, + + testDateFmtFullDateComponentsWDMY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "wdmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'чацвер, 29 верасня 2011 г.'); + test.done(); + }, + + testDateFmtShortTimeComponentsS_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "s"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "37"); + test.done(); + }, + + testDateFmtShortTimeComponentsM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45"); + test.done(); + }, + + testDateFmtShortTimeComponentsH_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "h"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13"); + test.done(); + }, + + testDateFmtShortTimeComponentsMS_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "ms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "hm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMS_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "hms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMA_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "hma"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + time: "hmz", + timezone: "Europe/Moscow" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 MSK"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMAZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + time: "hmaz", + timezone: "Europe/Moscow" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 MSK"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSA_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "hmsa"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + time: "hmsz", + timezone: "Europe/Moscow" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 MSK"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSAZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + time: "hmsaz", + timezone: "Europe/Moscow" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 MSK"); + test.done(); + }, + + testDateFmtFullTimeComponentsS_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "s"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "37"); + test.done(); + }, + + testDateFmtFullTimeComponentsM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45"); + test.done(); + }, + + testDateFmtFullTimeComponentsH_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "h"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13"); + test.done(); + }, + + testDateFmtFullTimeComponentsMS_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "ms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "hm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMS_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "hms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMA_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "hma"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + length: "full", + time: "hmz", + timezone: "Europe/Moscow" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 MSK"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMAZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + length: "full", + time: "hmaz", + timezone: "Europe/Moscow" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 MSK"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSA_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "hmsa"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + length: "full", + time: "hmsz", + timezone: "Europe/Moscow" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 MSK"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSAZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + length: "full", + time: "hmsaz", + timezone: "Europe/Moscow" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 MSK"); + test.done(); + }, + + testDateFmtWithTimeZoneAndNoDST_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + length: "full", + time: "hmsz", + timezone: "Europe/Moscow" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 12, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 MSK"); + test.done(); + }, + + testDateFmtFormatRelativeWithinMinuteAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 30, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "праз 30 секунд"); + test.done(); + }, +testDateFmtFormatRelativeWithinMinuteBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 44, + second: 30, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "30 секунд таму"); + test.done(); + }, +testDateFmtFormatRelativeWithinHourAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "праз 10 хвілін"); + test.done(); + }, +testDateFmtFormatRelativeWithinHourBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '10 хвілін таму'); + test.done(); + }, +testDateFmtFormatRelativeWithinDayAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 17, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'праз 4 гадзіны'); + test.done(); + }, +testDateFmtFormatRelativeWithinDayBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '4 гадзіны таму'); + test.done(); + }, + + testDateFmtFormatRelativeWithinFortnightAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'праз 4 дні'); + test.done(); + }, +testDateFmtFormatRelativeWithinFortnightBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 16, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '4 дні таму'); + test.done(); + }, + + testDateFmtFormatRelativeWithinQuarterAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'праз 9 тыдняў'); + test.done(); + }, +testDateFmtFormatRelativeWithinQuarterBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '9 тыдняў таму'); + test.done(); + }, + + testDateFmtFormatRelativeWithinTwoYearsAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2013, + month: 1, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'праз 16 месяцаў'); + test.done(); + }, +testDateFmtFormatRelativeWithinTwoYearsBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2010, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '14 месяцаў таму'); + test.done(); + }, + + testDateFmtFormatRelativeYearsAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2025, + month: 10, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'праз 14 гадоў'); + test.done(); + }, +testDateFmtFormatRelativeYearsBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 1990, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '21 год таму'); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/date/testdatetimefmt.js b/js/test/date/testdatetimefmt.js index 2ad5c635b2..0d20d184fc 100644 --- a/js/test/date/testdatetimefmt.js +++ b/js/test/date/testdatetimefmt.js @@ -5128,6 +5128,32 @@ module.exports.testdatetimeformat = { result1 = new DateFmt({locale:"ka-GE", type:"time", time:"ahmsz", length:"full", useNative:false, timezone:"local"}).template; test.equal(result1, "HH:mm:ss z"); + test.done(); + }, + testDateTimeFormat_be_BY: function(test) { + test.expect(7); + + var result1, result2, result3, result4; + + result1 = new DateFmt({locale:"be-BY", type:"date", date:"dmwy", length: "full", useNative:false, timezone:"local"}).template; + result2 = new DateFmt({locale:"be-BY", type:"date", date:"dmwy", length: "long", useNative:false, timezone:"local"}).template; + result3 = new DateFmt({locale:"be-BY", type:"date", date:"dmwy", length: "medium", useNative:false, timezone:"local"}).template; + result4 = new DateFmt({locale:"be-BY", type:"date", date:"dmwy", length: "short", useNative:false, timezone:"local"}).template; + + test.equal(result1, "EEEE, d MMMM yyyy \'г\'."); + test.equal(result2, "EEE, d MMMM yyyy \'г\'."); + test.equal(result3, "EE, d.MM.yyyy"); + test.equal(result4, "E, d.MM.yy"); + + result1 = new DateFmt({locale:"be-BY", type:"datetime", date:"dmwy", length: "full", useNative:false, timezone:"local"}).template; + result2 = new DateFmt({locale:"be-BY", type:"datetime", date:"dmwy", length: "short", useNative:false, timezone:"local"}).template; + + test.equal(result1, "EEEE, d MMMM yyyy \'г\'. \'у\' HH:mm"); + test.equal(result2, "E, d.MM.yy, HH:mm"); + + result1 = new DateFmt({locale:"be-BY", type:"time", time:"ahmsz", length:"full", useNative:false, timezone:"local"}).template; + test.equal(result1, "HH:mm:ss z"); + test.done(); } } \ No newline at end of file diff --git a/js/test/daterange/testSuiteFiles.js b/js/test/daterange/testSuiteFiles.js index d79236ec11..f86795c407 100644 --- a/js/test/daterange/testSuiteFiles.js +++ b/js/test/daterange/testSuiteFiles.js @@ -26,6 +26,7 @@ module.exports.files = [ "testdatefmtrange_ar_SA.js", "testdatefmtrange_as_IN.js", "testdatefmtrange_az_Latn_AZ.js", + "testdatefmtrange_be_BY.js", "testdatefmtrange_bg_BG.js", "testdatefmtrange_bn_IN.js", "testdatefmtrange_bs_Latn_BA.js", diff --git a/js/test/daterange/testdatefmtrange_be_BY.js b/js/test/daterange/testdatefmtrange_be_BY.js new file mode 100644 index 0000000000..e3858558a1 --- /dev/null +++ b/js/test/daterange/testdatefmtrange_be_BY.js @@ -0,0 +1,692 @@ +/* + * testdatefmtrange_be_BY.js - test the date range formatter object Georgian/Georgia + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(GregorianDate) === "undefined") { + var GregorianDate = require("../../lib/GregorianDate.js"); +} +if (typeof(DateRngFmt) === "undefined") { + var DateRngFmt = require("../../lib/DateRngFmt.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testdatefmtrange_be_BY = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + + testDateRngFmtkaGERangeInDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "31.12.11, 13:45 – 14:30"); + test.done(); + }, + testDateRngFmtkaGERangeInDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "31.12.2011, 13:45 – 14:30"); + test.done(); + }, + testDateRngFmtkaGERangeInDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "31 снежня 2011 г. у 13:45 – 14:30"); + test.done(); + }, + testDateRngFmtkaGERangeInDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "31 снежня 2011 г. у 13:45 – 14:30"); + test.done(); + }, + + testDateRngFmtkaGERangeNextDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "30.12.11, 13:45 – 31.12.11, 14:30"); + test.done(); + }, + testDateRngFmtkaGERangeNextDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "30.12.2011, 13:45 – 31.12.2011, 14:30"); + test.done(); + }, + testDateRngFmtkaGERangeNextDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "30 снежня 2011 г. у 13:45 – 31 снежня 2011 г. у 14:30"); + test.done(); + }, + testDateRngFmtkaGERangeNextDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "30 снежня 2011 г. у 13:45 – 31 снежня 2011 г. у 14:30"); + test.done(); + }, + + testDateRngFmtkaGERangeMultiDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31.12.11"); + test.done(); + }, + testDateRngFmtkaGERangeMultiDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31.12.2011"); + test.done(); + }, + testDateRngFmtkaGERangeMultiDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31 снежня 2011 г."); + test.done(); + }, + testDateRngFmtkaGERangeMultiDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31 снежня 2011 г."); + test.done(); + }, + + testDateRngFmtkaGERangeNextMonthShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20.11 – 31.12.11"); + test.done(); + }, + testDateRngFmtkaGERangeNextMonthMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20.11 – 31.12.2011"); + test.done(); + }, + testDateRngFmtkaGERangeNextMonthLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 лістапада – 31 снежня 2011 г."); + test.done(); + }, + testDateRngFmtkaGERangeNextMonthFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 лістапада – 31 снежня 2011 г."); + test.done(); + }, + + testDateRngFmtkaGERangeNextYearShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20.11.11 – 31.01.12"); + test.done(); + }, + testDateRngFmtkaGERangeNextYearMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20.11.2011 – 31.01.2012"); + test.done(); + }, + testDateRngFmtkaGERangeNextYearLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 лістапада 2011 г. – 31 студзеня 2012 г."); + test.done(); + }, + testDateRngFmtkaGERangeNextYearFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 лістапада 2011 г. – 31 студзеня 2012 г."); + test.done(); + }, + + testDateRngFmtkaGERangeMultiYearShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "11.11 – 01.14"); + test.done(); + }, + testDateRngFmtkaGERangeMultiYearMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "11.2011 – 01.2014"); + test.done(); + }, + testDateRngFmtkaGERangeMultiYearLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "лістапада 2011 г. – студзеня 2014 г."); + test.done(); + }, + testDateRngFmtkaGERangeMultiYearFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "лістапада 2011 г. – студзеня 2014 г."); + test.done(); + }, + testDateRngFmtkaGEManyYearsFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2064, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011 – 2064"); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/durfmt/testdurfmt2.js b/js/test/durfmt/testdurfmt2.js index 5d8c54d100..dece5ed04c 100644 --- a/js/test/durfmt/testdurfmt2.js +++ b/js/test/durfmt/testdurfmt2.js @@ -9035,6 +9035,59 @@ module.exports.testdurfmt2 = { test.equal(clockformatted_18[2], '18სთ, 18წთ, 18წმ'); test.equal(clockformatted_18[3], '18სთ, 18წთ, 18წმ'); + test.done(); + }, + testDurFmt_be_BY: function(test) { + test.expect(24); + // 1 3 100 + var textfmt; + var data = setVariable(); + var length = data["fullLength"]; + + var textformatted_1 = [], textformatted_3 = [], textformatted_100 = []; + var clockformatted_1 = [], clockformatted_3 = [], clockformatted_100 = []; + + for (var i=0; i<4; i++) { + textfmt = new DurationFmt({locale: "be-BY", style:"text", length:length[i]}); + textformatted_1.push(textfmt.format({year: 1,month: 1,week: 1,day: 1}).toString()); + textformatted_3.push(textfmt.format({year: 3,month: 3,week: 3,day: 3}).toString()); + textformatted_100.push(textfmt.format({year: 100,month: 100,week: 100,day: 100}).toString()); + + clockformatted_1.push(textfmt.format({hour: 1,minute: 1,second: 1}).toString()); + clockformatted_3.push(textfmt.format({hour: 3,minute: 3,second: 3}).toString()); + clockformatted_100.push(textfmt.format({hour: 100,minute: 100,second: 100}).toString()); + } + + test.equal(textformatted_1[0], '1 год 1 месяц 1 тыдзень 1 суткі'); + test.equal(textformatted_1[1], '1 г. 1 мес. 1 тыдз. 1 сут'); + test.equal(textformatted_1[2], '1 г. 1 мес. 1 тыдз. 1 сут'); + test.equal(textformatted_1[3], '1 г. 1 мес. 1 тыдз. 1 сут'); + + test.equal(textformatted_3[0], '3 гады 3 месяца 3 тыдні 3 сутак'); + test.equal(textformatted_3[1], '3 г. 3 мес. 3 тыдз. 3 сут'); + test.equal(textformatted_3[2], '3 г. 3 мес. 3 тыдз. 3 сут'); + test.equal(textformatted_3[3], '3 г. 3 мес. 3 тыдз. 3 сут'); + + test.equal(textformatted_100[0], '100 гадоў 100 месяцаў 100 тыдняў 100 сутак'); + test.equal(textformatted_100[1], '100 г. 100 мес. 100 тыдз. 100 сут'); + test.equal(textformatted_100[2], '100 г. 100 мес. 100 тыдз. 100 сут'); + test.equal(textformatted_100[3], '100 г. 100 мес. 100 тыдз. 100 сут'); + + test.equal(clockformatted_1[0], '1 гадзіна 1 хвіліна 1 секунда'); + test.equal(clockformatted_1[1], '1 гадз 1 хв 1 с'); + test.equal(clockformatted_1[2], '1 гадз 1 хв 1 с'); + test.equal(clockformatted_1[3], '1 гадз 1 хв 1 с'); + + test.equal(clockformatted_3[0], '3 гадзіны 3 хвіліны 3 секунды'); + test.equal(clockformatted_3[1], '3 гадз 3 хв 3 с'); + test.equal(clockformatted_3[2], '3 гадз 3 хв 3 с'); + test.equal(clockformatted_3[3], '3 гадз 3 хв 3 с'); + + test.equal(clockformatted_100[0], '100 гадзін 100 хвілін 100 секунд'); + test.equal(clockformatted_100[1], '100 гадз 100 хв 100 с'); + test.equal(clockformatted_100[2], '100 гадз 100 хв 100 с'); + test.equal(clockformatted_100[3], '100 гадз 100 хв 100 с'); + test.done(); } } diff --git a/js/test/number/testcurrency.js b/js/test/number/testcurrency.js index 4ebc9bedf3..f9e736488d 100644 --- a/js/test/number/testcurrency.js +++ b/js/test/number/testcurrency.js @@ -1902,6 +1902,15 @@ module.exports.testcurrency = { test.equal(info.getCurrency(), "GEL"); + test.done(); + }, + testCurrency_be_BY: function(test) { + test.expect(2); + var info = new LocaleInfo("be-BY"); + test.ok(info !== null); + + test.equal(info.getCurrency(), "BYN"); + test.done(); } }; diff --git a/js/test/number/testnumfmt2.js b/js/test/number/testnumfmt2.js index 845f03f896..86cfb57981 100644 --- a/js/test/number/testnumfmt2.js +++ b/js/test/number/testnumfmt2.js @@ -3773,5 +3773,24 @@ module.exports.testnumfmt2 = { test.equal(li.getCurrencyFormats().commonNegative, "-{n} {s}"); test.equal(curfmt.format(57.05), "57,05 ₾"); //GEL test.done(); + }, + testNumFmt_be_BY: function(test) { + test.expect(9); + var li = new LocaleInfo("be-BY"); + var fmt = new NumFmt({locale:"be-BY", type:"standard", useNative:false}); + test.equal(li.getDecimalSeparator(), ","); + test.equal(li.getGroupingSeparator(), " "); + test.equal(fmt.format(123456789.45), "123 456 789,45"); + + var pctfmt = new NumFmt({locale:"be-BY", type:"percentage", useNative:false}); + test.equal(li.getPercentageFormat(), "{n} %"); + test.equal(li.getNegativePercentageFormat(), "-{n} %"); + test.equal(pctfmt.format(34), "34 %"); + + var curfmt = new NumFmt({locale: "be-BY", type: "currency", useNative:false, currency:li.getCurrency()}); + test.equal(li.getCurrencyFormats().common, "{n} {s}"); + test.equal(li.getCurrencyFormats().commonNegative, "-{n} {s}"); + test.equal(curfmt.format(57.05), "57,05 р."); //BYN + test.done(); } } \ No newline at end of file diff --git a/js/test/root/testlocaleinfo.js b/js/test/root/testlocaleinfo.js index 9949aaee2f..282e824c93 100644 --- a/js/test/root/testlocaleinfo.js +++ b/js/test/root/testlocaleinfo.js @@ -13388,5 +13388,15 @@ module.exports.testlocaleinfo = { test.equal(info.getDelimiterQuotationEnd(), "“"); test.equal(info.getPaperSize(), "A4"); test.done(); + }, + testLocaleInfoQuotation_be_BY: function(test) { + test.expect(4); + var info = new LocaleInfo("be-BY"); + test.ok(info !== null); + + test.equal(info.getDelimiterQuotationStart(), "«"); + test.equal(info.getDelimiterQuotationEnd(), "»"); + test.equal(info.getPaperSize(), "A4"); + test.done(); } }; \ No newline at end of file diff --git a/js/test/root/testlocalematch.js b/js/test/root/testlocalematch.js index 850772fff3..e64964bcfe 100644 --- a/js/test/root/testlocalematch.js +++ b/js/test/root/testlocalematch.js @@ -1106,6 +1106,38 @@ module.exports.testlocalematch = { test.equal(locale.getSpec(), "ka-Geor-GE"); test.done(); }, + testLocaleMatcherGetLikelyLocaleByLocaleCode63: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "be-BY" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "be-Cyrl-BY"); + test.done(); + }, + testLocaleMatcherGetLikelyLocaleByLocaleCode64: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "be" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "be-Cyrl-BY"); + test.done(); + },testLocaleMatcherGetLikelyLocaleByLocaleCode65: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "BY" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "be-Cyrl-BY"); + test.done(); + }, testLocaleMatcherMatchExactFullLocale: function(test) { test.expect(2); @@ -1573,6 +1605,17 @@ module.exports.testlocalematch = { test.equal(locale.getSpec(), "ka-GE"); test.done(); }, + testLocaleMatcherGetLikelyLocaleMinimalByLanguage4: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "be" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocaleMinimal(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "be-BY"); + test.done(); + }, testLocaleMatcherGetLikelyLocaleMinimalUzbek: function(test) { test.expect(3); diff --git a/js/test/root/testscriptinfo.js b/js/test/root/testscriptinfo.js index c686e0409e..08f4f29c5b 100644 --- a/js/test/root/testscriptinfo.js +++ b/js/test/root/testscriptinfo.js @@ -2185,5 +2185,15 @@ module.exports.testscriptinfo = { test.equal(li.getScript(), "Geor"); test.equal(scinfo.getScriptDirection(), "ltr"); test.done(); + }, + testScriptInfo_be_BY: function(test) { + test.expect(4); + var li = new LocaleInfo("be-BY"); + var scinfo = new ScriptInfo(li.getScript()); + test.ok(li !== null); + test.ok(scinfo !== null); + test.equal(li.getScript(), "Cyrl"); + test.equal(scinfo.getScriptDirection(), "ltr"); + test.done(); } }; diff --git a/js/test/root/teststrings.js b/js/test/root/teststrings.js index 57a8473b46..e4bbc51461 100644 --- a/js/test/root/teststrings.js +++ b/js/test/root/teststrings.js @@ -3263,6 +3263,46 @@ module.exports.teststrings = { test.equal(str.formatChoice(1), "There items are one"); test.done(); }, + testStringFormatChoiceCharClasses25: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(0), "There are no items."); + test.done(); + }, + testStringFormatChoiceCharClasses26: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(1), "There items are one"); + test.done(); + }, + testStringFormatChoiceCharClasses27: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(3), "The items are few"); + test.done(); + }, + testStringFormatChoiceCharClasses28: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(100), "The items are many"); + test.done(); + }, testStringFormatChoiceCharClassesComplex1: function(test) { test.expect(2); @@ -3670,5 +3710,35 @@ module.exports.teststrings = { test.equal(str.formatChoice(1.7), "Default items"); test.done(); + }, + testStringFormatChoiceDecimal26: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(21.0), "There items are one"); + test.done(); + }, + testStringFormatChoiceDecimal27: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(33.0), "The items are few"); + test.done(); + }, + testStringFormatChoiceDecimal28: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(100.1), "Default items"); + test.done(); } }; \ No newline at end of file diff --git a/js/test/strings-ext/testSuiteFiles.js b/js/test/strings-ext/testSuiteFiles.js index b290555e25..0ea3ee78d1 100644 --- a/js/test/strings-ext/testSuiteFiles.js +++ b/js/test/strings-ext/testSuiteFiles.js @@ -23,6 +23,7 @@ module.exports.files = [ "testlistfmt.js", "testlistfmt_am_ET.js", "testlistfmt_ar.js", + "testlistfmt_be_BY.js", "testlistfmt_bs.js", "testlistfmt_de.js", "testlistfmt_el.js", diff --git a/js/test/strings-ext/testlistfmt_be_BY.js b/js/test/strings-ext/testlistfmt_be_BY.js new file mode 100644 index 0000000000..43fc7fa0a6 --- /dev/null +++ b/js/test/strings-ext/testlistfmt_be_BY.js @@ -0,0 +1,253 @@ +/* + * testlistfmt_be_BY.js - test the list formatter object + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSe-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(ListFmt) === "undefined") { + var ListFmt = require("../../lib/ListFmt.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testlistfmt_be_BY = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + testListFmtkaGENumberFormatOne: function(test) { + var fmt = new ListFmt({ + locale: "be-BY" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін"]), "адзін"); + test.done(); + }, + testListFmtkaGENumberFormatTwo: function(test) { + var fmt = new ListFmt({ + locale: "be-BY" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два"]), "адзін і два"); + test.done(); + }, + testListFmtkaGENumberFormatThree: function(test) { + var fmt = new ListFmt({ + locale: "be-BY" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры"]), "адзін, два і тры"); + test.done(); + }, + testListFmtkaGENumberFormatFour: function(test) { + var fmt = new ListFmt({ + locale: "be-BY" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры"]), "адзін, два, тры і чатыры"); + test.done(); + }, + testListFmtkaGENumberFormatFive: function(test) { + var fmt = new ListFmt({ + locale: "be-BY" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "ხუთი"]), "адзін, два, тры, чатыры і ხუთი"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatOneShort: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін"]), "адзін"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatTwoShort: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два"]), "адзін два"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatThreeShort: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры"]), "адзін два тры"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatFourShort: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры"]), "адзін два тры чатыры"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatFiveShort: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "ხუთი"]), "адзін два тры чатыры ხუთი"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatOneFull: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін"]), "адзін"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatTwoFull: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два"]), "адзін два"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatThreeFull: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры"]), "адзін два тры"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatFourFull: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры"]), "адзін два тры чатыры"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatFiveFull: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "ხუთი"]), "адзін два тры чатыры ხუთი"); + test.done(); + }, + testListFmtORStylekaGENumberFormatOne: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін"]), "адзін"); + test.done(); + }, + testListFmtORStylekaGENumberFormatTwo: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два"]), "адзін ці два"); + test.done(); + }, + testListFmtORStylekaGENumberFormatThree: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры"]), "адзін, два ці тры"); + test.done(); + }, + testListFmtORStylekaGENumberFormatFour: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры"]), "адзін, два, тры ці чатыры"); + test.done(); + }, + testListFmtORStylekaGENumberFormatFiveFull: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "ხუთი"]), "адзін, два, тры, чатыры ці ხუთი"); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/units/testmeasurement.js b/js/test/units/testmeasurement.js index 5480878c96..f5aa03cb8d 100644 --- a/js/test/units/testmeasurement.js +++ b/js/test/units/testmeasurement.js @@ -715,6 +715,12 @@ module.exports.testmeasurement = { test.equal(Measurement.getMeasurementSystemForLocale("zu-ZA"), "metric"); test.done(); }, + testMeasurementGetMeasurementSystemOther4: function(test) { + test.expect(1); + + test.equal(Measurement.getMeasurementSystemForLocale("be-BY"), "metric"); + test.done(); + }, testMeasurementGetMeasurementSystemOtherWithLocaleObj: function(test) { test.expect(1); diff --git a/js/test/units/testunitfmt.js b/js/test/units/testunitfmt.js index 9905fb5758..37db9b1d41 100644 --- a/js/test/units/testunitfmt.js +++ b/js/test/units/testunitfmt.js @@ -1936,6 +1936,30 @@ module.exports.testunitfmt = { test.equal(str, "1,000兆字节/秒"); test.done(); }, + testUnitFormatDigitalSpeed5: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "megabyte/s", + amount: 1000 + }); + + var uf = new UnitFmt({locale: "be-BY",length:"long",autoConvert:false,autoScale: false}); + var str = uf.format(m1); + test.equal(str, "1 000 мегабайта у секунду"); + test.done(); + }, + testUnitFormatDigitalSpeed6: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "megabyte/s", + amount: 1000 + }); + + var uf = new UnitFmt({locale: "be-BY",length:"short",autoConvert:false,autoScale: false}); + var str = uf.format(m1); + test.equal(str, "1 000 МБ/с"); + test.done(); + }, testUnitFormatEnergy11: function(test) { test.expect(1); From f0af18afaa79091d5e9adb791567795168cbc94e Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Wed, 19 Aug 2020 09:23:18 +0900 Subject: [PATCH 14/48] More updates. apply feedback --- js/test/date/testdatefmt_be_BY.js | 38 ++++++++++----------- js/test/daterange/testdatefmtrange_be_BY.js | 2 +- js/test/root/teststrings.js | 10 ++++++ js/test/strings-ext/testlistfmt_be_BY.js | 8 ++--- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/js/test/date/testdatefmt_be_BY.js b/js/test/date/testdatefmt_be_BY.js index 5b1d84c21c..b85b836d6e 100644 --- a/js/test/date/testdatefmt_be_BY.js +++ b/js/test/date/testdatefmt_be_BY.js @@ -1,5 +1,5 @@ /* - * testdatefmt_be_BY.js - test the date formatter object in Georgian + * testdatefmt_be_BY.js - test the date formatter object in Belarus * * Copyright © 2020, JEDLSoft * @@ -1003,7 +1003,7 @@ module.exports.testdatefmt_be_BY = { locale: "be-BY", type: "time", time: "hmz", - timezone: "Europe/Moscow" + timezone: "Europe/Minsk" }); test.ok(fmt !== null); @@ -1017,7 +1017,7 @@ module.exports.testdatefmt_be_BY = { second: 37, millisecond: 0 }); - test.equal(fmt.format(date), "13:45 MSK"); + test.equal(fmt.format(date), "13:45 +03"); test.done(); }, @@ -1027,7 +1027,7 @@ module.exports.testdatefmt_be_BY = { locale: "be-BY", type: "time", time: "hmaz", - timezone: "Europe/Moscow" + timezone: "Europe/Minsk" }); test.ok(fmt !== null); @@ -1041,7 +1041,7 @@ module.exports.testdatefmt_be_BY = { second: 37, millisecond: 0 }); - test.equal(fmt.format(date), "13:45 MSK"); + test.equal(fmt.format(date), "13:45 +03"); test.done(); }, @@ -1070,7 +1070,7 @@ module.exports.testdatefmt_be_BY = { locale: "be-BY", type: "time", time: "hmsz", - timezone: "Europe/Moscow" + timezone: "Europe/Minsk" }); test.ok(fmt !== null); @@ -1084,7 +1084,7 @@ module.exports.testdatefmt_be_BY = { second: 37, millisecond: 0 }); - test.equal(fmt.format(date), "13:45:37 MSK"); + test.equal(fmt.format(date), "13:45:37 +03"); test.done(); }, @@ -1094,7 +1094,7 @@ module.exports.testdatefmt_be_BY = { locale: "be-BY", type: "time", time: "hmsaz", - timezone: "Europe/Moscow" + timezone: "Europe/Minsk" }); test.ok(fmt !== null); @@ -1108,7 +1108,7 @@ module.exports.testdatefmt_be_BY = { second: 37, millisecond: 0 }); - test.equal(fmt.format(date), "13:45:37 MSK"); + test.equal(fmt.format(date), "13:45:37 +03"); test.done(); }, @@ -1252,7 +1252,7 @@ module.exports.testdatefmt_be_BY = { type: "time", length: "full", time: "hmz", - timezone: "Europe/Moscow" + timezone: "Europe/Minsk" }); test.ok(fmt !== null); @@ -1266,7 +1266,7 @@ module.exports.testdatefmt_be_BY = { second: 37, millisecond: 0 }); - test.equal(fmt.format(date), "13:45 MSK"); + test.equal(fmt.format(date), "13:45 +03"); test.done(); }, @@ -1277,7 +1277,7 @@ module.exports.testdatefmt_be_BY = { type: "time", length: "full", time: "hmaz", - timezone: "Europe/Moscow" + timezone: "Europe/Minsk" }); test.ok(fmt !== null); @@ -1291,7 +1291,7 @@ module.exports.testdatefmt_be_BY = { second: 37, millisecond: 0 }); - test.equal(fmt.format(date), "13:45 MSK"); + test.equal(fmt.format(date), "13:45 +03"); test.done(); }, @@ -1321,7 +1321,7 @@ module.exports.testdatefmt_be_BY = { type: "time", length: "full", time: "hmsz", - timezone: "Europe/Moscow" + timezone: "Europe/Minsk" }); test.ok(fmt !== null); @@ -1335,7 +1335,7 @@ module.exports.testdatefmt_be_BY = { second: 37, millisecond: 0 }); - test.equal(fmt.format(date), "13:45:37 MSK"); + test.equal(fmt.format(date), "13:45:37 +03"); test.done(); }, @@ -1346,7 +1346,7 @@ module.exports.testdatefmt_be_BY = { type: "time", length: "full", time: "hmsaz", - timezone: "Europe/Moscow" + timezone: "Europe/Minsk" }); test.ok(fmt !== null); @@ -1360,7 +1360,7 @@ module.exports.testdatefmt_be_BY = { second: 37, millisecond: 0 }); - test.equal(fmt.format(date), "13:45:37 MSK"); + test.equal(fmt.format(date), "13:45:37 +03"); test.done(); }, @@ -1371,7 +1371,7 @@ module.exports.testdatefmt_be_BY = { type: "time", length: "full", time: "hmsz", - timezone: "Europe/Moscow" + timezone: "Europe/Minsk" }); test.ok(fmt !== null); @@ -1385,7 +1385,7 @@ module.exports.testdatefmt_be_BY = { second: 37, millisecond: 0 }); - test.equal(fmt.format(date), "13:45:37 MSK"); + test.equal(fmt.format(date), "13:45:37 +03"); test.done(); }, diff --git a/js/test/daterange/testdatefmtrange_be_BY.js b/js/test/daterange/testdatefmtrange_be_BY.js index e3858558a1..a0b9463b7c 100644 --- a/js/test/daterange/testdatefmtrange_be_BY.js +++ b/js/test/daterange/testdatefmtrange_be_BY.js @@ -1,5 +1,5 @@ /* - * testdatefmtrange_be_BY.js - test the date range formatter object Georgian/Georgia + * testdatefmtrange_be_BY.js - test the date range formatter object Belarussian/Belarus * * Copyright © 2020, JEDLSoft * diff --git a/js/test/root/teststrings.js b/js/test/root/teststrings.js index e4bbc51461..32fd9f0b01 100644 --- a/js/test/root/teststrings.js +++ b/js/test/root/teststrings.js @@ -3303,6 +3303,16 @@ module.exports.teststrings = { test.equal(str.formatChoice(100), "The items are many"); test.done(); }, + testStringFormatChoiceCharClasses29: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(8), "The items are many"); + test.done(); + }, testStringFormatChoiceCharClassesComplex1: function(test) { test.expect(2); diff --git a/js/test/strings-ext/testlistfmt_be_BY.js b/js/test/strings-ext/testlistfmt_be_BY.js index 43fc7fa0a6..15d82ad146 100644 --- a/js/test/strings-ext/testlistfmt_be_BY.js +++ b/js/test/strings-ext/testlistfmt_be_BY.js @@ -77,7 +77,7 @@ module.exports.testlistfmt_be_BY = { test.expect(2); test.ok(fmt !== null); - test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "ხუთი"]), "адзін, два, тры, чатыры і ხუთი"); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "пяць"]), "адзін, два, тры, чатыры і пяць"); test.done(); }, testListFmtUnitStylekaGENumberFormatOneShort: function(test) { @@ -132,7 +132,7 @@ module.exports.testlistfmt_be_BY = { test.expect(2); test.ok(fmt !== null); - test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "ხუთი"]), "адзін два тры чатыры ხუთი"); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "пяць"]), "адзін два тры чатыры пяць"); test.done(); }, testListFmtUnitStylekaGENumberFormatOneFull: function(test) { @@ -192,7 +192,7 @@ module.exports.testlistfmt_be_BY = { test.expect(2); test.ok(fmt !== null); - test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "ხუთი"]), "адзін два тры чатыры ხუთი"); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "пяць"]), "адзін два тры чатыры пяць"); test.done(); }, testListFmtORStylekaGENumberFormatOne: function(test) { @@ -247,7 +247,7 @@ module.exports.testlistfmt_be_BY = { test.expect(2); test.ok(fmt !== null); - test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "ხუთი"]), "адзін, два, тры, чатыры ці ხუთი"); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "пяць"]), "адзін, два, тры, чатыры ці пяць"); test.done(); } }; \ No newline at end of file From 52b0ac5a86fd7daab83854ba3a2263b944186179 Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Wed, 19 Aug 2020 15:15:09 +0900 Subject: [PATCH 15/48] Add dayofWeek test case for be-BY --- js/test/date/testDayOfWeek.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/test/date/testDayOfWeek.js b/js/test/date/testDayOfWeek.js index 0aa7c5b75a..c042b31bf4 100644 --- a/js/test/date/testDayOfWeek.js +++ b/js/test/date/testDayOfWeek.js @@ -1964,6 +1964,16 @@ module.exports.testweekdata = { var info = new LocaleInfo("ka-GE"); test.ok(info !== null); + test.equal(info.getFirstDayOfWeek(), 1); + test.equal(info.getWeekEndStart(), 6); + test.equal(info.getWeekEndEnd(), 0); + test.done(); + }, + testWeekData_be_BY: function(test) { + test.expect(4); + var info = new LocaleInfo("be-BY"); + test.ok(info !== null); + test.equal(info.getFirstDayOfWeek(), 1); test.equal(info.getWeekEndStart(), 6); test.equal(info.getWeekEndEnd(), 0); From 32d8290910e46dd8642d436acda4c4d4d7a34adb Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Wed, 19 Aug 2020 15:45:35 +0900 Subject: [PATCH 16/48] Add one more missing test case which is daterange template --- .../daterange/testdatefmtrange_fmttemplate.js | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/js/test/daterange/testdatefmtrange_fmttemplate.js b/js/test/daterange/testdatefmtrange_fmttemplate.js index 05cf803d08..0ef2975a9b 100644 --- a/js/test/daterange/testdatefmtrange_fmttemplate.js +++ b/js/test/daterange/testdatefmtrange_fmttemplate.js @@ -13864,6 +13864,78 @@ module.exports.testdaterangefmt = { test.equal(templatec30[2], "{sy} – {ey}"); test.equal(templatec30[3], "{sy} – {ey}"); + test.done(); + }, + testDateRngFmt_be_BY: function(test) { + test.expect(36); + var fmt; + var data = setVariables(); + var length = data["fullLength"]; + var abbrLength = data["abbrLength"]; + + var templatec00 = [],templatec01 = [],templatec02 = [],templatec03 = []; + var templatec10 = [],templatec11 = [],templatec12 = [],templatec20 = []; + var templatec30 = []; + + //dmy + for (var i=0; i < 4; i++) { + fmt = new DateRngFmt({locale:"be-BY", length: length[i]}) + templatec00.push(fmt.dateFmt.formats.range["c00"][abbrLength[i]]); + templatec01.push(fmt.dateFmt.formats.range["c01"][abbrLength[i]]); + templatec02.push(fmt.dateFmt.formats.range["c02"][abbrLength[i]]); + templatec03.push(fmt.dateFmt.formats.range["c03"][abbrLength[i]]); + templatec10.push(fmt.dateFmt.formats.range["c10"][abbrLength[i]]); + templatec11.push(fmt.dateFmt.formats.range["c11"][abbrLength[i]]); + templatec12.push(fmt.dateFmt.formats.range["c12"][abbrLength[i]]); + templatec20.push(fmt.dateFmt.formats.range["c20"][abbrLength[i]]); + templatec30.push(fmt.dateFmt.formats.range["c30"][abbrLength[i]]); + } + + test.equal(templatec00[0], '{sd} {sm} {sy} г. у {st} – {et}'); + test.equal(templatec00[1], '{sd} {sm} {sy} г. у {st} – {et}'); + test.equal(templatec00[2], '{sd}.{sm}.{sy}, {st} – {et}'); + test.equal(templatec00[3], '{sd}.{sm}.{sy}, {st} – {et}'); + + test.equal(templatec01[0], '{sd} {sm} {sy} г. у {st} – {ed} {em} {ey} г. у {et}'); + test.equal(templatec01[1], '{sd} {sm} {sy} г. у {st} – {ed} {em} {ey} г. у {et}'); + test.equal(templatec01[2], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + test.equal(templatec01[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + + test.equal(templatec02[1], '{sd} {sm} {sy} г. у {st} – {ed} {em} {ey} г. у {et}'); + test.equal(templatec02[0], '{sd} {sm} {sy} г. у {st} – {ed} {em} {ey} г. у {et}'); + test.equal(templatec02[2], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + test.equal(templatec02[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + + test.equal(templatec03[0], '{sd} {sm} {sy} г. у {st} – {ed} {em} {ey} г. у {et}'); + test.equal(templatec03[1], '{sd} {sm} {sy} г. у {st} – {ed} {em} {ey} г. у {et}'); + test.equal(templatec03[2], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + test.equal(templatec03[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + + test.equal(templatec10[0], '{sd} – {ed} {em} {ey} г.'); + test.equal(templatec10[1], '{sd} – {ed} {em} {ey} г.'); + test.equal(templatec10[2], '{sd} – {ed}.{em}.{ey}'); + test.equal(templatec10[3], '{sd} – {ed}.{em}.{ey}'); + + test.equal(templatec11[0], '{sd} {sm} – {ed} {em} {ey} г.'); + test.equal(templatec11[1], '{sd} {sm} – {ed} {em} {ey} г.'); + test.equal(templatec11[2], '{sd}.{sm} – {ed}.{em}.{ey}'); + test.equal(templatec11[3], '{sd}.{sm} – {ed}.{em}.{ey}'); + + test.equal(templatec12[0], '{sd} {sm} {sy} г. – {ed} {em} {ey} г.'); + test.equal(templatec12[1], '{sd} {sm} {sy} г. – {ed} {em} {ey} г.'); + test.equal(templatec12[2], '{sd}.{sm}.{sy} – {ed}.{em}.{ey}'); + test.equal(templatec12[3], '{sd}.{sm}.{sy} – {ed}.{em}.{ey}'); + + test.equal(templatec20[0], '{sm} {sy} г. – {em} {ey} г.'); + test.equal(templatec20[1], '{sm} {sy} г. – {em} {ey} г.'); + test.equal(templatec20[2], '{sm}.{sy} – {em}.{ey}'); + test.equal(templatec20[3], '{sm}.{sy} – {em}.{ey}'); + + test.equal(templatec30[0], "{sy} – {ey}"); + test.equal(templatec30[1], "{sy} – {ey}"); + test.equal(templatec30[2], "{sy} – {ey}"); + test.equal(templatec30[3], "{sy} – {ey}"); + test.done(); } } \ No newline at end of file From d4a99c742309852399265f186f88f5d44ed349f3 Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Wed, 19 Aug 2020 16:04:08 +0900 Subject: [PATCH 17/48] Fixed wrong test function name --- js/test/daterange/testdatefmtrange_be_BY.js | 50 ++++++++++----------- js/test/root/testcountry.js | 13 ++++++ js/test/strings-ext/testlistfmt_be_BY.js | 40 ++++++++--------- 3 files changed, 58 insertions(+), 45 deletions(-) diff --git a/js/test/daterange/testdatefmtrange_be_BY.js b/js/test/daterange/testdatefmtrange_be_BY.js index a0b9463b7c..53704e2832 100644 --- a/js/test/daterange/testdatefmtrange_be_BY.js +++ b/js/test/daterange/testdatefmtrange_be_BY.js @@ -34,7 +34,7 @@ module.exports.testdatefmtrange_be_BY = { callback(); }, - testDateRngFmtkaGERangeInDayShort: function(test) { + testDateRngFmtbeBYRangeInDayShort: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); test.ok(fmt !== null); @@ -60,7 +60,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "31.12.11, 13:45 – 14:30"); test.done(); }, - testDateRngFmtkaGERangeInDayMedium: function(test) { + testDateRngFmtbeBYRangeInDayMedium: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); test.ok(fmt !== null); @@ -86,7 +86,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "31.12.2011, 13:45 – 14:30"); test.done(); }, - testDateRngFmtkaGERangeInDayLong: function(test) { + testDateRngFmtbeBYRangeInDayLong: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); test.ok(fmt !== null); @@ -112,7 +112,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "31 снежня 2011 г. у 13:45 – 14:30"); test.done(); }, - testDateRngFmtkaGERangeInDayFull: function(test) { + testDateRngFmtbeBYRangeInDayFull: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); test.ok(fmt !== null); @@ -139,7 +139,7 @@ module.exports.testdatefmtrange_be_BY = { test.done(); }, - testDateRngFmtkaGERangeNextDayShort: function(test) { + testDateRngFmtbeBYRangeNextDayShort: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); test.ok(fmt !== null); @@ -165,7 +165,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "30.12.11, 13:45 – 31.12.11, 14:30"); test.done(); }, - testDateRngFmtkaGERangeNextDayMedium: function(test) { + testDateRngFmtbeBYRangeNextDayMedium: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); test.ok(fmt !== null); @@ -191,7 +191,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "30.12.2011, 13:45 – 31.12.2011, 14:30"); test.done(); }, - testDateRngFmtkaGERangeNextDayLong: function(test) { + testDateRngFmtbeBYRangeNextDayLong: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); test.ok(fmt !== null); @@ -217,7 +217,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "30 снежня 2011 г. у 13:45 – 31 снежня 2011 г. у 14:30"); test.done(); }, - testDateRngFmtkaGERangeNextDayFull: function(test) { + testDateRngFmtbeBYRangeNextDayFull: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); test.ok(fmt !== null); @@ -244,7 +244,7 @@ module.exports.testdatefmtrange_be_BY = { test.done(); }, - testDateRngFmtkaGERangeMultiDayShort: function(test) { + testDateRngFmtbeBYRangeMultiDayShort: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); test.ok(fmt !== null); @@ -270,7 +270,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "20 – 31.12.11"); test.done(); }, - testDateRngFmtkaGERangeMultiDayMedium: function(test) { + testDateRngFmtbeBYRangeMultiDayMedium: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); test.ok(fmt !== null); @@ -296,7 +296,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "20 – 31.12.2011"); test.done(); }, - testDateRngFmtkaGERangeMultiDayLong: function(test) { + testDateRngFmtbeBYRangeMultiDayLong: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); test.ok(fmt !== null); @@ -322,7 +322,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "20 – 31 снежня 2011 г."); test.done(); }, - testDateRngFmtkaGERangeMultiDayFull: function(test) { + testDateRngFmtbeBYRangeMultiDayFull: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); test.ok(fmt !== null); @@ -349,7 +349,7 @@ module.exports.testdatefmtrange_be_BY = { test.done(); }, - testDateRngFmtkaGERangeNextMonthShort: function(test) { + testDateRngFmtbeBYRangeNextMonthShort: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); test.ok(fmt !== null); @@ -375,7 +375,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "20.11 – 31.12.11"); test.done(); }, - testDateRngFmtkaGERangeNextMonthMedium: function(test) { + testDateRngFmtbeBYRangeNextMonthMedium: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); test.ok(fmt !== null); @@ -401,7 +401,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "20.11 – 31.12.2011"); test.done(); }, - testDateRngFmtkaGERangeNextMonthLong: function(test) { + testDateRngFmtbeBYRangeNextMonthLong: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); test.ok(fmt !== null); @@ -427,7 +427,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "20 лістапада – 31 снежня 2011 г."); test.done(); }, - testDateRngFmtkaGERangeNextMonthFull: function(test) { + testDateRngFmtbeBYRangeNextMonthFull: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); test.ok(fmt !== null); @@ -454,7 +454,7 @@ module.exports.testdatefmtrange_be_BY = { test.done(); }, - testDateRngFmtkaGERangeNextYearShort: function(test) { + testDateRngFmtbeBYRangeNextYearShort: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); test.ok(fmt !== null); @@ -480,7 +480,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "20.11.11 – 31.01.12"); test.done(); }, - testDateRngFmtkaGERangeNextYearMedium: function(test) { + testDateRngFmtbeBYRangeNextYearMedium: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); test.ok(fmt !== null); @@ -506,7 +506,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "20.11.2011 – 31.01.2012"); test.done(); }, - testDateRngFmtkaGERangeNextYearLong: function(test) { + testDateRngFmtbeBYRangeNextYearLong: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); test.ok(fmt !== null); @@ -532,7 +532,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "20 лістапада 2011 г. – 31 студзеня 2012 г."); test.done(); }, - testDateRngFmtkaGERangeNextYearFull: function(test) { + testDateRngFmtbeBYRangeNextYearFull: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); test.ok(fmt !== null); @@ -559,7 +559,7 @@ module.exports.testdatefmtrange_be_BY = { test.done(); }, - testDateRngFmtkaGERangeMultiYearShort: function(test) { + testDateRngFmtbeBYRangeMultiYearShort: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); test.ok(fmt !== null); @@ -585,7 +585,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "11.11 – 01.14"); test.done(); }, - testDateRngFmtkaGERangeMultiYearMedium: function(test) { + testDateRngFmtbeBYRangeMultiYearMedium: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); test.ok(fmt !== null); @@ -611,7 +611,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "11.2011 – 01.2014"); test.done(); }, - testDateRngFmtkaGERangeMultiYearLong: function(test) { + testDateRngFmtbeBYRangeMultiYearLong: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); test.ok(fmt !== null); @@ -637,7 +637,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "лістапада 2011 г. – студзеня 2014 г."); test.done(); }, - testDateRngFmtkaGERangeMultiYearFull: function(test) { + testDateRngFmtbeBYRangeMultiYearFull: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); test.ok(fmt !== null); @@ -663,7 +663,7 @@ module.exports.testdatefmtrange_be_BY = { test.equal(fmt.format(start, end), "лістапада 2011 г. – студзеня 2014 г."); test.done(); }, - testDateRngFmtkaGEManyYearsFull: function(test) { + testDateRngFmtbeBYManyYearsFull: function(test) { test.expect(2); var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); test.ok(fmt !== null); diff --git a/js/test/root/testcountry.js b/js/test/root/testcountry.js index f059070888..bf6394fe16 100644 --- a/js/test/root/testcountry.js +++ b/js/test/root/testcountry.js @@ -172,6 +172,19 @@ module.exports.testcountry = { test.equal(locale.toString(), "en-AU"); test.done(); }, + testCountryLocale9: function(test) { + test.expect(4); + var ctry = new Country({ + locale: "be-BY" + }); + test.ok(ctry !== null); + + test.equal(ctry.getName("MO"),"Макаа, САР (Кітай)" ); + test.equal(ctry.getCode("Макаа, САР (Кітай)"), "MO"); + var locale = ctry.getLocale(); + test.equal(locale.toString(), "be-BY"); + test.done(); + }, testCountryGetByCodeUnknown: function(test) { try { diff --git a/js/test/strings-ext/testlistfmt_be_BY.js b/js/test/strings-ext/testlistfmt_be_BY.js index 15d82ad146..b2469dc1aa 100644 --- a/js/test/strings-ext/testlistfmt_be_BY.js +++ b/js/test/strings-ext/testlistfmt_be_BY.js @@ -30,7 +30,7 @@ module.exports.testlistfmt_be_BY = { ilib.clearCache(); callback(); }, - testListFmtkaGENumberFormatOne: function(test) { + testListFmtbeBYNumberFormatOne: function(test) { var fmt = new ListFmt({ locale: "be-BY" }); @@ -40,7 +40,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін"]), "адзін"); test.done(); }, - testListFmtkaGENumberFormatTwo: function(test) { + testListFmtbeBYNumberFormatTwo: function(test) { var fmt = new ListFmt({ locale: "be-BY" }); @@ -50,7 +50,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два"]), "адзін і два"); test.done(); }, - testListFmtkaGENumberFormatThree: function(test) { + testListFmtbeBYNumberFormatThree: function(test) { var fmt = new ListFmt({ locale: "be-BY" }); @@ -60,7 +60,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два", "тры"]), "адзін, два і тры"); test.done(); }, - testListFmtkaGENumberFormatFour: function(test) { + testListFmtbeBYNumberFormatFour: function(test) { var fmt = new ListFmt({ locale: "be-BY" }); @@ -70,7 +70,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два", "тры", "чатыры"]), "адзін, два, тры і чатыры"); test.done(); }, - testListFmtkaGENumberFormatFive: function(test) { + testListFmtbeBYNumberFormatFive: function(test) { var fmt = new ListFmt({ locale: "be-BY" }); @@ -80,7 +80,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "пяць"]), "адзін, два, тры, чатыры і пяць"); test.done(); }, - testListFmtUnitStylekaGENumberFormatOneShort: function(test) { + testListFmtUnitStylebeBYNumberFormatOneShort: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "unit" @@ -91,7 +91,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін"]), "адзін"); test.done(); }, - testListFmtUnitStylekaGENumberFormatTwoShort: function(test) { + testListFmtUnitStylebeBYNumberFormatTwoShort: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "unit" @@ -102,7 +102,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два"]), "адзін два"); test.done(); }, - testListFmtUnitStylekaGENumberFormatThreeShort: function(test) { + testListFmtUnitStylebeBYNumberFormatThreeShort: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "unit" @@ -113,7 +113,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два", "тры"]), "адзін два тры"); test.done(); }, - testListFmtUnitStylekaGENumberFormatFourShort: function(test) { + testListFmtUnitStylebeBYNumberFormatFourShort: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "unit" @@ -124,7 +124,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два", "тры", "чатыры"]), "адзін два тры чатыры"); test.done(); }, - testListFmtUnitStylekaGENumberFormatFiveShort: function(test) { + testListFmtUnitStylebeBYNumberFormatFiveShort: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "unit" @@ -135,7 +135,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "пяць"]), "адзін два тры чатыры пяць"); test.done(); }, - testListFmtUnitStylekaGENumberFormatOneFull: function(test) { + testListFmtUnitStylebeBYNumberFormatOneFull: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "unit", @@ -147,7 +147,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін"]), "адзін"); test.done(); }, - testListFmtUnitStylekaGENumberFormatTwoFull: function(test) { + testListFmtUnitStylebeBYNumberFormatTwoFull: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "unit", @@ -159,7 +159,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два"]), "адзін два"); test.done(); }, - testListFmtUnitStylekaGENumberFormatThreeFull: function(test) { + testListFmtUnitStylebeBYNumberFormatThreeFull: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "unit", @@ -171,7 +171,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два", "тры"]), "адзін два тры"); test.done(); }, - testListFmtUnitStylekaGENumberFormatFourFull: function(test) { + testListFmtUnitStylebeBYNumberFormatFourFull: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "unit", @@ -183,7 +183,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два", "тры", "чатыры"]), "адзін два тры чатыры"); test.done(); }, - testListFmtUnitStylekaGENumberFormatFiveFull: function(test) { + testListFmtUnitStylebeBYNumberFormatFiveFull: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "unit", @@ -195,7 +195,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "пяць"]), "адзін два тры чатыры пяць"); test.done(); }, - testListFmtORStylekaGENumberFormatOne: function(test) { + testListFmtORStylebeBYNumberFormatOne: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "disjunction" @@ -206,7 +206,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін"]), "адзін"); test.done(); }, - testListFmtORStylekaGENumberFormatTwo: function(test) { + testListFmtORStylebeBYNumberFormatTwo: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "disjunction" @@ -217,7 +217,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два"]), "адзін ці два"); test.done(); }, - testListFmtORStylekaGENumberFormatThree: function(test) { + testListFmtORStylebeBYNumberFormatThree: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "disjunction" @@ -228,7 +228,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два", "тры"]), "адзін, два ці тры"); test.done(); }, - testListFmtORStylekaGENumberFormatFour: function(test) { + testListFmtORStylebeBYNumberFormatFour: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "disjunction" @@ -239,7 +239,7 @@ module.exports.testlistfmt_be_BY = { test.equal(fmt.format(["адзін", "два", "тры", "чатыры"]), "адзін, два, тры ці чатыры"); test.done(); }, - testListFmtORStylekaGENumberFormatFiveFull: function(test) { + testListFmtORStylebeBYNumberFormatFiveFull: function(test) { var fmt = new ListFmt({ locale: "be-BY", style: "disjunction" From 5740a57e9fafea6d78f2a0a61d8c9fbf7f31325e Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Wed, 19 Aug 2020 18:33:00 +0900 Subject: [PATCH 18/48] Add new testunifmt_be_BY.js file to check the locales's default value. --- js/test/units/testSuiteFiles.js | 1 + js/test/units/testunitfmt_be_BY.js | 330 +++++++++++++++++++++++++++++ 2 files changed, 331 insertions(+) create mode 100644 js/test/units/testunitfmt_be_BY.js diff --git a/js/test/units/testSuiteFiles.js b/js/test/units/testSuiteFiles.js index 152892446b..e1c065731c 100644 --- a/js/test/units/testSuiteFiles.js +++ b/js/test/units/testSuiteFiles.js @@ -31,6 +31,7 @@ module.exports.files = [ "testtemp.js", "testtime.js", "testunitfmt.js", + "testunitfmt_be_BY.js", "testunits.js", "testunitfmtasync.js", "testdigitalspeed.js", diff --git a/js/test/units/testunitfmt_be_BY.js b/js/test/units/testunitfmt_be_BY.js new file mode 100644 index 0000000000..d4cd4660e9 --- /dev/null +++ b/js/test/units/testunitfmt_be_BY.js @@ -0,0 +1,330 @@ +/* + * testunitfmt_be_BY.js - test the unitfmt for be-BY + * + * Copyright © 2020 JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(UnitFmt) === "undefined") { + var UnitFmt = require("../../lib/UnitFmt.js"); +} +if (typeof(Measurement) === "undefined") { + var Measurement = require("../../lib/Measurement.js"); +} + +if (typeof(MeasurementFactory) === "undefined") { + var MeasurementFactory = require("../../lib/MeasurementFactory.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testunitfmt_be_BY = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + testUnitFormatGetLocale_be_BY: function(test) { + test.expect(2); + var uf = new UnitFmt({ + locale: "be-BY" + }); + test.ok(uf.getLocale()); + test.equal(uf.getLocale().getSpec(), "be-BY"); + test.done(); + }, + testGetMeasurementSystem_be_BY: function(test) { + test.expect(1); + + test.equal(Measurement.getMeasurementSystemForLocale("be-BY"), "metric"); + test.done(); + }, + testUnitFormatTemperature1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "fahrenheit", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + length: "short", + autoConvert: true, + maxFractionDigits: 2, + roundingMode: "down" + }); + var str = uf.format(m1); + test.equal(str, "-16,66 °C"); + test.done(); + }, + testUnitFormatTemperature2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "fahrenheit", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + autoScale: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "-16,666666666666668 градусы Цэльсія"); + test.done(); + }, + testUnitFormatArea1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "square centimeter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert:true, + length:"short" + }); + + var str = uf.format(m1); + test.equal(str, "2 см²"); + test.done(); + }, + testUnitFormatArea2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "square centimeter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "long" + }); + + var str = uf.format(m1); + test.equal(str, "2 квадратныя сантыметры"); + test.done(); + }, + testUnitFormatArea3_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "hectare", + amount: 1000 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "short" + }); + + var str = uf.format(m1); + test.equal(str, "10 км²"); + test.done(); + }, + testUnitFormatArea4_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "hectare", + amount: 1000 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "long" + }); + + var str = uf.format(m1); + test.equal(str, "10 квадратных кіламетраў"); + test.done(); + }, + testUnitFormatFuelConsumption1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km/liter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "short" + }); + var str = uf.format(m1); + test.equal(str, "2 км/л"); + test.done(); + }, + testUnitFormatFuelConsumption2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km/liter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "2 кіламетра на літр"); + test.done(); + }, + testUnitFormatLength1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "mile", + amount: 2000 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "short" + }); + var str = uf.format(m1); + test.equal(str, "3,21868 Mm"); + test.done(); + }, + testUnitFormatLength2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "mile", + amount: 2000 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "3,21868 megameters"); + test.done(); + }, + testUnitFormatWithUsageVehicleDistance1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km", + amount: 10 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + usage: "vehicleDistance", + length: "short", + autoConvert: true, + }); + var str = uf.format(m1); + test.equal(str, "10 км"); + test.done(); + }, + testUnitFormatWithUsageVehicleDistance2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km", + amount: 10 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + usage: "vehicleDistance", + length: "long", + autoConvert: true + }); + var str = uf.format(m1); + test.equal(str, "10 кіламетраў"); + test.done(); + }, + testUnitFormatWithUsageFuelVolume1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "imperial gallon", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + usage: "fuelVolume", + length: "short", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "9,09 л"); + test.done(); + }, + testUnitFormatWithUsageFuelVolume2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "imperial gallon", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + usage: "fuelVolume", + length: "long", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "9,09 літра"); + test.done(); + }, + testUnitFormatWithUsageOverrideSignificantDigits1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "kWh", + amount: 102.338322234 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + usage: "electricalEnergy", + length: "short", + significantDigits: "6", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "102,338 кВт·г"); + test.done(); + }, + testUnitFormatWithUsageOverrideSignificantDigits2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "kWh", + amount: 102.338322234 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + usage: "electricalEnergy", + length: "long", + significantDigits: "6", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "102,338 кілават-гадзіны"); + test.done(); + } +} \ No newline at end of file From d4817e1cba531558938cc3020f615f5d004a8abc Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Thu, 20 Aug 2020 11:19:41 +0900 Subject: [PATCH 19/48] Add test cases to verify eu-ES --- js/build.xml | 4 +- js/test/date/testDayOfWeek.js | 10 + js/test/date/testMeridiems.js | 10 + js/test/date/testMonthTranslation.js | 45 + js/test/date/testSuiteFiles.js | 1 + js/test/date/testWeekdayTranslation.js | 71 + js/test/date/testcalendar.js | 6 +- js/test/date/testclock.js | 9 + js/test/date/testdatefmt_eu_ES.js | 1788 +++++++++++++++++ js/test/date/testdatetimefmt.js | 26 + js/test/daterange/testSuiteFiles.js | 1 + js/test/daterange/testdatefmtrange_eu_ES.js | 692 +++++++ .../daterange/testdatefmtrange_fmttemplate.js | 72 + js/test/durfmt/testdurfmt2.js | 41 + js/test/number/testnumfmt2.js | 19 + js/test/root/testcountry.js | 13 + js/test/root/testlocaleinfo.js | 10 + js/test/root/testlocalematch.js | 33 + js/test/root/testscriptinfo.js | 10 + js/test/root/teststrings.js | 40 + js/test/strings-ext/testSuiteFiles.js | 1 + js/test/strings-ext/testlistfmt_eu_ES.js | 253 +++ js/test/units/testunitfmt_eu_ES.js | 331 +++ 23 files changed, 3481 insertions(+), 5 deletions(-) create mode 100644 js/test/date/testdatefmt_eu_ES.js create mode 100644 js/test/daterange/testdatefmtrange_eu_ES.js create mode 100644 js/test/strings-ext/testlistfmt_eu_ES.js create mode 100644 js/test/units/testunitfmt_eu_ES.js diff --git a/js/build.xml b/js/build.xml index 940a8bfce9..616ffcdb9b 100644 --- a/js/build.xml +++ b/js/build.xml @@ -53,8 +53,8 @@ limitations under the License. - - + + diff --git a/js/test/date/testDayOfWeek.js b/js/test/date/testDayOfWeek.js index 0aa7c5b75a..5879a6faa0 100644 --- a/js/test/date/testDayOfWeek.js +++ b/js/test/date/testDayOfWeek.js @@ -1964,6 +1964,16 @@ module.exports.testweekdata = { var info = new LocaleInfo("ka-GE"); test.ok(info !== null); + test.equal(info.getFirstDayOfWeek(), 1); + test.equal(info.getWeekEndStart(), 6); + test.equal(info.getWeekEndEnd(), 0); + test.done(); + }, + testWeekData_eu_ES: function(test) { + test.expect(4); + var info = new LocaleInfo("eu-ES"); + test.ok(info !== null); + test.equal(info.getFirstDayOfWeek(), 1); test.equal(info.getWeekEndStart(), 6); test.equal(info.getWeekEndEnd(), 0); diff --git a/js/test/date/testMeridiems.js b/js/test/date/testMeridiems.js index 44fb518658..35d6740376 100644 --- a/js/test/date/testMeridiems.js +++ b/js/test/date/testMeridiems.js @@ -1972,6 +1972,16 @@ module.exports.testmeridiems = { test.equal(fmt[0].name, "AM"); test.equal(fmt[1].name, "PM"); + test.done(); + }, + testMeridiem_en_ES: function(test) { + test.expect(3); + var fmt = DateFmt.getMeridiemsRange({locale:"eu-ES"}); + test.ok(fmt !== null); + + test.equal(fmt[0].name, "AM"); + test.equal(fmt[1].name, "PM"); + test.done(); } } \ No newline at end of file diff --git a/js/test/date/testMonthTranslation.js b/js/test/date/testMonthTranslation.js index d468675dc9..a2f0368a44 100644 --- a/js/test/date/testMonthTranslation.js +++ b/js/test/date/testMonthTranslation.js @@ -7315,6 +7315,51 @@ module.exports.testmonthtranslation = { test.equal(value[10], "ნოე"); test.equal(value[11], "დეკ"); + test.done(); + }, + testMonthTranslate_eu_ES: function(test) { + test.expect(24); + + // full, long: MMMM + // medium: MMM + // short: M + + var value = [], i; + var fmt = new DateFmt({locale:"eu-ES", date:"m", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + test.equal(value[0], "urtarrila"); + test.equal(value[1], "otsaila"); + test.equal(value[2], "martxoa"); + test.equal(value[3], "apirila"); + test.equal(value[4], "maiatza"); + test.equal(value[5], "ekaina"); + test.equal(value[6], "uztaila"); + test.equal(value[7], "abuztua"); + test.equal(value[8], "iraila"); + test.equal(value[9], "urria"); + test.equal(value[10], "azaroa"); + test.equal(value[11], "abendua"); + + var fmt = new DateFmt({locale:"eu-ES", date:"m", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + + test.equal(value[0], "urt."); + test.equal(value[1], "ots."); + test.equal(value[2], "mar."); + test.equal(value[3], "api."); + test.equal(value[4], "mai."); + test.equal(value[5], "eka."); + test.equal(value[6], "uzt."); + test.equal(value[7], "abu."); + test.equal(value[8], "ira."); + test.equal(value[9], "urr."); + test.equal(value[10], "aza."); + test.equal(value[11], "abe."); + test.done(); } } diff --git a/js/test/date/testSuiteFiles.js b/js/test/date/testSuiteFiles.js index dbf16c1a08..4e79853723 100644 --- a/js/test/date/testSuiteFiles.js +++ b/js/test/date/testSuiteFiles.js @@ -52,6 +52,7 @@ module.exports.files = [ "testdatefmt_es_CO.js", "testdatefmt_es_ES.js", "testdatefmt_et_EE.js", + "testdatefmt_eu_ES.js", "testdatefmt_fa_IR.js", "testdatefmt_fi_FI.js", "testdatefmt_fr_CA.js", diff --git a/js/test/date/testWeekdayTranslation.js b/js/test/date/testWeekdayTranslation.js index ff7f370ff3..ac33f51b0d 100644 --- a/js/test/date/testWeekdayTranslation.js +++ b/js/test/date/testWeekdayTranslation.js @@ -11222,6 +11222,77 @@ module.exports.testWeekdayTranslation = { test.equal(value[5], "პ"); test.equal(value[6], "შ"); + test.done(); + }, + testWeekdayTranslationFull_eu_ES: function(test) { + // full -> wide + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"eu-ES", date:"w", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "igandea"); + test.equal(value[1], "astelehena"); + test.equal(value[2], "asteartea"); + test.equal(value[3], "asteazkena"); + test.equal(value[4], "osteguna"); + test.equal(value[5], "ostirala"); + test.equal(value[6], "larunbata"); + test.done(); + }, + testWeekdayTranslationLong_eu_ES: function(test) { + // long -> abbreviate + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"eu-ES", date:"w", length: "long", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "ig."); + test.equal(value[1], "al."); + test.equal(value[2], "ar."); + test.equal(value[3], "az."); + test.equal(value[4], "og."); + test.equal(value[5], "or."); + test.equal(value[6], "lr."); + + test.done(); + }, + testWeekdayTranslationMedium_eu_ES: function(test) { + // medium -> short + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"eu-ES", date:"w", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "ig."); + test.equal(value[1], "al."); + test.equal(value[2], "ar."); + test.equal(value[3], "az."); + test.equal(value[4], "og."); + test.equal(value[5], "or."); + test.equal(value[6], "lr."); + + test.done(); + }, + testWeekdayTranslationShort_eu_ES: function(test) { + // short: narrow + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"eu-ES", date:"w", length: "short", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "I"); + test.equal(value[1], "A"); + test.equal(value[2], "A"); + test.equal(value[3], "A"); + test.equal(value[4], "O"); + test.equal(value[5], "O"); + test.equal(value[6], "L"); + test.done(); } } \ No newline at end of file diff --git a/js/test/date/testcalendar.js b/js/test/date/testcalendar.js index aa4593303b..ccdb3158fc 100644 --- a/js/test/date/testcalendar.js +++ b/js/test/date/testcalendar.js @@ -23,14 +23,14 @@ if (typeof(LocaleInfo) === "undefined") { module.exports.testcalendar = { testDefaultCalendar_GregorianCaseAll: function(test) { - test.expect(193); + test.expect(195); var localeList = ["ar-AE","ar-BH","ar-DJ","ar-DZ","ar-EG","ar-IQ","ar-JO","ar-KW","ar-LB","ar-LY","ar-MA","ar-MR", - "ar-OM","ar-QA","ar-SA","ar-SD","ar-SY","ar-TN","ar-YE","as-IN","az-Latn-AZ","bg-BG","bn-IN","bs-Latn-BA,bs-Latn-ME", + "ar-OM","ar-QA","ar-SA","ar-SD","ar-SY","ar-TN","ar-YE","as-IN","az-Latn-AZ","be-BY","bg-BG","bn-IN","bs-Latn-BA,bs-Latn-ME", "cs-CZ","da-DK","de-AT","de-CH","de-DE","de-LU","et-EE","el-CY","el-GR","en-AM","en-AU","en-AZ","en-CA","en-GB","en-GH", "en-GM","en-HK","en-IE","en-IN","en-IS","en-JP","en-KE","en-KR","en-LK","en-LR","en-MM","en-MW","en-MY","en-NG","en-NZ", "en-PH","en-PK","en-PR","en-RW","en-SD","en-SG","en-SL","en-TW","en-TZ","en-UG","en-US","en-ZA","en-ZM","es-AR","es-BO", "es-CL","es-CO","es-CR","es-DO","es-EC","es-ES","es-GQ","es-GT","es-HN","es-MX","es-NI","es-PA","es-PE","es-PH","es-PR", - "es-PY","es-SV","es-US","es-UY","es-VE","fi-FI","fr-BE","fr-BF","fr-BJ","fr-CA","fr-CD","fr-CF","fr-CG","fr-CH","fr-CI", + "es-PY","es-SV","es-US","es-UY","es-VE","eu-ES","fi-FI","fr-BE","fr-BF","fr-BJ","fr-CA","fr-CD","fr-CF","fr-CG","fr-CH","fr-CI", "fr-CM","fr-GQ","fr-DJ","fr-DZ","fr-FR","fr-GA","fr-GN","fr-LB","fr-LU","fr-ML","fr-RW","fr-SN","fr-TG","ga-IE","gu-IN", "he-IL","hi-IN","hi-SG","hr-HR","hr-ME","hu-HU","id-ID","is-IS","it-CH","it-IT","ja-JP","ka-GE","kk-Cyrl-KZ","km-KH","kn-IN", "ko-KR","ku-Arab-IQ","lt-LT","lv-LV","mk-MK","ml-IN","mn-Cyrl-MN","mr-IN","ms-MY","ms-SG","nb-NO","nl-BE","nl-NL","pa-IN", diff --git a/js/test/date/testclock.js b/js/test/date/testclock.js index f6cc085945..4f613c0ad9 100644 --- a/js/test/date/testclock.js +++ b/js/test/date/testclock.js @@ -1773,6 +1773,15 @@ module.exports.testclock = { test.equal(info.getClock(), 24); + test.done(); + }, + testClock_eu_ES: function(test) { + test.expect(2); + var info = new LocaleInfo("eu-ES"); + test.ok(info !== null); + + test.equal(info.getClock(), 24); + test.done(); } } diff --git a/js/test/date/testdatefmt_eu_ES.js b/js/test/date/testdatefmt_eu_ES.js new file mode 100644 index 0000000000..dd4ffd2230 --- /dev/null +++ b/js/test/date/testdatefmt_eu_ES.js @@ -0,0 +1,1788 @@ +/* + * testdatefmt_eu_ES.js - test the date formatter object in Basque/Spain + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(JulianDate) === "undefined") { + var JulianDate = require("../../lib/JulianDate.js"); +} +if (typeof(GregorianDate) === "undefined") { + var GregorianDate = require("../../lib/GregorianDate.js"); +} +if (typeof(DateFmt) === "undefined") { + var DateFmt = require("../../lib/DateFmt.js"); +} +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testdatefmt_eu_ES = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + + testDateFmtConstructorEmpty_eu_ES: function(test) { + test.expect(1); + var fmt = new DateFmt({locale: "eu-ES"}); + + test.ok(fmt !== null); + test.done(); + }, + + testDateFmtSimpleShort_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "short"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "11/9/29"); + test.done(); + }, + + testDateFmtSimpleMedium_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "medium"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011(e)ko ira. 29(a)"); + test.done(); + }, + + testDateFmtSimpleLong_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "long"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011(e)ko irailaren 29(a)"); + test.done(); + }, + + testDateFmtSimpleFull_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011(e)ko irailaren 29(a)'); + test.done(); + }, + + testDateFmtSimpleTimeShort_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "short", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeMedium_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "medium", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeLong_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", timelength: "long", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeFull_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 1, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '01:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleShort_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "short", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '11/9/29 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleMedium_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "medium", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011(e)ko ira. 29(a) 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleLong_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "long", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011(e)ko irailaren 29(a) 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleFull_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011(e)ko irailaren 29(a) 13:45'); + test.done(); + }, + + + testDateFmtTemplateCalendar_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", calendar: "julian", template: "yyyy-MM-dd"}); + test.ok(fmt !== null); + + var date = new JulianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011-09-29"); + test.done(); + }, + + testDateFmtTemplateCalendarIncompatibleDateType_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", calendar: "julian", template: "yyyy-MM-dd HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + // convert automatically to a Julian calendar date + test.equal(fmt.format(date), "2011-09-16 13:45"); + test.done(); + }, + + testDateFmtTemplateClock12SwitchHH_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", clock: "12", template: "HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateClock12Switchkk_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", clock: "12", template: "kk:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateClock24Switchhh_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", clock: "24", template: "hh:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateClock24SwitchKK: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", clock: "24", template: "KK:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault12hh_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", template: "hh:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault12KK: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", template: "KK:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault24HH_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", template: "HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault24kk_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", template: "kk:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + + testDateFmtTypeDate_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "date"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '11/9/29'); + test.done(); + }, + + testDateFmtTypeTime_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtTypeDateTime_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '11/9/29 13:45'); + test.done(); + }, + + testDateFmtShortDateComponentsY_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", date: "y"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "11"); + test.done(); + }, + + testDateFmtShortDateComponentsM_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", date: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "9"); + test.done(); + }, + + testDateFmtShortDateComponentsN_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", date: "n"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'i'); + test.done(); + }, + + testDateFmtShortDateComponentsD_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", date: "d"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29"); + test.done(); + }, + + testDateFmtShortDateComponentsDM_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", date: "dm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '9/29'); + test.done(); + }, + + testDateFmtShortDateComponentsMY_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", date: "my"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '11/9'); + test.done(); + }, + + testDateFmtShortDateComponentsDMY_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", date: "dmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '11/9/29'); + test.done(); + }, + + testDateFmtShortDateComponentsWDM_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", date: "wdm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '9/29, O'); + test.done(); + }, + + testDateFmtShortDateComponentsWDMY_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", date: "wdmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '11/9/29, O'); + test.done(); + }, + + testDateFmtLongDateComponentsWDM_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", date: "wdm", length: "long"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'irailaren 29(a), og.'); + test.done(); + }, + + testDateFmtFullDateComponentsY_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full", date: "y"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011"); + test.done(); + }, + + testDateFmtFullDateComponentsM_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full", date: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "iraila"); + test.done(); + }, + + testDateFmtFullDateComponentsD_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full", date: "d"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29"); + test.done(); + }, + + testDateFmtFullDateComponentsDM_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full", date: "dm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'irailaren 29(a)'); + test.done(); + }, + + testDateFmtFullDateComponentsMY_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full", date: "my"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011(e)ko iraila'); + test.done(); + }, + + testDateFmtFullDateComponentsDMY_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full", date: "dmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011(e)ko irailaren 29(a)'); + test.done(); + }, + + testDateFmtFullDateComponentsWDM_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full", date: "wdm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'irailaren 29(a), osteguna'); + test.done(); + }, + + testDateFmtFullDateComponentsWDMY_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full", date: "wdmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011(e)ko irailaren 29(a), osteguna'); + test.done(); + }, + + testDateFmtShortTimeComponentsS_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", time: "s"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "37"); + test.done(); + }, + + testDateFmtShortTimeComponentsM_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", time: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45"); + test.done(); + }, + + testDateFmtShortTimeComponentsH_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", time: "h"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13"); + test.done(); + }, + + testDateFmtShortTimeComponentsMS_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", time: "ms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHM_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", time: "hm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMS_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", time: "hms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMA_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", time: "hma"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMZ_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "eu-ES", + type: "time", + time: "hmz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 (CEST)"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMAZ_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "eu-ES", + type: "time", + time: "hmaz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 (CEST)"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSA_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", time: "hmsa"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSZ_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "eu-ES", + type: "time", + time: "hmsz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 (CEST)"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSAZ_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "eu-ES", + type: "time", + time: "hmsaz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 (CEST)"); + test.done(); + }, + + testDateFmtFullTimeComponentsS_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", length: "full", time: "s"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "37"); + test.done(); + }, + + testDateFmtFullTimeComponentsM_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", length: "full", time: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45"); + test.done(); + }, + + testDateFmtFullTimeComponentsH_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", length: "full", time: "h"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13"); + test.done(); + }, + + testDateFmtFullTimeComponentsMS_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", length: "full", time: "ms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHM_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", length: "full", time: "hm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMS_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", length: "full", time: "hms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMA_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", length: "full", time: "hma"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMZ_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "eu-ES", + type: "time", + length: "full", + time: "hmz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 (CEST)"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMAZ_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "eu-ES", + type: "time", + length: "full", + time: "hmaz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 (CEST)"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSA_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", type: "time", length: "full", time: "hmsa"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSZ_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "eu-ES", + type: "time", + length: "full", + time: "hmsz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 (CEST)"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSAZ_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "eu-ES", + type: "time", + length: "full", + time: "hmsaz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 (CEST)"); + test.done(); + }, + + testDateFmtWithTimeZoneAndNoDST_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "eu-ES", + type: "time", + length: "full", + time: "hmsz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 12, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 (CET)"); + test.done(); + }, + + testDateFmtFormatRelativeWithinMinuteAfter_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 30, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "30 segundo barru"); + test.done(); + }, +testDateFmtFormatRelativeWithinMinuteBefore_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 44, + second: 30, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "Duela 30 segundo"); + test.done(); + }, +testDateFmtFormatRelativeWithinHourAfter_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "10 minutu barru"); + test.done(); + }, +testDateFmtFormatRelativeWithinHourBefore_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'Duela 10 minutu'); + test.done(); + }, +testDateFmtFormatRelativeWithinDayAfter_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 17, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '4 ordu barru'); + test.done(); + }, +testDateFmtFormatRelativeWithinDayBefore_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'Duela 4 ordu'); + test.done(); + }, + + testDateFmtFormatRelativeWithinFortnightAfter_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '4 egun barru'); + test.done(); + }, +testDateFmtFormatRelativeWithinFortnightBefore_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 16, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'Duela 4 egun'); + test.done(); + }, + + testDateFmtFormatRelativeWithinQuarterAfter_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 11, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '9 aste barru'); + test.done(); + }, +testDateFmtFormatRelativeWithinQuarterBefore_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'Duela 9 aste'); + test.done(); + }, + + testDateFmtFormatRelativeWithinTwoYearsAfter_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2013, + month: 1, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '16 hilabete barru'); + test.done(); + }, +testDateFmtFormatRelativeWithinTwoYearsBefore_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2010, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'Duela 14 hilabete'); + test.done(); + }, + + testDateFmtFormatRelativeYearsAfter_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 2025, + month: 10, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '14 urte barru'); + test.done(); + }, +testDateFmtFormatRelativeYearsBefore_eu_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "eu-ES", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "eu-ES", + year: 1990, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'Duela 21 urte'); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/date/testdatetimefmt.js b/js/test/date/testdatetimefmt.js index 2ad5c635b2..2a82fc664a 100644 --- a/js/test/date/testdatetimefmt.js +++ b/js/test/date/testdatetimefmt.js @@ -5128,6 +5128,32 @@ module.exports.testdatetimeformat = { result1 = new DateFmt({locale:"ka-GE", type:"time", time:"ahmsz", length:"full", useNative:false, timezone:"local"}).template; test.equal(result1, "HH:mm:ss z"); + test.done(); + }, + testDateTimeFormat_eu_ES: function(test) { + test.expect(7); + + var result1, result2, result3, result4; + + result1 = new DateFmt({locale:"eu-ES", type:"date", date:"dmwy", length: "full", useNative:false, timezone:"local"}).template; + result2 = new DateFmt({locale:"eu-ES", type:"date", date:"dmwy", length: "long", useNative:false, timezone:"local"}).template; + result3 = new DateFmt({locale:"eu-ES", type:"date", date:"dmwy", length: "medium", useNative:false, timezone:"local"}).template; + result4 = new DateFmt({locale:"eu-ES", type:"date", date:"dmwy", length: "short", useNative:false, timezone:"local"}).template; + + test.equal(result1, "yyyy(\'e\')\'ko\' MMMM\'ren\' d(\'a\'), EEEE"); + test.equal(result2, "yyyy(\'e\')\'ko\' MMMM\'ren\' d(\'a\'), EEE"); + test.equal(result3, "yyyy(\'e\')\'ko\' MMM d(\'a\'), EE"); + test.equal(result4, "yy/M/d, E"); + + result1 = new DateFmt({locale:"eu-ES", type:"datetime", date:"dmwy", length: "full", useNative:false, timezone:"local"}).template; + result2 = new DateFmt({locale:"eu-ES", type:"datetime", date:"dmwy", length: "short", useNative:false, timezone:"local"}).template; + + test.equal(result1, "yyyy(\'e\')\'ko\' MMMM\'ren\' d(\'a\'), EEEE HH:mm"); + test.equal(result2, "yy/M/d, E HH:mm"); + + result1 = new DateFmt({locale:"eu-ES", type:"time", time:"ahmsz", length:"full", useNative:false, timezone:"local"}).template; + test.equal(result1, "HH:mm:ss (z)"); + test.done(); } } \ No newline at end of file diff --git a/js/test/daterange/testSuiteFiles.js b/js/test/daterange/testSuiteFiles.js index d79236ec11..39051976f5 100644 --- a/js/test/daterange/testSuiteFiles.js +++ b/js/test/daterange/testSuiteFiles.js @@ -41,6 +41,7 @@ module.exports.files = [ "testdatefmtrange_es_UY.js", "testdatefmtrange_es_VE.js", "testdatefmtrange_et_EE.js", + "testdatefmtrange_eu_ES.js", "testdatefmtrange_fa_IR.js", "testdatefmtrange_fi_FI.js", "testdatefmtrange_fr_CA.js", diff --git a/js/test/daterange/testdatefmtrange_eu_ES.js b/js/test/daterange/testdatefmtrange_eu_ES.js new file mode 100644 index 0000000000..4021fda9be --- /dev/null +++ b/js/test/daterange/testdatefmtrange_eu_ES.js @@ -0,0 +1,692 @@ +/* + * testdatefmtrange_eu_ES.js - test the date range formatter object Basque-Spain + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(GregorianDate) === "undefined") { + var GregorianDate = require("../../lib/GregorianDate.js"); +} +if (typeof(DateRngFmt) === "undefined") { + var DateRngFmt = require("../../lib/DateRngFmt.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testdatefmtrange_eu_ES = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + + testDateRngFmteuESRangeInDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "11/12/31 13:45 – 14:30"); + test.done(); + }, + testDateRngFmteuESRangeInDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko abe. 31(a) 13:45 – 14:30"); + test.done(); + }, + testDateRngFmteuESRangeInDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko abenduaren 31(a) 13:45 – 14:30"); + test.done(); + }, + testDateRngFmteuESRangeInDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko abenduaren 31(a) 13:45 – 14:30"); + test.done(); + }, + + testDateRngFmteuESRangeNextDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "11/12/30 13:45 – 11/12/31 14:30"); + test.done(); + }, + testDateRngFmteuESRangeNextDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko abe. 30(a) 13:45 – 2011(e)ko abe. 31(a) 14:30"); + test.done(); + }, + testDateRngFmteuESRangeNextDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko abenduaren 30(a) 13:45 – 2011(e)ko abenduaren 31(a) 14:30"); + test.done(); + }, + testDateRngFmteuESRangeNextDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko abenduaren 30(a) 13:45 – 2011(e)ko abenduaren 31(a) 14:30"); + test.done(); + }, + + testDateRngFmteuESRangeMultiDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "11/12/20 – 31"); + test.done(); + }, + testDateRngFmteuESRangeMultiDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko abe. 20(a) – 31"); + test.done(); + }, + testDateRngFmteuESRangeMultiDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko abenduaren 20(a) – 31"); + test.done(); + }, + testDateRngFmteuESRangeMultiDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko abenduaren 20(a) – 31"); + test.done(); + }, + + testDateRngFmteuESRangeNextMonthShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "11/11/20 – 11/12/31"); + test.done(); + }, + testDateRngFmteuESRangeNextMonthMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko aza. 20(a) – 2011(e)ko abe. 31(a)"); + test.done(); + }, + testDateRngFmteuESRangeNextMonthLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko azaroaren 20(a) – abenduaren 31(a)"); + test.done(); + }, + testDateRngFmteuESRangeNextMonthFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko azaroaren 20(a) – abenduaren 31(a)"); + test.done(); + }, + + testDateRngFmteuESRangeNextYearShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "11/11/20 – 12/1/31"); + test.done(); + }, + testDateRngFmteuESRangeNextYearMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko aza. 20(a) – 2012(e)ko urt. 31(a)"); + test.done(); + }, + testDateRngFmteuESRangeNextYearLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko azaroaren 20(a) – 2012(e)ko urtarrilaren 31(a)"); + test.done(); + }, + testDateRngFmteuESRangeNextYearFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko azaroaren 20(a) – 2012(e)ko urtarrilaren 31(a)"); + test.done(); + }, + + testDateRngFmteuESRangeMultiYearShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "11/11 – 14/1"); + test.done(); + }, + testDateRngFmteuESRangeMultiYearMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko aza. – 2014(e)ko urt."); + test.done(); + }, + testDateRngFmteuESRangeMultiYearLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko azaroa – 2014(e)ko urtarrila"); + test.done(); + }, + testDateRngFmteuESRangeMultiYearFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011(e)ko azaroa – 2014(e)ko urtarrila"); + test.done(); + }, + testDateRngFmteuESManyYearsFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "eu-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2064, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011 – 2064"); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/daterange/testdatefmtrange_fmttemplate.js b/js/test/daterange/testdatefmtrange_fmttemplate.js index 05cf803d08..150881ed35 100644 --- a/js/test/daterange/testdatefmtrange_fmttemplate.js +++ b/js/test/daterange/testdatefmtrange_fmttemplate.js @@ -13864,6 +13864,78 @@ module.exports.testdaterangefmt = { test.equal(templatec30[2], "{sy} – {ey}"); test.equal(templatec30[3], "{sy} – {ey}"); + test.done(); + }, + testDateRngFmt_eu_ES: function(test) { + test.expect(36); + var fmt; + var data = setVariables(); + var length = data["fullLength"]; + var abbrLength = data["abbrLength"]; + + var templatec00 = [],templatec01 = [],templatec02 = [],templatec03 = []; + var templatec10 = [],templatec11 = [],templatec12 = [],templatec20 = []; + var templatec30 = []; + + //yme + for (var i=0; i < 4; i++) { + fmt = new DateRngFmt({locale:"eu-ES", length: length[i]}) + templatec00.push(fmt.dateFmt.formats.range["c00"][abbrLength[i]]); + templatec01.push(fmt.dateFmt.formats.range["c01"][abbrLength[i]]); + templatec02.push(fmt.dateFmt.formats.range["c02"][abbrLength[i]]); + templatec03.push(fmt.dateFmt.formats.range["c03"][abbrLength[i]]); + templatec10.push(fmt.dateFmt.formats.range["c10"][abbrLength[i]]); + templatec11.push(fmt.dateFmt.formats.range["c11"][abbrLength[i]]); + templatec12.push(fmt.dateFmt.formats.range["c12"][abbrLength[i]]); + templatec20.push(fmt.dateFmt.formats.range["c20"][abbrLength[i]]); + templatec30.push(fmt.dateFmt.formats.range["c30"][abbrLength[i]]); + } + + test.equal(templatec00[0], '{sy}(e)ko {sm}ren {sd}(a) {st} – {et}'); + test.equal(templatec00[1], '{sy}(e)ko {sm}ren {sd}(a) {st} – {et}'); + test.equal(templatec00[2], '{sy}(e)ko {sm} {sd}(a) {st} – {et}'); + test.equal(templatec00[3], '{sy}/{sm}/{sd} {st} – {et}'); + + test.equal(templatec01[0], '{sy}(e)ko {sm}ren {sd}(a) {st} – {ey}(e)ko {em}ren {ed}(a) {et}'); + test.equal(templatec01[1], '{sy}(e)ko {sm}ren {sd}(a) {st} – {ey}(e)ko {em}ren {ed}(a) {et}'); + test.equal(templatec01[2], '{sy}(e)ko {sm} {sd}(a) {st} – {ey}(e)ko {em} {ed}(a) {et}'); + test.equal(templatec01[3], '{sy}/{sm}/{sd} {st} – {ey}/{em}/{ed} {et}'); + + test.equal(templatec02[1], '{sy}(e)ko {sm}ren {sd}(a) {st} – {ey}(e)ko {em}ren {ed}(a) {et}'); + test.equal(templatec02[0], '{sy}(e)ko {sm}ren {sd}(a) {st} – {ey}(e)ko {em}ren {ed}(a) {et}'); + test.equal(templatec02[2], '{sy}(e)ko {sm} {sd}(a) {st} – {ey}(e)ko {em} {ed}(a) {et}'); + test.equal(templatec02[3], '{sy}/{sm}/{sd} {st} – {ey}/{em}/{ed} {et}'); + + test.equal(templatec03[0], '{sy}(e)ko {sm}ren {sd}(a) {st} – {ey}(e)ko {em}ren {ed}(a) {et}'); + test.equal(templatec03[1], '{sy}(e)ko {sm}ren {sd}(a) {st} – {ey}(e)ko {em}ren {ed}(a) {et}'); + test.equal(templatec03[2], '{sy}(e)ko {sm} {sd}(a) {st} – {ey}(e)ko {em} {ed}(a) {et}'); + test.equal(templatec03[3], '{sy}/{sm}/{sd} {st} – {ey}/{em}/{ed} {et}'); + + test.equal(templatec10[0], '{sy}(e)ko {sm}ren {sd}(a) – {ed}'); + test.equal(templatec10[1], '{sy}(e)ko {sm}ren {sd}(a) – {ed}'); + test.equal(templatec10[2], '{sy}(e)ko {sm} {sd}(a) – {ed}'); + test.equal(templatec10[3], '{sy}/{sm}/{sd} – {ed}'); + + test.equal(templatec11[0], '{sy}(e)ko {sm}ren {sd}(a) – {em}ren {ed}(a)'); + test.equal(templatec11[1], '{sy}(e)ko {sm}ren {sd}(a) – {em}ren {ed}(a)'); + test.equal(templatec11[2], '{sy}(e)ko {sm} {sd}(a) – {ey}(e)ko {em} {ed}(a)'); + test.equal(templatec11[3], '{sy}/{sm}/{sd} – {ey}/{em}/{ed}'); + + test.equal(templatec12[0], '{sy}(e)ko {sm}ren {sd}(a) – {ey}(e)ko {em}ren {ed}(a)'); + test.equal(templatec12[1], '{sy}(e)ko {sm}ren {sd}(a) – {ey}(e)ko {em}ren {ed}(a)'); + test.equal(templatec12[2], '{sy}(e)ko {sm} {sd}(a) – {ey}(e)ko {em} {ed}(a)'); + test.equal(templatec12[3], '{sy}/{sm}/{sd} – {ey}/{em}/{ed}'); + + test.equal(templatec20[0], '{sy}(e)ko {sm} – {ey}(e)ko {em}'); + test.equal(templatec20[1], '{sy}(e)ko {sm} – {ey}(e)ko {em}'); + test.equal(templatec20[2], '{sy}(e)ko {sm} – {ey}(e)ko {em}'); + test.equal(templatec20[3], '{sy}/{sm} – {ey}/{em}'); + + test.equal(templatec30[0], "{sy} – {ey}"); + test.equal(templatec30[1], "{sy} – {ey}"); + test.equal(templatec30[2], "{sy} – {ey}"); + test.equal(templatec30[3], "{sy} – {ey}"); + test.done(); } } \ No newline at end of file diff --git a/js/test/durfmt/testdurfmt2.js b/js/test/durfmt/testdurfmt2.js index 5d8c54d100..237d942971 100644 --- a/js/test/durfmt/testdurfmt2.js +++ b/js/test/durfmt/testdurfmt2.js @@ -9035,6 +9035,47 @@ module.exports.testdurfmt2 = { test.equal(clockformatted_18[2], '18სთ, 18წთ, 18წმ'); test.equal(clockformatted_18[3], '18სთ, 18წთ, 18წმ'); + test.done(); + }, + testDurFmt_eu_ES: function(test) { + test.expect(16); + // 1 11 + var textfmt; + var data = setVariable(); + var length = data["fullLength"]; + + var textformatted_1 = [], textformatted_11 = []; + var clockformatted_1 = [], clockformatted_11 = []; + + for (var i=0; i<4; i++) { + textfmt = new DurationFmt({locale: "eu-ES", style:"text", length:length[i]}); + textformatted_1.push(textfmt.format({year: 1,month: 1,week: 1,day: 1}).toString()); + textformatted_11.push(textfmt.format({year: 11,month: 11,week: 11,day: 11}).toString()); + + clockformatted_1.push(textfmt.format({hour: 1,minute: 1,second: 1}).toString()); + clockformatted_11.push(textfmt.format({hour: 11,minute: 11,second: 11}).toString()); + } + + test.equal(textformatted_1[0], '1 urte, 1 hilabete, 1 aste eta 1 egun'); + test.equal(textformatted_1[1], '1 urte, 1 hilabete, 1 aste, 1 egun'); + test.equal(textformatted_1[2], '1 u., 1 hil, 1 aste, 1 e.'); + test.equal(textformatted_1[3], '1 u., 1 hil, 1 aste, 1 e.'); + + test.equal(textformatted_11[0], '11 urte, 11 hilabete, 11 aste eta 11 egun'); + test.equal(textformatted_11[1], '11 urte, 11 hilabete, 11 aste, 11 egun'); + test.equal(textformatted_11[2], '11 u., 11 hil, 11 aste, 11 e.'); + test.equal(textformatted_11[3], '11 u., 11 hil, 11 aste, 11 e.'); + + test.equal(clockformatted_1[0], '1 ordu, 1 minutu eta 1 segundo'); + test.equal(clockformatted_1[1], '1 h, 1 min, 1 s'); + test.equal(clockformatted_1[2], '1 h, 1 min, 1 s'); + test.equal(clockformatted_1[3], '1 h, 1 min, 1 s'); + + test.equal(clockformatted_11[0], '11 ordu, 11 minutu eta 11 segundo'); + test.equal(clockformatted_11[1], '11 h, 11 min, 11 s'); + test.equal(clockformatted_11[2], '11 h, 11 min, 11 s'); + test.equal(clockformatted_11[3], '11 h, 11 min, 11 s'); + test.done(); } } diff --git a/js/test/number/testnumfmt2.js b/js/test/number/testnumfmt2.js index 845f03f896..03d365cd7e 100644 --- a/js/test/number/testnumfmt2.js +++ b/js/test/number/testnumfmt2.js @@ -3773,5 +3773,24 @@ module.exports.testnumfmt2 = { test.equal(li.getCurrencyFormats().commonNegative, "-{n} {s}"); test.equal(curfmt.format(57.05), "57,05 ₾"); //GEL test.done(); + }, + testNumFmt_eu_ES: function(test) { + test.expect(9); + var li = new LocaleInfo("eu-ES"); + var fmt = new NumFmt({locale:"eu-ES", type:"standard", useNative:false}); + test.equal(li.getDecimalSeparator(), ","); + test.equal(li.getGroupingSeparator(), "."); + test.equal(fmt.format(123456789.45), "123.456.789,45"); + + var pctfmt = new NumFmt({locale:"eu-ES", type:"percentage", useNative:false}); + test.equal(li.getPercentageFormat(), "% {n}"); + test.equal(li.getNegativePercentageFormat(), "−% {n}"); + test.equal(pctfmt.format(34), "% 34"); + + var curfmt = new NumFmt({locale: "eu-ES", type: "currency", useNative:false, currency:li.getCurrency()}); + test.equal(li.getCurrencyFormats().common, "{n} {s}"); + test.equal(li.getCurrencyFormats().commonNegative, "−{n} {s}"); + test.equal(curfmt.format(57.05), "57,05 €"); + test.done(); } } \ No newline at end of file diff --git a/js/test/root/testcountry.js b/js/test/root/testcountry.js index f059070888..4d90e8ce1b 100644 --- a/js/test/root/testcountry.js +++ b/js/test/root/testcountry.js @@ -172,6 +172,19 @@ module.exports.testcountry = { test.equal(locale.toString(), "en-AU"); test.done(); }, + testCountryLocale10: function(test) { + test.expect(4); + var ctry = new Country({ + locale: "eu-ES" + }); + test.ok(ctry !== null); + + test.equal(ctry.getName("MO"),"Macau Txinako AEB" ); + test.equal(ctry.getCode("Macau Txinako AEB"), "MO"); + var locale = ctry.getLocale(); + test.equal(locale.toString(), "eu-ES"); + test.done(); + }, testCountryGetByCodeUnknown: function(test) { try { diff --git a/js/test/root/testlocaleinfo.js b/js/test/root/testlocaleinfo.js index 9949aaee2f..f80dae3698 100644 --- a/js/test/root/testlocaleinfo.js +++ b/js/test/root/testlocaleinfo.js @@ -13388,5 +13388,15 @@ module.exports.testlocaleinfo = { test.equal(info.getDelimiterQuotationEnd(), "“"); test.equal(info.getPaperSize(), "A4"); test.done(); + }, + testLocaleInfoQuotation_eu_ES: function(test) { + test.expect(4); + var info = new LocaleInfo("eu-ES"); + test.ok(info !== null); + + test.equal(info.getDelimiterQuotationStart(), "“"); + test.equal(info.getDelimiterQuotationEnd(), "”"); + test.equal(info.getPaperSize(), "A4"); + test.done(); } }; \ No newline at end of file diff --git a/js/test/root/testlocalematch.js b/js/test/root/testlocalematch.js index 850772fff3..df45e976f4 100644 --- a/js/test/root/testlocalematch.js +++ b/js/test/root/testlocalematch.js @@ -1106,6 +1106,28 @@ module.exports.testlocalematch = { test.equal(locale.getSpec(), "ka-Geor-GE"); test.done(); }, + testLocaleMatcherGetLikelyLocaleByLocaleCode66: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "eu-ES" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "eu-Latn-ES"); + test.done(); + }, + testLocaleMatcherGetLikelyLocaleByLocaleCode67: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "eu" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "eu-Latn-ES"); + test.done(); + }, testLocaleMatcherMatchExactFullLocale: function(test) { test.expect(2); @@ -1573,6 +1595,17 @@ module.exports.testlocalematch = { test.equal(locale.getSpec(), "ka-GE"); test.done(); }, + testLocaleMatcherGetLikelyLocaleMinimalByLanguage5: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "eu" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocaleMinimal(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "eu-ES"); + test.done(); + }, testLocaleMatcherGetLikelyLocaleMinimalUzbek: function(test) { test.expect(3); diff --git a/js/test/root/testscriptinfo.js b/js/test/root/testscriptinfo.js index c686e0409e..88d3e3b400 100644 --- a/js/test/root/testscriptinfo.js +++ b/js/test/root/testscriptinfo.js @@ -2185,5 +2185,15 @@ module.exports.testscriptinfo = { test.equal(li.getScript(), "Geor"); test.equal(scinfo.getScriptDirection(), "ltr"); test.done(); + }, + testScriptInfo_eu_ES: function(test) { + test.expect(4); + var li = new LocaleInfo("eu-ES"); + var scinfo = new ScriptInfo(li.getScript()); + test.ok(li !== null); + test.ok(scinfo !== null); + test.equal(li.getScript(), "Latn"); + test.equal(scinfo.getScriptDirection(), "ltr"); + test.done(); } }; diff --git a/js/test/root/teststrings.js b/js/test/root/teststrings.js index 57a8473b46..c066e81e13 100644 --- a/js/test/root/teststrings.js +++ b/js/test/root/teststrings.js @@ -3263,6 +3263,26 @@ module.exports.teststrings = { test.equal(str.formatChoice(1), "There items are one"); test.done(); }, + testStringFormatChoiceCharClasses30: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("eu-ES"); + + test.ok(str !== null); + + test.equal(str.formatChoice(1), "There items are one"); + test.done(); + }, + testStringFormatChoiceCharClasses31: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("eu-ES"); + + test.ok(str !== null); + + test.equal(str.formatChoice(16), "Default items"); + test.done(); + }, testStringFormatChoiceCharClassesComplex1: function(test) { test.expect(2); @@ -3668,6 +3688,26 @@ module.exports.teststrings = { test.ok(str !== null); + test.equal(str.formatChoice(1.7), "Default items"); + test.done(); + }, + testStringFormatChoiceDecimal29: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("eu-ES"); + + test.ok(str !== null); + + test.equal(str.formatChoice(1.0), "There items are one"); + test.done(); + }, + testStringFormatChoiceDecimal30: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("eu-ES"); + + test.ok(str !== null); + test.equal(str.formatChoice(1.7), "Default items"); test.done(); } diff --git a/js/test/strings-ext/testSuiteFiles.js b/js/test/strings-ext/testSuiteFiles.js index b290555e25..70cc1efcc4 100644 --- a/js/test/strings-ext/testSuiteFiles.js +++ b/js/test/strings-ext/testSuiteFiles.js @@ -28,6 +28,7 @@ module.exports.files = [ "testlistfmt_el.js", "testlistfmt_en.js", "testlistfmt_es.js", + "testlistfmt_eu_ES.js", "testlistfmt_fa.js", "testlistfmt_fr.js", "testlistfmt_gu_IN.js", diff --git a/js/test/strings-ext/testlistfmt_eu_ES.js b/js/test/strings-ext/testlistfmt_eu_ES.js new file mode 100644 index 0000000000..a557bd2fb2 --- /dev/null +++ b/js/test/strings-ext/testlistfmt_eu_ES.js @@ -0,0 +1,253 @@ +/* + * testlistfmt_eu_ES.js - test the list formatter object + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSe-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(ListFmt) === "undefined") { + var ListFmt = require("../../lib/ListFmt.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testlistfmt_eu_ES = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + testListFmteuESNumberFormatOne: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat"]), "bat"); + test.done(); + }, + testListFmteuESNumberFormatTwo: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi"]), "bat eta bi"); + test.done(); + }, + testListFmteuESNumberFormatThree: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi", "hiru"]), "bat, bi eta hiru"); + test.done(); + }, + testListFmteuESNumberFormatFour: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi", "hiru", "lau"]), "bat, bi, hiru eta lau"); + test.done(); + }, + testListFmteuESNumberFormatFive: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi", "hiru", "lau", "bost"]), "bat, bi, hiru, lau eta bost"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatOneShort: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat"]), "bat"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatTwoShort: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi"]), "bat eta bi"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatThreeShort: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi", "hiru"]), "bat, bi eta hiru"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatFourShort: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi", "hiru", "lau"]), "bat, bi, hiru eta lau"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatFiveShort: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi", "hiru", "lau", "bost"]), "bat, bi, hiru, lau eta bost"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatOneFull: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat"]), "bat"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatTwoFull: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi"]), "bat eta bi"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatThreeFull: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi", "hiru"]), "bat, bi eta hiru"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatFourFull: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi", "hiru", "lau"]), "bat, bi, hiru eta lau"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatFiveFull: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi", "hiru", "lau", "bost"]), "bat, bi, hiru, lau eta bost"); + test.done(); + }, + testListFmtORStyleeuESNumberFormatOne: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat"]), "bat"); + test.done(); + }, + testListFmtORStyleeuESNumberFormatTwo: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi"]), "bat edo bi"); + test.done(); + }, + testListFmtORStyleeuESNumberFormatThree: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi", "hiru"]), "bat, bi edo hiru"); + test.done(); + }, + testListFmtORStyleeuESNumberFormatFour: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi", "hiru", "lau"]), "bat, bi, hiru edo lau"); + test.done(); + }, + testListFmtORStyleeuESNumberFormatFiveFull: function(test) { + var fmt = new ListFmt({ + locale: "eu-ES", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["bat", "bi", "hiru", "lau", "bost"]), "bat, bi, hiru, lau edo bost"); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/units/testunitfmt_eu_ES.js b/js/test/units/testunitfmt_eu_ES.js new file mode 100644 index 0000000000..cf2a1033ed --- /dev/null +++ b/js/test/units/testunitfmt_eu_ES.js @@ -0,0 +1,331 @@ +/* + * testunitfmt_eu_ES.js - test the unitfmt for eu-ES + * + * Copyright © 2020 JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(UnitFmt) === "undefined") { + var UnitFmt = require("../../lib/UnitFmt.js"); +} +if (typeof(Measurement) === "undefined") { + var Measurement = require("../../lib/Measurement.js"); +} + +if (typeof(MeasurementFactory) === "undefined") { + var MeasurementFactory = require("../../lib/MeasurementFactory.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testunitfmt_eu_ES = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + testUnitFormatGetLocale_eu_ES: function(test) { + test.expect(2); + var uf = new UnitFmt({ + locale: "eu-ES" + }); + test.ok(uf.getLocale()); + test.equal(uf.getLocale().getSpec(), "eu-ES"); + test.done(); + }, + testGetMeasurementSystem_eu_ES: function(test) { + test.expect(1); + + test.equal(Measurement.getMeasurementSystemForLocale("eu-ES"), "metric"); + test.done(); + }, + testUnitFormatTemperature1_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "fahrenheit", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + length: "short", + autoConvert: true, + maxFractionDigits: 2, + roundingMode: "down" + }); + var str = uf.format(m1); + test.equal(str, "−16,66 °C"); + test.done(); + }, + testUnitFormatTemperature2_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "fahrenheit", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + autoConvert: true, + autoScale: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "−16,666666666666668 Celsius gradu"); + test.done(); + }, + + testUnitFormatArea1_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "square centimeter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + autoConvert:true, + length:"short" + }); + + var str = uf.format(m1); + test.equal(str, "2 cm²"); + test.done(); + }, + testUnitFormatArea2_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "square centimeter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + autoConvert: true, + length: "long" + }); + + var str = uf.format(m1); + test.equal(str, "2 zentimetro karratu"); + test.done(); + }, + testUnitFormatArea3_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "hectare", + amount: 1000 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + autoConvert: true, + length: "short" + }); + + var str = uf.format(m1); + test.equal(str, "10 km²"); + test.done(); + }, + testUnitFormatArea4_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "hectare", + amount: 1000 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + autoConvert: true, + length: "long" + }); + + var str = uf.format(m1); + test.equal(str, "10 kilometro karratu"); + test.done(); + }, + testUnitFormatFuelConsumption1_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km/liter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + autoConvert: true, + length: "short" + }); + var str = uf.format(m1); + test.equal(str, "2 km/l"); + test.done(); + }, + testUnitFormatFuelConsumption2_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km/liter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + autoConvert: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "2 kilometro litro bakoitzeko"); + test.done(); + }, + testUnitFormatLength1_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "mile", + amount: 2000 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + autoConvert: true, + length: "short" + }); + var str = uf.format(m1); + test.equal(str, "3,21868 Mm"); + test.done(); + }, + testUnitFormatLength2_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "mile", + amount: 2000 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + autoConvert: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "3,21868 megameters"); + test.done(); + }, + testUnitFormatWithUsageVehicleDistance1_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km", + amount: 10 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + usage: "vehicleDistance", + length: "short", + autoConvert: true, + }); + var str = uf.format(m1); + test.equal(str, "10 km"); + test.done(); + }, + testUnitFormatWithUsageVehicleDistance2_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km", + amount: 10 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + usage: "vehicleDistance", + length: "long", + autoConvert: true + }); + var str = uf.format(m1); + test.equal(str, "10 kilometro"); + test.done(); + }, + testUnitFormatWithUsageFuelVolume1_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "imperial gallon", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + usage: "fuelVolume", + length: "short", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "9,09 l"); + test.done(); + }, + testUnitFormatWithUsageFuelVolume2_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "imperial gallon", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + usage: "fuelVolume", + length: "long", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "9,09 litro"); + test.done(); + }, + testUnitFormatWithUsageOverrideSignificantDigits1_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "kWh", + amount: 102.338322234 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + usage: "electricalEnergy", + length: "short", + significantDigits: "6", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "102,338 kWh"); + test.done(); + }, + testUnitFormatWithUsageOverrideSignificantDigits2_eu_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "kWh", + amount: 102.338322234 + }); + + var uf = new UnitFmt({ + locale: "eu-ES", + usage: "electricalEnergy", + length: "long", + significantDigits: "6", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "102,338 kilowatt-ordu"); + test.done(); + } +} \ No newline at end of file From 1f702ad4a27b9265d81420753788550f0f6edcad Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Thu, 20 Aug 2020 15:48:28 +0900 Subject: [PATCH 20/48] Remove be-BY in the list --- js/test/date/testcalendar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/test/date/testcalendar.js b/js/test/date/testcalendar.js index ccdb3158fc..28e3b88108 100644 --- a/js/test/date/testcalendar.js +++ b/js/test/date/testcalendar.js @@ -23,9 +23,9 @@ if (typeof(LocaleInfo) === "undefined") { module.exports.testcalendar = { testDefaultCalendar_GregorianCaseAll: function(test) { - test.expect(195); + test.expect(194); var localeList = ["ar-AE","ar-BH","ar-DJ","ar-DZ","ar-EG","ar-IQ","ar-JO","ar-KW","ar-LB","ar-LY","ar-MA","ar-MR", - "ar-OM","ar-QA","ar-SA","ar-SD","ar-SY","ar-TN","ar-YE","as-IN","az-Latn-AZ","be-BY","bg-BG","bn-IN","bs-Latn-BA,bs-Latn-ME", + "ar-OM","ar-QA","ar-SA","ar-SD","ar-SY","ar-TN","ar-YE","as-IN","az-Latn-AZ","bg-BG","bn-IN","bs-Latn-BA,bs-Latn-ME", "cs-CZ","da-DK","de-AT","de-CH","de-DE","de-LU","et-EE","el-CY","el-GR","en-AM","en-AU","en-AZ","en-CA","en-GB","en-GH", "en-GM","en-HK","en-IE","en-IN","en-IS","en-JP","en-KE","en-KR","en-LK","en-LR","en-MM","en-MW","en-MY","en-NG","en-NZ", "en-PH","en-PK","en-PR","en-RW","en-SD","en-SG","en-SL","en-TW","en-TZ","en-UG","en-US","en-ZA","en-ZM","es-AR","es-BO", From eeaf2856cadc2cfd6f6f4a9b37115f785a340947 Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Thu, 20 Aug 2020 17:25:40 +0900 Subject: [PATCH 21/48] Add testcase to verify gl-ES --- js/data/locale/gl/dateformats.json | 56 +- js/test/date/testDayOfWeek.js | 10 + js/test/date/testMeridiems.js | 10 + js/test/date/testMonthTranslation.js | 45 + js/test/date/testSuite.html | 1 + js/test/date/testSuiteFiles.js | 1 + js/test/date/testWeekdayTranslation.js | 71 + js/test/date/testcalendar.js | 4 +- js/test/date/testclock.js | 9 + js/test/date/testdatefmt_gl_ES.js | 1788 +++++++++++++++++ js/test/daterange/testSuite.html | 1 + js/test/daterange/testSuiteFiles.js | 1 + .../daterange/testdatefmtrange_fmttemplate.js | 72 + js/test/daterange/testdatefmtrange_gl_ES.js | 692 +++++++ js/test/durfmt/testdurfmt2.js | 41 + js/test/number/testnumfmt2.js | 19 + js/test/root/testlocaleinfo.js | 10 + js/test/root/testlocalematch.js | 33 + js/test/root/testscriptinfo.js | 10 + js/test/root/teststrings.js | 20 + js/test/strings-ext/testSuite.html | 1 + js/test/strings-ext/testSuiteFiles.js | 1 + js/test/strings-ext/testlistfmt_gl_ES.js | 253 +++ js/test/units/testSuite.html | 1 + js/test/units/testSuiteFiles.js | 1 + js/test/units/testunitfmt_gl_ES.js | 331 +++ 26 files changed, 3452 insertions(+), 30 deletions(-) create mode 100644 js/test/date/testdatefmt_gl_ES.js create mode 100644 js/test/daterange/testdatefmtrange_gl_ES.js create mode 100644 js/test/strings-ext/testlistfmt_gl_ES.js create mode 100644 js/test/units/testunitfmt_gl_ES.js diff --git a/js/data/locale/gl/dateformats.json b/js/data/locale/gl/dateformats.json index cdc1a66d4f..e1cc67d5a9 100644 --- a/js/data/locale/gl/dateformats.json +++ b/js/data/locale/gl/dateformats.json @@ -120,46 +120,46 @@ "s": "{st} – {et}, {sd}/{sm}/{sy}" }, "c01": { - "f": "{st} do {sd} de {sm} de {sy} – {et} do d de MMMM de yyyy", - "l": "{st} do {sd} de {sm} de {sy} – {et} do d de MMMM de yyyy", - "m": "{st}, {sd} de {sm} de {sy} – {et}, d de MMM de yyyy", - "s": "{st}, {sd}/{sm}/{sy} – {et}, dd/MM/yy" + "f": "{st} do {sd} de {sm} de {sy} – {et} do {ed} de {em} de {ey}", + "l": "{st} do {sd} de {sm} de {sy} – {et} do {ed} de {em} de {ey}", + "m": "{st}, {sd} de {sm} de {sy} – {et}, {ed} de {em} de {ey}", + "s": "{st}, {sd}/{sm}/{sy} – {et}, {ed}/{em}/{ey}" }, "c02": { - "f": "{st} do {sd} de {sm} de {sy} – {et} do d de MMMM de yyyy", - "l": "{st} do {sd} de {sm} de {sy} – {et} do d de MMMM de yyyy", - "m": "{st}, {sd} de {sm} de {sy} – {et}, d de MMM de yyyy", - "s": "{st}, {sd}/{sm}/{sy} – {et}, dd/MM/yy" + "f": "{st} do {sd} de {sm} de {sy} – {et} do {ed} de {em} de {ey}", + "l": "{st} do {sd} de {sm} de {sy} – {et} do {ed} de {em} de {ey}", + "m": "{st}, {sd} de {sm} de {sy} – {et}, {ed} de {em} de {ey}", + "s": "{st}, {sd}/{sm}/{sy} – {et}, {ed}/{em}/{ey}" }, "c03": { - "f": "{st} do {sd} de {sm} de {sy} – {et} do d de MMMM de yyyy", - "l": "{st} do {sd} de {sm} de {sy} – {et} do d de MMMM de yyyy", - "m": "{st}, {sd} de {sm} de {sy} – {et}, d de MMM de yyyy", - "s": "{st}, {sd}/{sm}/{sy} – {et}, dd/MM/yy" + "f": "{st} do {sd} de {sm} de {sy} – {et} do {ed} de {em} de {ey}", + "l": "{st} do {sd} de {sm} de {sy} – {et} do {ed} de {em} de {ey}", + "m": "{st}, {sd} de {sm} de {sy} – {et}, {ed} de {em} de {ey}", + "s": "{st}, {sd}/{sm}/{sy} – {et}, {ed}/{em}/{ey}" }, "c10": { - "f": "{date} – {date}", - "l": "{date} – {date}", - "m": "{date} – {date}", - "s": "{date} – {date}" + "f": "{sd} – {ed} de {em} de {ey}", + "l": "{sd} – {ed} de {em} de {ey}", + "m": "{sd} – {ed} de {em} de {ey}", + "s": "{sd} – {ed}/{em}/{ey}" }, "c11": { - "f": "{date} – {date}", - "l": "{date} – {date}", - "m": "{date} – {date}", - "s": "{date} – {date}" + "f": "{sd} de {sm} – {ed} de {em} de {ey}", + "l": "{sd} de {sm} – {ed} de {em} de {ey}", + "m": "{sd} de {sm} – {ed} de {em} de {ey}", + "s": "{sd}/{sm} – {ed}/{em}/{ey}" }, "c12": { - "f": "d de MMMM de yyyy – {date}", - "l": "d de MMMM de yyyy – {date}", - "m": "d de MMM de yyyy – {date}", - "s": "dd/MM/yy – {date}" + "f": "{sd} de {sm} de {sy} – {ed} de {em} de {ey}", + "l": "{sd} de {sm} de {sy} – {ed} de {em} de {ey}", + "m": "{sd} de {sm} de {sy} – {ed} de {em} de {ey}", + "s": "{sd}/{sm}/{sy} – {ed}/{em}/{ey}" }, "c20": { - "f": "d de MMMM de yyyy – {date}", - "l": "d de MMMM de yyyy – {date}", - "m": "d de MMM de yyyy – {date}", - "s": "dd/MM/yy – {date}" + "f": "{sm} de {sy} – {em} de {ey}", + "l": "{sm} de {sy} – {em} de {ey}", + "m": "{sm} de {sy} – {em} de {ey}", + "s": "{sm}/{sy} – {em}/{ey}" }, "c30": { "f": "{sy} – {ey}", diff --git a/js/test/date/testDayOfWeek.js b/js/test/date/testDayOfWeek.js index 0aa7c5b75a..78215d74f9 100644 --- a/js/test/date/testDayOfWeek.js +++ b/js/test/date/testDayOfWeek.js @@ -1964,6 +1964,16 @@ module.exports.testweekdata = { var info = new LocaleInfo("ka-GE"); test.ok(info !== null); + test.equal(info.getFirstDayOfWeek(), 1); + test.equal(info.getWeekEndStart(), 6); + test.equal(info.getWeekEndEnd(), 0); + test.done(); + }, + testWeekData_gl_ES: function(test) { + test.expect(4); + var info = new LocaleInfo("gl-ES"); + test.ok(info !== null); + test.equal(info.getFirstDayOfWeek(), 1); test.equal(info.getWeekEndStart(), 6); test.equal(info.getWeekEndEnd(), 0); diff --git a/js/test/date/testMeridiems.js b/js/test/date/testMeridiems.js index 44fb518658..b362a80f56 100644 --- a/js/test/date/testMeridiems.js +++ b/js/test/date/testMeridiems.js @@ -1972,6 +1972,16 @@ module.exports.testmeridiems = { test.equal(fmt[0].name, "AM"); test.equal(fmt[1].name, "PM"); + test.done(); + }, + testMeridiem_gl_ES: function(test) { + test.expect(3); + var fmt = DateFmt.getMeridiemsRange({locale:"gl-ES"}); + test.ok(fmt !== null); + + test.equal(fmt[0].name, "a.m."); + test.equal(fmt[1].name, "p.m."); + test.done(); } } \ No newline at end of file diff --git a/js/test/date/testMonthTranslation.js b/js/test/date/testMonthTranslation.js index d468675dc9..821ce43167 100644 --- a/js/test/date/testMonthTranslation.js +++ b/js/test/date/testMonthTranslation.js @@ -7315,6 +7315,51 @@ module.exports.testmonthtranslation = { test.equal(value[10], "ნოე"); test.equal(value[11], "დეკ"); + test.done(); + }, + testMonthTranslate_gl_ES: function(test) { + test.expect(24); + + // full, long: MMMM + // medium: MMM + // short: MM + + var value = [], i; + var fmt = new DateFmt({locale:"gl-ES", date:"m", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + test.equal(value[0], "Xaneiro"); + test.equal(value[1], "Febreiro"); + test.equal(value[2], "Marzo"); + test.equal(value[3], "Abril"); + test.equal(value[4], "Maio"); + test.equal(value[5], "Xuño"); + test.equal(value[6], "Xullo"); + test.equal(value[7], "Agosto"); + test.equal(value[8], "Setembro"); + test.equal(value[9], "Outubro"); + test.equal(value[10], "Novembro"); + test.equal(value[11], "Decembro"); + + var fmt = new DateFmt({locale:"gl-ES", date:"m", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + + test.equal(value[0], "Xan."); + test.equal(value[1], "Feb."); + test.equal(value[2], "Mar."); + test.equal(value[3], "Abr."); + test.equal(value[4], "Maio"); + test.equal(value[5], "Xuño"); + test.equal(value[6], "Xul."); + test.equal(value[7], "Ago."); + test.equal(value[8], "Set."); + test.equal(value[9], "Out."); + test.equal(value[10], "Nov."); + test.equal(value[11], "Dec."); + test.done(); } } diff --git a/js/test/date/testSuite.html b/js/test/date/testSuite.html index 98d7e4a687..720fc498c4 100644 --- a/js/test/date/testSuite.html +++ b/js/test/date/testSuite.html @@ -70,6 +70,7 @@ + diff --git a/js/test/date/testSuiteFiles.js b/js/test/date/testSuiteFiles.js index dbf16c1a08..49302b706b 100644 --- a/js/test/date/testSuiteFiles.js +++ b/js/test/date/testSuiteFiles.js @@ -57,6 +57,7 @@ module.exports.files = [ "testdatefmt_fr_CA.js", "testdatefmt_fr_FR.js", "testdatefmt_ga_IE.js", + "testdatefmt_gl_ES.js", "testdatefmt_gu_IN.js", "testdatefmt_ha_Latn_NG.js", "testdatefmt_he_IL.js", diff --git a/js/test/date/testWeekdayTranslation.js b/js/test/date/testWeekdayTranslation.js index ff7f370ff3..91fdabcedf 100644 --- a/js/test/date/testWeekdayTranslation.js +++ b/js/test/date/testWeekdayTranslation.js @@ -11222,6 +11222,77 @@ module.exports.testWeekdayTranslation = { test.equal(value[5], "პ"); test.equal(value[6], "შ"); + test.done(); + }, + testWeekdayTranslationFull_gl_ES: function(test) { + // full -> wide + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"gl-ES", date:"w", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "Domingo"); + test.equal(value[1], "Luns"); + test.equal(value[2], "Martes"); + test.equal(value[3], "Mércores"); + test.equal(value[4], "Xoves"); + test.equal(value[5], "Venres"); + test.equal(value[6], "Sábado"); + test.done(); + }, + testWeekdayTranslationLong_gl_ES: function(test) { + // long -> abbreviate + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"gl-ES", date:"w", length: "long", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "Dom."); + test.equal(value[1], "Luns"); + test.equal(value[2], "Mar."); + test.equal(value[3], "Mér."); + test.equal(value[4], "Xov."); + test.equal(value[5], "Ven."); + test.equal(value[6], "Sáb."); + + test.done(); + }, + testWeekdayTranslationMedium_gl_ES: function(test) { + // medium -> short + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"gl-ES", date:"w", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "Do"); + test.equal(value[1], "Lu"); + test.equal(value[2], "Ma"); + test.equal(value[3], "Mé"); + test.equal(value[4], "Xo"); + test.equal(value[5], "Ve"); + test.equal(value[6], "Sá"); + + test.done(); + }, + testWeekdayTranslationShort_gl_ES: function(test) { + // short: narrow + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"gl-ES", date:"w", length: "short", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "D"); + test.equal(value[1], "L"); + test.equal(value[2], "M"); + test.equal(value[3], "M"); + test.equal(value[4], "X"); + test.equal(value[5], "V"); + test.equal(value[6], "S"); + test.done(); } } \ No newline at end of file diff --git a/js/test/date/testcalendar.js b/js/test/date/testcalendar.js index aa4593303b..7af9cbef12 100644 --- a/js/test/date/testcalendar.js +++ b/js/test/date/testcalendar.js @@ -23,7 +23,7 @@ if (typeof(LocaleInfo) === "undefined") { module.exports.testcalendar = { testDefaultCalendar_GregorianCaseAll: function(test) { - test.expect(193); + test.expect(194); var localeList = ["ar-AE","ar-BH","ar-DJ","ar-DZ","ar-EG","ar-IQ","ar-JO","ar-KW","ar-LB","ar-LY","ar-MA","ar-MR", "ar-OM","ar-QA","ar-SA","ar-SD","ar-SY","ar-TN","ar-YE","as-IN","az-Latn-AZ","bg-BG","bn-IN","bs-Latn-BA,bs-Latn-ME", "cs-CZ","da-DK","de-AT","de-CH","de-DE","de-LU","et-EE","el-CY","el-GR","en-AM","en-AU","en-AZ","en-CA","en-GB","en-GH", @@ -31,7 +31,7 @@ module.exports.testcalendar = { "en-PH","en-PK","en-PR","en-RW","en-SD","en-SG","en-SL","en-TW","en-TZ","en-UG","en-US","en-ZA","en-ZM","es-AR","es-BO", "es-CL","es-CO","es-CR","es-DO","es-EC","es-ES","es-GQ","es-GT","es-HN","es-MX","es-NI","es-PA","es-PE","es-PH","es-PR", "es-PY","es-SV","es-US","es-UY","es-VE","fi-FI","fr-BE","fr-BF","fr-BJ","fr-CA","fr-CD","fr-CF","fr-CG","fr-CH","fr-CI", - "fr-CM","fr-GQ","fr-DJ","fr-DZ","fr-FR","fr-GA","fr-GN","fr-LB","fr-LU","fr-ML","fr-RW","fr-SN","fr-TG","ga-IE","gu-IN", + "fr-CM","fr-GQ","fr-DJ","fr-DZ","fr-FR","fr-GA","fr-GN","fr-LB","fr-LU","fr-ML","fr-RW","fr-SN","fr-TG","ga-IE","gu-IN","gl-ES", "he-IL","hi-IN","hi-SG","hr-HR","hr-ME","hu-HU","id-ID","is-IS","it-CH","it-IT","ja-JP","ka-GE","kk-Cyrl-KZ","km-KH","kn-IN", "ko-KR","ku-Arab-IQ","lt-LT","lv-LV","mk-MK","ml-IN","mn-Cyrl-MN","mr-IN","ms-MY","ms-SG","nb-NO","nl-BE","nl-NL","pa-IN", "pa-PK","pl-PL","pt-AO","pt-BR","pt-GQ","pt-CV","pt-PT","ro-RO","ru-BY","ru-GE","ru-KG","ru-KZ","ru-RU","ru-UA","si-LK", diff --git a/js/test/date/testclock.js b/js/test/date/testclock.js index f6cc085945..79609890ed 100644 --- a/js/test/date/testclock.js +++ b/js/test/date/testclock.js @@ -1773,6 +1773,15 @@ module.exports.testclock = { test.equal(info.getClock(), 24); + test.done(); + }, + testClock_gl_ES: function(test) { + test.expect(2); + var info = new LocaleInfo("gl-ES"); + test.ok(info !== null); + + test.equal(info.getClock(), 24); + test.done(); } } diff --git a/js/test/date/testdatefmt_gl_ES.js b/js/test/date/testdatefmt_gl_ES.js new file mode 100644 index 0000000000..b6a7874b69 --- /dev/null +++ b/js/test/date/testdatefmt_gl_ES.js @@ -0,0 +1,1788 @@ +/* + * testdatefmt_gl_ES.js - test the date formatter object in Galician-Spain + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(JulianDate) === "undefined") { + var JulianDate = require("../../lib/JulianDate.js"); +} +if (typeof(GregorianDate) === "undefined") { + var GregorianDate = require("../../lib/GregorianDate.js"); +} +if (typeof(DateFmt) === "undefined") { + var DateFmt = require("../../lib/DateFmt.js"); +} +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testdatefmt_gl_ES = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + + testDateFmtConstructorEmpty_gl_ES: function(test) { + test.expect(1); + var fmt = new DateFmt({locale: "gl-ES"}); + + test.ok(fmt !== null); + test.done(); + }, + + testDateFmtSimpleShort_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "short"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29/09/11"); + test.done(); + }, + + testDateFmtSimpleMedium_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "medium"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29 de set. de 2011"); + test.done(); + }, + + testDateFmtSimpleLong_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "long"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29 de setembro de 2011"); + test.done(); + }, + + testDateFmtSimpleFull_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 de setembro de 2011'); + test.done(); + }, + + testDateFmtSimpleTimeShort_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "short", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeMedium_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "medium", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeLong_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", timelength: "long", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeFull_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 1, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '01:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleShort_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "short", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45, 29/09/11'); + test.done(); + }, + + testDateFmtDateTimeSimpleMedium_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "medium", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45, 29 de set. de 2011'); + test.done(); + }, + + testDateFmtDateTimeSimpleLong_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "long", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45 do 29 de setembro de 2011'); + test.done(); + }, + + testDateFmtDateTimeSimpleFull_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45 do 29 de setembro de 2011'); + test.done(); + }, + + + testDateFmtTemplateCalendar_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", calendar: "julian", template: "yyyy-MM-dd"}); + test.ok(fmt !== null); + + var date = new JulianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011-09-29"); + test.done(); + }, + + testDateFmtTemplateCalendarIncompatibleDateType_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", calendar: "julian", template: "yyyy-MM-dd HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + // convert automatically to a Julian calendar date + test.equal(fmt.format(date), "2011-09-16 13:45"); + test.done(); + }, + + testDateFmtTemplateClock12SwitchHH_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", clock: "12", template: "HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateClock12Switchkk_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", clock: "12", template: "kk:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateClock24Switchhh_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", clock: "24", template: "hh:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateClock24SwitchKK: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", clock: "24", template: "KK:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault12hh_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", template: "hh:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault12KK: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", template: "KK:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault24HH_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", template: "HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault24kk_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", template: "kk:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + + testDateFmtTypeDate_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "date"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29/09/11'); + test.done(); + }, + + testDateFmtTypeTime_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtTypeDateTime_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45, 29/09/11'); + test.done(); + }, + + testDateFmtShortDateComponentsY_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", date: "y"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "11"); + test.done(); + }, + + testDateFmtShortDateComponentsM_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", date: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "Se"); + test.done(); + }, + + testDateFmtShortDateComponentsN_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", date: "n"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 's'); + test.done(); + }, + + testDateFmtShortDateComponentsD_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", date: "d"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29"); + test.done(); + }, + + testDateFmtShortDateComponentsDM_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", date: "dm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29/09'); + test.done(); + }, + + testDateFmtShortDateComponentsMY_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", date: "my"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '09/11'); + test.done(); + }, + + testDateFmtShortDateComponentsDMY_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", date: "dmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29/09/11'); + test.done(); + }, + + testDateFmtShortDateComponentsWDM_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", date: "wdm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'x., 29/09'); + test.done(); + }, + + testDateFmtShortDateComponentsWDMY_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", date: "wdmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'x., 29/09/11'); + test.done(); + }, + + testDateFmtLongDateComponentsWDM_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", date: "wdm", length: "long"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'xov., 29 de setembro'); + test.done(); + }, + + testDateFmtFullDateComponentsY_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full", date: "y"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011"); + test.done(); + }, + + testDateFmtFullDateComponentsM_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full", date: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "Setembro"); + test.done(); + }, + + testDateFmtFullDateComponentsD_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full", date: "d"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29"); + test.done(); + }, + + testDateFmtFullDateComponentsDM_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full", date: "dm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 de setembro'); + test.done(); + }, + + testDateFmtFullDateComponentsMY_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full", date: "my"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'Setembro de 2011'); + test.done(); + }, + + testDateFmtFullDateComponentsDMY_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full", date: "dmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 de setembro de 2011'); + test.done(); + }, + + testDateFmtFullDateComponentsWDM_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full", date: "wdm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'xoves, 29 de setembro'); + test.done(); + }, + + testDateFmtFullDateComponentsWDMY_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full", date: "wdmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'xoves, 29 de setembro de 2011'); + test.done(); + }, + + testDateFmtShortTimeComponentsS_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", time: "s"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "37"); + test.done(); + }, + + testDateFmtShortTimeComponentsM_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", time: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45"); + test.done(); + }, + + testDateFmtShortTimeComponentsH_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", time: "h"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13"); + test.done(); + }, + + testDateFmtShortTimeComponentsMS_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", time: "ms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHM_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", time: "hm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMS_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", time: "hms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMA_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", time: "hma"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMZ_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "gl-ES", + type: "time", + time: "hmz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 CEST"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMAZ_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "gl-ES", + type: "time", + time: "hmaz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 CEST"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSA_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", time: "hmsa"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSZ_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "gl-ES", + type: "time", + time: "hmsz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 CEST"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSAZ_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "gl-ES", + type: "time", + time: "hmsaz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 CEST"); + test.done(); + }, + + testDateFmtFullTimeComponentsS_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", length: "full", time: "s"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "37"); + test.done(); + }, + + testDateFmtFullTimeComponentsM_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", length: "full", time: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45"); + test.done(); + }, + + testDateFmtFullTimeComponentsH_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", length: "full", time: "h"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13"); + test.done(); + }, + + testDateFmtFullTimeComponentsMS_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", length: "full", time: "ms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHM_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", length: "full", time: "hm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMS_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", length: "full", time: "hms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMA_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", length: "full", time: "hma"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMZ_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "gl-ES", + type: "time", + length: "full", + time: "hmz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 CEST"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMAZ_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "gl-ES", + type: "time", + length: "full", + time: "hmaz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 CEST"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSA_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", type: "time", length: "full", time: "hmsa"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSZ_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "gl-ES", + type: "time", + length: "full", + time: "hmsz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 CEST"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSAZ_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "gl-ES", + type: "time", + length: "full", + time: "hmsaz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 CEST"); + test.done(); + }, + + testDateFmtWithTimeZoneAndNoDST_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "gl-ES", + type: "time", + length: "full", + time: "hmsz", + timezone: "Europe/Madrid" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 12, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 CET"); + test.done(); + }, + + testDateFmtFormatRelativeWithinMinuteAfter_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 30, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "en 30 segundos"); + test.done(); + }, +testDateFmtFormatRelativeWithinMinuteBefore_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 44, + second: 30, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "hai 30 segundos"); + test.done(); + }, +testDateFmtFormatRelativeWithinHourAfter_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "en 10 minutos"); + test.done(); + }, +testDateFmtFormatRelativeWithinHourBefore_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'hai 10 minutos'); + test.done(); + }, +testDateFmtFormatRelativeWithinDayAfter_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 17, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'en 4 horas'); + test.done(); + }, +testDateFmtFormatRelativeWithinDayBefore_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'hai 4 horas'); + test.done(); + }, + + testDateFmtFormatRelativeWithinFortnightAfter_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'en 4 días'); + test.done(); + }, +testDateFmtFormatRelativeWithinFortnightBefore_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 16, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'hai 4 días'); + test.done(); + }, + + testDateFmtFormatRelativeWithinQuarterAfter_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 11, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'en 9 semanas'); + test.done(); + }, +testDateFmtFormatRelativeWithinQuarterBefore_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'hai 9 semanas'); + test.done(); + }, + + testDateFmtFormatRelativeWithinTwoYearsAfter_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2013, + month: 1, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'en 16 meses'); + test.done(); + }, +testDateFmtFormatRelativeWithinTwoYearsBefore_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2010, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'hai 14 meses'); + test.done(); + }, + + testDateFmtFormatRelativeYearsAfter_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 2025, + month: 10, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'en 14 anos'); + test.done(); + }, +testDateFmtFormatRelativeYearsBefore_gl_ES: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "gl-ES", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "gl-ES", + year: 1990, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'hai 21 anos'); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/daterange/testSuite.html b/js/test/daterange/testSuite.html index 3d48d1a1e9..ad80226eca 100644 --- a/js/test/daterange/testSuite.html +++ b/js/test/daterange/testSuite.html @@ -58,6 +58,7 @@ + diff --git a/js/test/daterange/testSuiteFiles.js b/js/test/daterange/testSuiteFiles.js index d79236ec11..44426ced3b 100644 --- a/js/test/daterange/testSuiteFiles.js +++ b/js/test/daterange/testSuiteFiles.js @@ -47,6 +47,7 @@ module.exports.files = [ "testdatefmtrange_fr_FR.js", "testdatefmtrange_ga_IE.js", "testdatefmtrange_gu_IN.js", + "testdatefmtrange_gl_ES.js", "testdatefmtrange_ha_Latn_NG.js", "testdatefmtrange_he_IL.js", "testdatefmtrange_hi_IN.js", diff --git a/js/test/daterange/testdatefmtrange_fmttemplate.js b/js/test/daterange/testdatefmtrange_fmttemplate.js index 05cf803d08..73030869c9 100644 --- a/js/test/daterange/testdatefmtrange_fmttemplate.js +++ b/js/test/daterange/testdatefmtrange_fmttemplate.js @@ -13864,6 +13864,78 @@ module.exports.testdaterangefmt = { test.equal(templatec30[2], "{sy} – {ey}"); test.equal(templatec30[3], "{sy} – {ey}"); + test.done(); + }, + testDateRngFmt_gl_ES: function(test) { + test.expect(36); + var fmt; + var data = setVariables(); + var length = data["fullLength"]; + var abbrLength = data["abbrLength"]; + + var templatec00 = [],templatec01 = [],templatec02 = [],templatec03 = []; + var templatec10 = [],templatec11 = [],templatec12 = [],templatec20 = []; + var templatec30 = []; + + //dmy + for (var i=0; i < 4; i++) { + fmt = new DateRngFmt({locale:"gl-ES", length: length[i]}) + templatec00.push(fmt.dateFmt.formats.range["c00"][abbrLength[i]]); + templatec01.push(fmt.dateFmt.formats.range["c01"][abbrLength[i]]); + templatec02.push(fmt.dateFmt.formats.range["c02"][abbrLength[i]]); + templatec03.push(fmt.dateFmt.formats.range["c03"][abbrLength[i]]); + templatec10.push(fmt.dateFmt.formats.range["c10"][abbrLength[i]]); + templatec11.push(fmt.dateFmt.formats.range["c11"][abbrLength[i]]); + templatec12.push(fmt.dateFmt.formats.range["c12"][abbrLength[i]]); + templatec20.push(fmt.dateFmt.formats.range["c20"][abbrLength[i]]); + templatec30.push(fmt.dateFmt.formats.range["c30"][abbrLength[i]]); + } + + test.equal(templatec00[0], '{sd} {sm}, {sy}, {st} – {et}'); + test.equal(templatec00[1], '{sd} {sm}, {sy}, {st} – {et}'); + test.equal(templatec00[2], '{sd} {sm}. {sy}, {st} – {et}'); + test.equal(templatec00[3], '{sd}.{sm}.{sy}, {st} – {et}'); + + test.equal(templatec01[0], '{sd} {sm}, {sy}, {st} – {ed} {em}, {ey}, {et}'); + test.equal(templatec01[1], '{sd} {sm}, {sy}, {st} – {ed} {em}, {ey}, {et}'); + test.equal(templatec01[2], '{sd} {sm}. {sy}, {st} – {ed} {em}. {ey}, {et}'); + test.equal(templatec01[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + + test.equal(templatec02[1], '{sd} {sm}, {sy}, {st} – {ed} {em}, {ey}, {et}'); + test.equal(templatec02[0], '{sd} {sm}, {sy}, {st} – {ed} {em}, {ey}, {et}'); + test.equal(templatec02[2], '{sd} {sm}. {sy}, {st} – {ed} {em}. {ey}, {et}'); + test.equal(templatec02[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + + test.equal(templatec03[0], '{sd} {sm}, {sy}, {st} – {ed} {em}, {ey}, {et}'); + test.equal(templatec03[1], '{sd} {sm}, {sy}, {st} – {ed} {em}, {ey}, {et}'); + test.equal(templatec03[2], '{sd} {sm}. {sy}, {st} – {ed} {em}. {ey}, {et}'); + test.equal(templatec03[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + + test.equal(templatec10[0], '{sd} – {ed} {em}, {ey}'); + test.equal(templatec10[1], '{sd} – {ed} {em}, {ey}'); + test.equal(templatec10[2], '{sd} – {ed} {em}. {ey}'); + test.equal(templatec10[3], '{sd} – {ed}.{em}.{ey}'); + + test.equal(templatec11[0], '{sd} {sm} – {ed} {em}, {ey}'); + test.equal(templatec11[1], '{sd} {sm} – {ed} {em}, {ey}'); + test.equal(templatec11[2], '{sd} {sm} – {ed} {em}. {ey}'); + test.equal(templatec11[3], '{sd}.{sm} – {ed}.{em}.{ey}'); + + test.equal(templatec12[0], '{sd} {sm}, {sy} – {ed} {em}, {ey}'); + test.equal(templatec12[1], '{sd} {sm}, {sy} – {ed} {em}, {ey}'); + test.equal(templatec12[2], '{sd} {sm}. {sy} – {ed} {em}. {ey}'); + test.equal(templatec12[3], '{sd}.{sm}.{sy} – {ed}.{em}.{ey}'); + + test.equal(templatec20[0], '{sm}, {sy} – {em}, {ey}'); + test.equal(templatec20[1], '{sm}, {sy} – {em}, {ey}'); + test.equal(templatec20[2], '{sm}. {sy} – {em}. {ey}'); + test.equal(templatec20[3], '{sm}.{sy} – {em}.{ey}'); + + test.equal(templatec30[0], "{sy} – {ey}"); + test.equal(templatec30[1], "{sy} – {ey}"); + test.equal(templatec30[2], "{sy} – {ey}"); + test.equal(templatec30[3], "{sy} – {ey}"); + test.done(); } } \ No newline at end of file diff --git a/js/test/daterange/testdatefmtrange_gl_ES.js b/js/test/daterange/testdatefmtrange_gl_ES.js new file mode 100644 index 0000000000..57d142f673 --- /dev/null +++ b/js/test/daterange/testdatefmtrange_gl_ES.js @@ -0,0 +1,692 @@ +/* + * testdatefmtrange_gl_ES.js - test the date range formatter object Galician-Spain + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(GregorianDate) === "undefined") { + var GregorianDate = require("../../lib/GregorianDate.js"); +} +if (typeof(DateRngFmt) === "undefined") { + var DateRngFmt = require("../../lib/DateRngFmt.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testdatefmtrange_gl_ES = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + + testDateRngFmtglESRangeInDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "13:45 – 14:30, 31/12/11"); + test.done(); + }, + testDateRngFmtglESRangeInDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "13:45 – 14:30, 31 de dec. de 2011"); + test.done(); + }, + testDateRngFmtglESRangeInDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "13:45 – 14:30 do 31 de decembro de 2011"); + test.done(); + }, + testDateRngFmtglESRangeInDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "13:45 – 14:30 do 31 de decembro de 2011"); + test.done(); + }, + + testDateRngFmtglESRangeNextDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "13:45, 30/12/11 – 14:30, 31/12/11"); + test.done(); + }, + testDateRngFmtglESRangeNextDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "13:45, 30 de dec. de 2011 – 14:30, 31 de dec. de 2011"); + test.done(); + }, + testDateRngFmtglESRangeNextDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "13:45 do 30 de decembro de 2011 – 14:30 do 31 de decembro de 2011"); + test.done(); + }, + testDateRngFmtglESRangeNextDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "13:45 do 30 de decembro de 2011 – 14:30 do 31 de decembro de 2011"); + test.done(); + }, + + testDateRngFmtglESRangeMultiDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31/12/11"); + test.done(); + }, + testDateRngFmtglESRangeMultiDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31 de dec. de 2011"); + test.done(); + }, + testDateRngFmtglESRangeMultiDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31 de decembro de 2011"); + test.done(); + }, + testDateRngFmtglESRangeMultiDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31 de decembro de 2011"); + test.done(); + }, + + testDateRngFmtglESRangeNextMonthShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20/11 – 31/12/11"); + test.done(); + }, + testDateRngFmtglESRangeNextMonthMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 de nov. – 31 de dec. de 2011"); + test.done(); + }, + testDateRngFmtglESRangeNextMonthLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 de novembro – 31 de decembro de 2011"); + test.done(); + }, + testDateRngFmtglESRangeNextMonthFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 de novembro – 31 de decembro de 2011"); + test.done(); + }, + + testDateRngFmtglESRangeNextYearShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20/11/11 – 31/01/12"); + test.done(); + }, + testDateRngFmtglESRangeNextYearMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 de nov. de 2011 – 31 de xan. de 2012"); + test.done(); + }, + testDateRngFmtglESRangeNextYearLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 de novembro de 2011 – 31 de xaneiro de 2012"); + test.done(); + }, + testDateRngFmtglESRangeNextYearFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 de novembro de 2011 – 31 de xaneiro de 2012"); + test.done(); + }, + + testDateRngFmtglESRangeMultiYearShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "11/11 – 01/14"); + test.done(); + }, + testDateRngFmtglESRangeMultiYearMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "nov. de 2011 – xan. de 2014"); + test.done(); + }, + testDateRngFmtglESRangeMultiYearLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "novembro de 2011 – xaneiro de 2014"); + test.done(); + }, + testDateRngFmtglESRangeMultiYearFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "novembro de 2011 – xaneiro de 2014"); + test.done(); + }, + testDateRngFmtglESManyYearsFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "gl-ES", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2064, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011 – 2064"); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/durfmt/testdurfmt2.js b/js/test/durfmt/testdurfmt2.js index 5d8c54d100..d79499f19d 100644 --- a/js/test/durfmt/testdurfmt2.js +++ b/js/test/durfmt/testdurfmt2.js @@ -9035,6 +9035,47 @@ module.exports.testdurfmt2 = { test.equal(clockformatted_18[2], '18სთ, 18წთ, 18წმ'); test.equal(clockformatted_18[3], '18სთ, 18წთ, 18წმ'); + test.done(); + }, + testDurFmt_gl_ES: function(test) { + test.expect(16); + // 1 11 + var textfmt; + var data = setVariable(); + var length = data["fullLength"]; + + var textformatted_1 = [],textformatted_11 = []; + var clockformatted_1 = [],clockformatted_11 = []; + + for (var i=0; i<4; i++) { + textfmt = new DurationFmt({locale: "gl-ES", style:"text", length:length[i]}); + textformatted_1.push(textfmt.format({year: 1,month: 1,week: 1,day: 1}).toString()); + textformatted_11.push(textfmt.format({year: 11,month: 11,week: 11,day: 11}).toString()); + + clockformatted_1.push(textfmt.format({hour: 1,minute: 1,second: 1}).toString()); + clockformatted_11.push(textfmt.format({hour: 11,minute: 11,second: 11}).toString()); + } + + test.equal(textformatted_1[0], '1 ano, 1 mes, 1 semana e 1 día'); + test.equal(textformatted_1[1], '1 ano, 1 mes, 1 sem., 1 día'); + test.equal(textformatted_1[2], '1 a., 1 m., 1 sem., 1 d'); + test.equal(textformatted_1[3], '1 a., 1 m., 1 sem., 1 d'); + + test.equal(textformatted_11[0], '11 anos, 11 meses, 11 semanas e 11 días'); + test.equal(textformatted_11[1], '11 anos, 11 meses, 11 sem., 11 días'); + test.equal(textformatted_11[2], '11 a., 11 m., 11 sem., 11 d'); + test.equal(textformatted_11[3], '11 a., 11 m., 11 sem., 11 d'); + + test.equal(clockformatted_1[0], '1 hora, 1 minuto e 1 segundo'); + test.equal(clockformatted_1[1], '1 h, 1 min, 1 s'); + test.equal(clockformatted_1[2], '1 h, 1 min, 1 s'); + test.equal(clockformatted_1[3], '1 h, 1 min, 1 s'); + + test.equal(clockformatted_11[0], '11 horas, 11 minutos e 11 segundos'); + test.equal(clockformatted_11[1], '11 h, 11 min, 11 s'); + test.equal(clockformatted_11[2], '11 h, 11 min, 11 s'); + test.equal(clockformatted_11[3], '11 h, 11 min, 11 s'); + test.done(); } } diff --git a/js/test/number/testnumfmt2.js b/js/test/number/testnumfmt2.js index 845f03f896..99735233e4 100644 --- a/js/test/number/testnumfmt2.js +++ b/js/test/number/testnumfmt2.js @@ -3773,5 +3773,24 @@ module.exports.testnumfmt2 = { test.equal(li.getCurrencyFormats().commonNegative, "-{n} {s}"); test.equal(curfmt.format(57.05), "57,05 ₾"); //GEL test.done(); + }, + testNumFmt_gl_ES: function(test) { + test.expect(9); + var li = new LocaleInfo("gl-ES"); + var fmt = new NumFmt({locale:"gl-ES", type:"standard", useNative:false}); + test.equal(li.getDecimalSeparator(), ","); + test.equal(li.getGroupingSeparator(), "."); + test.equal(fmt.format(123456789.45), "123.456.789,45"); + + var pctfmt = new NumFmt({locale:"gl-ES", type:"percentage", useNative:false}); + test.equal(li.getPercentageFormat(), "{n} %"); + test.equal(li.getNegativePercentageFormat(), "-{n} %"); + test.equal(pctfmt.format(34), "34 %"); + + var curfmt = new NumFmt({locale: "gl-ES", type: "currency", useNative:false, currency:li.getCurrency()}); + test.equal(li.getCurrencyFormats().common, "{n} {s}"); + test.equal(li.getCurrencyFormats().commonNegative, "-{n} {s}"); + test.equal(curfmt.format(57.05), "57,05 €"); + test.done(); } } \ No newline at end of file diff --git a/js/test/root/testlocaleinfo.js b/js/test/root/testlocaleinfo.js index 9949aaee2f..ea1d56fbad 100644 --- a/js/test/root/testlocaleinfo.js +++ b/js/test/root/testlocaleinfo.js @@ -13388,5 +13388,15 @@ module.exports.testlocaleinfo = { test.equal(info.getDelimiterQuotationEnd(), "“"); test.equal(info.getPaperSize(), "A4"); test.done(); + }, + testLocaleInfoQuotation_gl_ES: function(test) { + test.expect(4); + var info = new LocaleInfo("gl-ES"); + test.ok(info !== null); + + test.equal(info.getDelimiterQuotationStart(), "“"); + test.equal(info.getDelimiterQuotationEnd(), "”"); + test.equal(info.getPaperSize(), "A4"); + test.done(); } }; \ No newline at end of file diff --git a/js/test/root/testlocalematch.js b/js/test/root/testlocalematch.js index 850772fff3..2090ba0732 100644 --- a/js/test/root/testlocalematch.js +++ b/js/test/root/testlocalematch.js @@ -1106,6 +1106,28 @@ module.exports.testlocalematch = { test.equal(locale.getSpec(), "ka-Geor-GE"); test.done(); }, + testLocaleMatcherGetLikelyLocaleByLocaleCode68: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "gl-ES" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "gl-Latn-ES"); + test.done(); + }, + testLocaleMatcherGetLikelyLocaleByLocaleCode69: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "gl" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "gl-Latn-ES"); + test.done(); + }, testLocaleMatcherMatchExactFullLocale: function(test) { test.expect(2); @@ -1573,6 +1595,17 @@ module.exports.testlocalematch = { test.equal(locale.getSpec(), "ka-GE"); test.done(); }, + testLocaleMatcherGetLikelyLocaleMinimalByLanguage6: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "gl" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocaleMinimal(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "gl-ES"); + test.done(); + }, testLocaleMatcherGetLikelyLocaleMinimalUzbek: function(test) { test.expect(3); diff --git a/js/test/root/testscriptinfo.js b/js/test/root/testscriptinfo.js index c686e0409e..d33684ba79 100644 --- a/js/test/root/testscriptinfo.js +++ b/js/test/root/testscriptinfo.js @@ -2185,5 +2185,15 @@ module.exports.testscriptinfo = { test.equal(li.getScript(), "Geor"); test.equal(scinfo.getScriptDirection(), "ltr"); test.done(); + }, + testScriptInfo_gl_ES: function(test) { + test.expect(4); + var li = new LocaleInfo("gl-ES"); + var scinfo = new ScriptInfo(li.getScript()); + test.ok(li !== null); + test.ok(scinfo !== null); + test.equal(li.getScript(), "Latn"); + test.equal(scinfo.getScriptDirection(), "ltr"); + test.done(); } }; diff --git a/js/test/root/teststrings.js b/js/test/root/teststrings.js index 57a8473b46..d2421d4ee2 100644 --- a/js/test/root/teststrings.js +++ b/js/test/root/teststrings.js @@ -3263,6 +3263,26 @@ module.exports.teststrings = { test.equal(str.formatChoice(1), "There items are one"); test.done(); }, + testStringFormatChoiceCharClasses32: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("eu-ES"); + + test.ok(str !== null); + + test.equal(str.formatChoice(1), "There items are one"); + test.done(); + }, + testStringFormatChoiceCharClasses33: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("eu-ES"); + + test.ok(str !== null); + + test.equal(str.formatChoice(11), "Default items"); + test.done(); + }, testStringFormatChoiceCharClassesComplex1: function(test) { test.expect(2); diff --git a/js/test/strings-ext/testSuite.html b/js/test/strings-ext/testSuite.html index ea49ebf3d4..bb8e6b43e1 100644 --- a/js/test/strings-ext/testSuite.html +++ b/js/test/strings-ext/testSuite.html @@ -43,6 +43,7 @@ + diff --git a/js/test/strings-ext/testSuiteFiles.js b/js/test/strings-ext/testSuiteFiles.js index b290555e25..b4e8d5011a 100644 --- a/js/test/strings-ext/testSuiteFiles.js +++ b/js/test/strings-ext/testSuiteFiles.js @@ -31,6 +31,7 @@ module.exports.files = [ "testlistfmt_fa.js", "testlistfmt_fr.js", "testlistfmt_gu_IN.js", + "testlistfmt_gl_ES.js", "testlistfmt_he_IL.js", "testlistfmt_hi_IN.js", "testlistfmt_hr.js", diff --git a/js/test/strings-ext/testlistfmt_gl_ES.js b/js/test/strings-ext/testlistfmt_gl_ES.js new file mode 100644 index 0000000000..658d571b0d --- /dev/null +++ b/js/test/strings-ext/testlistfmt_gl_ES.js @@ -0,0 +1,253 @@ +/* + * testlistfmt_gl_ES.js - test the list formatter object + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSe-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(ListFmt) === "undefined") { + var ListFmt = require("../../lib/ListFmt.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testlistfmt_gl_ES = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + testListFmteuESNumberFormatOne: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un"]), "un"); + test.done(); + }, + testListFmteuESNumberFormatTwo: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous"]), "un e dous"); + test.done(); + }, + testListFmteuESNumberFormatThree: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous", "tres"]), "un, dous e tres"); + test.done(); + }, + testListFmteuESNumberFormatFour: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous", "tres", "catro"]), "un, dous, tres e catro"); + test.done(); + }, + testListFmteuESNumberFormatFive: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous", "tres", "catro", "cinco"]), "un, dous, tres, catro e cinco"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatOneShort: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un"]), "un"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatTwoShort: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous"]), "un, dous"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatThreeShort: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous", "tres"]), "un, dous, tres"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatFourShort: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous", "tres", "catro"]), "un, dous, tres, catro"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatFiveShort: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous", "tres", "catro", "cinco"]), "un, dous, tres, catro, cinco"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatOneFull: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un"]), "un"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatTwoFull: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous"]), "un e dous"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatThreeFull: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous", "tres"]), "un, dous e tres"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatFourFull: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous", "tres", "catro"]), "un, dous, tres e catro"); + test.done(); + }, + testListFmtUnitStyleeuESNumberFormatFiveFull: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous", "tres", "catro", "cinco"]), "un, dous, tres, catro e cinco"); + test.done(); + }, + testListFmtORStyleeuESNumberFormatOne: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un"]), "un"); + test.done(); + }, + testListFmtORStyleeuESNumberFormatTwo: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous"]), "un ou dous"); + test.done(); + }, + testListFmtORStyleeuESNumberFormatThree: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous", "tres"]), "un, dous ou tres"); + test.done(); + }, + testListFmtORStyleeuESNumberFormatFour: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous", "tres", "catro"]), "un, dous, tres ou catro"); + test.done(); + }, + testListFmtORStyleeuESNumberFormatFiveFull: function(test) { + var fmt = new ListFmt({ + locale: "gl-ES", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["un", "dous", "tres", "catro", "cinco"]), "un, dous, tres, catro ou cinco"); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/units/testSuite.html b/js/test/units/testSuite.html index 39c7e003c9..da34d15473 100644 --- a/js/test/units/testSuite.html +++ b/js/test/units/testSuite.html @@ -43,6 +43,7 @@ + diff --git a/js/test/units/testSuiteFiles.js b/js/test/units/testSuiteFiles.js index 152892446b..88cc4bcb44 100644 --- a/js/test/units/testSuiteFiles.js +++ b/js/test/units/testSuiteFiles.js @@ -31,6 +31,7 @@ module.exports.files = [ "testtemp.js", "testtime.js", "testunitfmt.js", + "testunitfmt_gl_ES.js", "testunits.js", "testunitfmtasync.js", "testdigitalspeed.js", diff --git a/js/test/units/testunitfmt_gl_ES.js b/js/test/units/testunitfmt_gl_ES.js new file mode 100644 index 0000000000..f040f61bf2 --- /dev/null +++ b/js/test/units/testunitfmt_gl_ES.js @@ -0,0 +1,331 @@ +/* + * testunitfmt_gl_ES.js - test the unitfmt for gl-ES + * + * Copyright © 2020 JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(UnitFmt) === "undefined") { + var UnitFmt = require("../../lib/UnitFmt.js"); +} +if (typeof(Measurement) === "undefined") { + var Measurement = require("../../lib/Measurement.js"); +} + +if (typeof(MeasurementFactory) === "undefined") { + var MeasurementFactory = require("../../lib/MeasurementFactory.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testunitfmt_gl_ES = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + testUnitFormatGetLocale_gl_ES: function(test) { + test.expect(2); + var uf = new UnitFmt({ + locale: "gl-ES" + }); + test.ok(uf.getLocale()); + test.equal(uf.getLocale().getSpec(), "gl-ES"); + test.done(); + }, + testGetMeasurementSystem_gl_ES: function(test) { + test.expect(1); + + test.equal(Measurement.getMeasurementSystemForLocale("gl-ES"), "metric"); + test.done(); + }, + testUnitFormatTemperature1_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "fahrenheit", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + length: "short", + autoConvert: true, + maxFractionDigits: 2, + roundingMode: "down" + }); + var str = uf.format(m1); + test.equal(str, "-16,66 °C"); + test.done(); + }, + testUnitFormatTemperature2_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "fahrenheit", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + autoConvert: true, + autoScale: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "-16,666666666666668 graos Celsius"); + test.done(); + }, + + testUnitFormatArea1_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "square centimeter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + autoConvert:true, + length:"short" + }); + + var str = uf.format(m1); + test.equal(str, "2 cm²"); + test.done(); + }, + testUnitFormatArea2_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "square centimeter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + autoConvert: true, + length: "long" + }); + + var str = uf.format(m1); + test.equal(str, "2 centímetros cadrados"); + test.done(); + }, + testUnitFormatArea3_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "hectare", + amount: 1000 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + autoConvert: true, + length: "short" + }); + + var str = uf.format(m1); + test.equal(str, "10 km²"); + test.done(); + }, + testUnitFormatArea4_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "hectare", + amount: 1000 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + autoConvert: true, + length: "long" + }); + + var str = uf.format(m1); + test.equal(str, "10 quilómetros cadrados"); + test.done(); + }, + testUnitFormatFuelConsumption1_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km/liter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + autoConvert: true, + length: "short" + }); + var str = uf.format(m1); + test.equal(str, "2 km/l"); + test.done(); + }, + testUnitFormatFuelConsumption2_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km/liter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + autoConvert: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "2 quilómetros por litro"); + test.done(); + }, + testUnitFormatLength1_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "mile", + amount: 2000 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + autoConvert: true, + length: "short" + }); + var str = uf.format(m1); + test.equal(str, "3,21868 Mm"); + test.done(); + }, + testUnitFormatLength2_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "mile", + amount: 2000 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + autoConvert: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "3,21868 megameters"); + test.done(); + }, + testUnitFormatWithUsageVehicleDistance1_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km", + amount: 10 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + usage: "vehicleDistance", + length: "short", + autoConvert: true, + }); + var str = uf.format(m1); + test.equal(str, "10 km"); + test.done(); + }, + testUnitFormatWithUsageVehicleDistance2_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km", + amount: 10 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + usage: "vehicleDistance", + length: "long", + autoConvert: true + }); + var str = uf.format(m1); + test.equal(str, "10 quilómetros"); + test.done(); + }, + testUnitFormatWithUsageFuelVolume1_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "imperial gallon", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + usage: "fuelVolume", + length: "short", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "9,09 l"); + test.done(); + }, + testUnitFormatWithUsageFuelVolume2_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "imperial gallon", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + usage: "fuelVolume", + length: "long", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "9,09 litros"); + test.done(); + }, + testUnitFormatWithUsageOverrideSignificantDigits1_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "kWh", + amount: 102.338322234 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + usage: "electricalEnergy", + length: "short", + significantDigits: "6", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "102,338 kWh"); + test.done(); + }, + testUnitFormatWithUsageOverrideSignificantDigits2_gl_ES: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "kWh", + amount: 102.338322234 + }); + + var uf = new UnitFmt({ + locale: "gl-ES", + usage: "electricalEnergy", + length: "long", + significantDigits: "6", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "102,338 quilowatts hora"); + test.done(); + } +} \ No newline at end of file From 17e4ef9cbc9b09db032977745a68c5a8c8341a95 Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Thu, 20 Aug 2020 17:48:19 +0900 Subject: [PATCH 22/48] Fix daterange tc --- .../daterange/testdatefmtrange_fmttemplate.js | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/js/test/daterange/testdatefmtrange_fmttemplate.js b/js/test/daterange/testdatefmtrange_fmttemplate.js index 73030869c9..85e6127f2a 100644 --- a/js/test/daterange/testdatefmtrange_fmttemplate.js +++ b/js/test/daterange/testdatefmtrange_fmttemplate.js @@ -13891,45 +13891,45 @@ module.exports.testdaterangefmt = { templatec30.push(fmt.dateFmt.formats.range["c30"][abbrLength[i]]); } - test.equal(templatec00[0], '{sd} {sm}, {sy}, {st} – {et}'); - test.equal(templatec00[1], '{sd} {sm}, {sy}, {st} – {et}'); - test.equal(templatec00[2], '{sd} {sm}. {sy}, {st} – {et}'); - test.equal(templatec00[3], '{sd}.{sm}.{sy}, {st} – {et}'); + test.equal(templatec00[0], '{st} – {et} do {sd} de {sm} de {sy}'); + test.equal(templatec00[1], '{st} – {et} do {sd} de {sm} de {sy}'); + test.equal(templatec00[2], '{st} – {et}, {sd} de {sm} de {sy}'); + test.equal(templatec00[3], '{st} – {et}, {sd}/{sm}/{sy}'); - test.equal(templatec01[0], '{sd} {sm}, {sy}, {st} – {ed} {em}, {ey}, {et}'); - test.equal(templatec01[1], '{sd} {sm}, {sy}, {st} – {ed} {em}, {ey}, {et}'); - test.equal(templatec01[2], '{sd} {sm}. {sy}, {st} – {ed} {em}. {ey}, {et}'); - test.equal(templatec01[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + test.equal(templatec01[0], '{st} do {sd} de {sm} de {sy} – {et} do {ed} de {em} de {ey}'); + test.equal(templatec01[1], '{st} do {sd} de {sm} de {sy} – {et} do {ed} de {em} de {ey}'); + test.equal(templatec01[2], '{st}, {sd} de {sm} de {sy} – {et}, {ed} de {em} de {ey}'); + test.equal(templatec01[3], '{st}, {sd}/{sm}/{sy} – {et}, {ed}/{em}/{ey}'); - test.equal(templatec02[1], '{sd} {sm}, {sy}, {st} – {ed} {em}, {ey}, {et}'); - test.equal(templatec02[0], '{sd} {sm}, {sy}, {st} – {ed} {em}, {ey}, {et}'); - test.equal(templatec02[2], '{sd} {sm}. {sy}, {st} – {ed} {em}. {ey}, {et}'); - test.equal(templatec02[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + test.equal(templatec02[1], '{st} do {sd} de {sm} de {sy} – {et} do {ed} de {em} de {ey}'); + test.equal(templatec02[0], '{st} do {sd} de {sm} de {sy} – {et} do {ed} de {em} de {ey}'); + test.equal(templatec02[2], '{st}, {sd} de {sm} de {sy} – {et}, {ed} de {em} de {ey}'); + test.equal(templatec02[3], '{st}, {sd}/{sm}/{sy} – {et}, {ed}/{em}/{ey}'); - test.equal(templatec03[0], '{sd} {sm}, {sy}, {st} – {ed} {em}, {ey}, {et}'); - test.equal(templatec03[1], '{sd} {sm}, {sy}, {st} – {ed} {em}, {ey}, {et}'); - test.equal(templatec03[2], '{sd} {sm}. {sy}, {st} – {ed} {em}. {ey}, {et}'); - test.equal(templatec03[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + test.equal(templatec03[0], '{st} do {sd} de {sm} de {sy} – {et} do {ed} de {em} de {ey}'); + test.equal(templatec03[1], '{st} do {sd} de {sm} de {sy} – {et} do {ed} de {em} de {ey}'); + test.equal(templatec03[2], '{st}, {sd} de {sm} de {sy} – {et}, {ed} de {em} de {ey}'); + test.equal(templatec03[3], '{st}, {sd}/{sm}/{sy} – {et}, {ed}/{em}/{ey}'); - test.equal(templatec10[0], '{sd} – {ed} {em}, {ey}'); - test.equal(templatec10[1], '{sd} – {ed} {em}, {ey}'); - test.equal(templatec10[2], '{sd} – {ed} {em}. {ey}'); - test.equal(templatec10[3], '{sd} – {ed}.{em}.{ey}'); + test.equal(templatec10[0], '{sd} – {ed} de {em} de {ey}'); + test.equal(templatec10[1], '{sd} – {ed} de {em} de {ey}'); + test.equal(templatec10[2], '{sd} – {ed} de {em} de {ey}'); + test.equal(templatec10[3], '{sd} – {ed}/{em}/{ey}'); - test.equal(templatec11[0], '{sd} {sm} – {ed} {em}, {ey}'); - test.equal(templatec11[1], '{sd} {sm} – {ed} {em}, {ey}'); - test.equal(templatec11[2], '{sd} {sm} – {ed} {em}. {ey}'); - test.equal(templatec11[3], '{sd}.{sm} – {ed}.{em}.{ey}'); + test.equal(templatec11[0], '{sd} de {sm} – {ed} de {em} de {ey}'); + test.equal(templatec11[1], '{sd} de {sm} – {ed} de {em} de {ey}'); + test.equal(templatec11[2], '{sd} de {sm} – {ed} de {em} de {ey}'); + test.equal(templatec11[3], '{sd}/{sm} – {ed}/{em}/{ey}'); - test.equal(templatec12[0], '{sd} {sm}, {sy} – {ed} {em}, {ey}'); - test.equal(templatec12[1], '{sd} {sm}, {sy} – {ed} {em}, {ey}'); - test.equal(templatec12[2], '{sd} {sm}. {sy} – {ed} {em}. {ey}'); - test.equal(templatec12[3], '{sd}.{sm}.{sy} – {ed}.{em}.{ey}'); + test.equal(templatec12[0], '{sd} de {sm} de {sy} – {ed} de {em} de {ey}'); + test.equal(templatec12[1], '{sd} de {sm} de {sy} – {ed} de {em} de {ey}'); + test.equal(templatec12[2], '{sd} de {sm} de {sy} – {ed} de {em} de {ey}'); + test.equal(templatec12[3], '{sd}/{sm}/{sy} – {ed}/{em}/{ey}'); - test.equal(templatec20[0], '{sm}, {sy} – {em}, {ey}'); - test.equal(templatec20[1], '{sm}, {sy} – {em}, {ey}'); - test.equal(templatec20[2], '{sm}. {sy} – {em}. {ey}'); - test.equal(templatec20[3], '{sm}.{sy} – {em}.{ey}'); + test.equal(templatec20[0], '{sm} de {sy} – {em} de {ey}'); + test.equal(templatec20[1], '{sm} de {sy} – {em} de {ey}'); + test.equal(templatec20[2], '{sm} de {sy} – {em} de {ey}'); + test.equal(templatec20[3], '{sm}/{sy} – {em}/{ey}'); test.equal(templatec30[0], "{sy} – {ey}"); test.equal(templatec30[1], "{sy} – {ey}"); From 1cc63fe4029ffe44d7456383a5ec5a92637f34da Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Thu, 20 Aug 2020 17:54:25 +0900 Subject: [PATCH 23/48] Write newly added file in testSuite.html --- js/test/date/testSuite.html | 1 + js/test/daterange/testSuite.html | 1 + js/test/strings-ext/testSuite.html | 1 + js/test/units/testSuite.html | 1 + 4 files changed, 4 insertions(+) diff --git a/js/test/date/testSuite.html b/js/test/date/testSuite.html index 98d7e4a687..18554aed9e 100644 --- a/js/test/date/testSuite.html +++ b/js/test/date/testSuite.html @@ -48,6 +48,7 @@ + diff --git a/js/test/daterange/testSuite.html b/js/test/daterange/testSuite.html index 3d48d1a1e9..064b1e5482 100644 --- a/js/test/daterange/testSuite.html +++ b/js/test/daterange/testSuite.html @@ -38,6 +38,7 @@ + diff --git a/js/test/strings-ext/testSuite.html b/js/test/strings-ext/testSuite.html index ea49ebf3d4..6108515c75 100644 --- a/js/test/strings-ext/testSuite.html +++ b/js/test/strings-ext/testSuite.html @@ -35,6 +35,7 @@ + diff --git a/js/test/units/testSuite.html b/js/test/units/testSuite.html index 39c7e003c9..f7a94144df 100644 --- a/js/test/units/testSuite.html +++ b/js/test/units/testSuite.html @@ -43,6 +43,7 @@ + From 156adbbd693d1ce2ecb67da05f5d855af4a47474 Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Thu, 20 Aug 2020 18:04:53 +0900 Subject: [PATCH 24/48] Add newly added file in testSuite.html --- js/test/date/testSuite.html | 1 + js/test/daterange/testSuite.html | 1 + js/test/strings-ext/testSuite.html | 1 + js/test/units/testSuite.html | 1 + js/test/units/testSuiteFiles.js | 1 + 5 files changed, 5 insertions(+) diff --git a/js/test/date/testSuite.html b/js/test/date/testSuite.html index 98d7e4a687..00c43149e6 100644 --- a/js/test/date/testSuite.html +++ b/js/test/date/testSuite.html @@ -64,6 +64,7 @@ + diff --git a/js/test/daterange/testSuite.html b/js/test/daterange/testSuite.html index 3d48d1a1e9..21f78f5323 100644 --- a/js/test/daterange/testSuite.html +++ b/js/test/daterange/testSuite.html @@ -53,6 +53,7 @@ + diff --git a/js/test/strings-ext/testSuite.html b/js/test/strings-ext/testSuite.html index ea49ebf3d4..efd3a1358e 100644 --- a/js/test/strings-ext/testSuite.html +++ b/js/test/strings-ext/testSuite.html @@ -40,6 +40,7 @@ + diff --git a/js/test/units/testSuite.html b/js/test/units/testSuite.html index 39c7e003c9..99d05ce147 100644 --- a/js/test/units/testSuite.html +++ b/js/test/units/testSuite.html @@ -43,6 +43,7 @@ + diff --git a/js/test/units/testSuiteFiles.js b/js/test/units/testSuiteFiles.js index 152892446b..a81e5654ec 100644 --- a/js/test/units/testSuiteFiles.js +++ b/js/test/units/testSuiteFiles.js @@ -31,6 +31,7 @@ module.exports.files = [ "testtemp.js", "testtime.js", "testunitfmt.js", + "testunitfmt_eu_ES.js", "testunits.js", "testunitfmtasync.js", "testdigitalspeed.js", From 5fdfcf4efeaadddaaf9e0be87e90ac4be931fa81 Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Fri, 21 Aug 2020 18:24:48 +0900 Subject: [PATCH 25/48] Add testcase to verify hy-AM --- js/test/date/testDayOfWeek.js | 10 + js/test/date/testMeridiems.js | 10 + js/test/date/testMonthTranslation.js | 45 + js/test/date/testSuite.html | 1 + js/test/date/testSuiteFiles.js | 1 + js/test/date/testWeekdayTranslation.js | 71 + js/test/date/testcalendar.js | 4 +- js/test/date/testclock.js | 11 +- js/test/date/testdatefmt_hy_AM.js | 1788 +++++++++++++++++ js/test/date/testdatetimefmt.js | 26 + .../daterange/testdatefmtrange_fmttemplate.js | 72 + js/test/durfmt/testdurfmt2.js | 41 + js/test/number/testnumfmt2.js | 19 + js/test/root/testlocaleinfo.js | 10 + js/test/root/testscriptinfo.js | 10 + 15 files changed, 2116 insertions(+), 3 deletions(-) create mode 100644 js/test/date/testdatefmt_hy_AM.js diff --git a/js/test/date/testDayOfWeek.js b/js/test/date/testDayOfWeek.js index 0aa7c5b75a..7ca18995cd 100644 --- a/js/test/date/testDayOfWeek.js +++ b/js/test/date/testDayOfWeek.js @@ -1964,6 +1964,16 @@ module.exports.testweekdata = { var info = new LocaleInfo("ka-GE"); test.ok(info !== null); + test.equal(info.getFirstDayOfWeek(), 1); + test.equal(info.getWeekEndStart(), 6); + test.equal(info.getWeekEndEnd(), 0); + test.done(); + }, + testWeekData_hy_AM: function(test) { + test.expect(4); + var info = new LocaleInfo("hy-AM"); + test.ok(info !== null); + test.equal(info.getFirstDayOfWeek(), 1); test.equal(info.getWeekEndStart(), 6); test.equal(info.getWeekEndEnd(), 0); diff --git a/js/test/date/testMeridiems.js b/js/test/date/testMeridiems.js index 44fb518658..e0d4546d07 100644 --- a/js/test/date/testMeridiems.js +++ b/js/test/date/testMeridiems.js @@ -1972,6 +1972,16 @@ module.exports.testmeridiems = { test.equal(fmt[0].name, "AM"); test.equal(fmt[1].name, "PM"); + test.done(); + }, + testMeridiem_hy_AM: function(test) { + test.expect(3); + var fmt = DateFmt.getMeridiemsRange({locale:"hy-AM"}); + test.ok(fmt !== null); + + test.equal(fmt[0].name, "AM"); + test.equal(fmt[1].name, "PM"); + test.done(); } } \ No newline at end of file diff --git a/js/test/date/testMonthTranslation.js b/js/test/date/testMonthTranslation.js index d468675dc9..c468ac8cc5 100644 --- a/js/test/date/testMonthTranslation.js +++ b/js/test/date/testMonthTranslation.js @@ -7315,6 +7315,51 @@ module.exports.testmonthtranslation = { test.equal(value[10], "ნოე"); test.equal(value[11], "დეკ"); + test.done(); + }, + testMonthTranslate_hy_AM: function(test) { + test.expect(24); + + // full, long: MMMM + // medium: MMM + // short: MM + + var value = [], i; + var fmt = new DateFmt({locale:"hy-AM", date:"m", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + test.equal(value[0], "հունվար"); + test.equal(value[1], "փետրվար"); + test.equal(value[2], "մարտ"); + test.equal(value[3], "ապրիլ"); + test.equal(value[4], "մայիս"); + test.equal(value[5], "հունիս"); + test.equal(value[6], "հուլիս"); + test.equal(value[7], "օգոստոս"); + test.equal(value[8], "սեպտեմբեր"); + test.equal(value[9], "հոկտեմբեր"); + test.equal(value[10], "նոյեմբեր"); + test.equal(value[11], "դեկտեմբեր"); + + var fmt = new DateFmt({locale:"hy-AM", date:"m", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + + test.equal(value[0], "հնվ"); + test.equal(value[1], "փտվ"); + test.equal(value[2], "մրտ"); + test.equal(value[3], "ապր"); + test.equal(value[4], "մյս"); + test.equal(value[5], "հնս"); + test.equal(value[6], "հլս"); + test.equal(value[7], "օգս"); + test.equal(value[8], "սեպ"); + test.equal(value[9], "հոկ"); + test.equal(value[10], "նոյ"); + test.equal(value[11], "դեկ"); + test.done(); } } diff --git a/js/test/date/testSuite.html b/js/test/date/testSuite.html index 98d7e4a687..2c689cc567 100644 --- a/js/test/date/testSuite.html +++ b/js/test/date/testSuite.html @@ -74,6 +74,7 @@ + diff --git a/js/test/date/testSuiteFiles.js b/js/test/date/testSuiteFiles.js index dbf16c1a08..6bb37b2264 100644 --- a/js/test/date/testSuiteFiles.js +++ b/js/test/date/testSuiteFiles.js @@ -62,6 +62,7 @@ module.exports.files = [ "testdatefmt_he_IL.js", "testdatefmt_hi_IN.js", "testdatefmt_hr_HR.js", + "testdatefmt_hy_AM.js", "testdatefmt_id_ID.js", "testdatefmt_it_IT.js", "testdatefmt_ja_JP.js", diff --git a/js/test/date/testWeekdayTranslation.js b/js/test/date/testWeekdayTranslation.js index ff7f370ff3..101035140f 100644 --- a/js/test/date/testWeekdayTranslation.js +++ b/js/test/date/testWeekdayTranslation.js @@ -11222,6 +11222,77 @@ module.exports.testWeekdayTranslation = { test.equal(value[5], "პ"); test.equal(value[6], "შ"); + test.done(); + }, + testWeekdayTranslationFull_hy_AM: function(test) { + // full -> wide + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"hy-AM", date:"w", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "կիրակի"); + test.equal(value[1], "երկուշաբթի"); + test.equal(value[2], "երեքշաբթի"); + test.equal(value[3], "չորեքշաբթի"); + test.equal(value[4], "հինգշաբթի"); + test.equal(value[5], "ուրբաթ"); + test.equal(value[6], "շաբաթ"); + test.done(); + }, + testWeekdayTranslationLong_hy_AM: function(test) { + // long -> abbreviate + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"hy-AM", date:"w", length: "long", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "կիր"); + test.equal(value[1], "երկ"); + test.equal(value[2], "երք"); + test.equal(value[3], "չրք"); + test.equal(value[4], "հնգ"); + test.equal(value[5], "ուր"); + test.equal(value[6], "շբթ"); + + test.done(); + }, + testWeekdayTranslationMedium_hy_AM: function(test) { + // medium -> short + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"hy-AM", date:"w", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "կր"); + test.equal(value[1], "եկ"); + test.equal(value[2], "եք"); + test.equal(value[3], "չք"); + test.equal(value[4], "հգ"); + test.equal(value[5], "ու"); + test.equal(value[6], "շբ"); + + test.done(); + }, + testWeekdayTranslationShort_hy_AM: function(test) { + // short: narrow + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"hy-AM", date:"w", length: "short", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "Կ"); + test.equal(value[1], "Ե"); + test.equal(value[2], "Ե"); + test.equal(value[3], "Չ"); + test.equal(value[4], "Հ"); + test.equal(value[5], "Ո"); + test.equal(value[6], "Շ"); + test.done(); } } \ No newline at end of file diff --git a/js/test/date/testcalendar.js b/js/test/date/testcalendar.js index aa4593303b..96407be063 100644 --- a/js/test/date/testcalendar.js +++ b/js/test/date/testcalendar.js @@ -23,7 +23,7 @@ if (typeof(LocaleInfo) === "undefined") { module.exports.testcalendar = { testDefaultCalendar_GregorianCaseAll: function(test) { - test.expect(193); + test.expect(194); var localeList = ["ar-AE","ar-BH","ar-DJ","ar-DZ","ar-EG","ar-IQ","ar-JO","ar-KW","ar-LB","ar-LY","ar-MA","ar-MR", "ar-OM","ar-QA","ar-SA","ar-SD","ar-SY","ar-TN","ar-YE","as-IN","az-Latn-AZ","bg-BG","bn-IN","bs-Latn-BA,bs-Latn-ME", "cs-CZ","da-DK","de-AT","de-CH","de-DE","de-LU","et-EE","el-CY","el-GR","en-AM","en-AU","en-AZ","en-CA","en-GB","en-GH", @@ -32,7 +32,7 @@ module.exports.testcalendar = { "es-CL","es-CO","es-CR","es-DO","es-EC","es-ES","es-GQ","es-GT","es-HN","es-MX","es-NI","es-PA","es-PE","es-PH","es-PR", "es-PY","es-SV","es-US","es-UY","es-VE","fi-FI","fr-BE","fr-BF","fr-BJ","fr-CA","fr-CD","fr-CF","fr-CG","fr-CH","fr-CI", "fr-CM","fr-GQ","fr-DJ","fr-DZ","fr-FR","fr-GA","fr-GN","fr-LB","fr-LU","fr-ML","fr-RW","fr-SN","fr-TG","ga-IE","gu-IN", - "he-IL","hi-IN","hi-SG","hr-HR","hr-ME","hu-HU","id-ID","is-IS","it-CH","it-IT","ja-JP","ka-GE","kk-Cyrl-KZ","km-KH","kn-IN", + "he-IL","hi-IN","hi-SG","hr-HR","hr-ME","hu-HU","hy-AM", "id-ID","is-IS","it-CH","it-IT","ja-JP","ka-GE","kk-Cyrl-KZ","km-KH","kn-IN", "ko-KR","ku-Arab-IQ","lt-LT","lv-LV","mk-MK","ml-IN","mn-Cyrl-MN","mr-IN","ms-MY","ms-SG","nb-NO","nl-BE","nl-NL","pa-IN", "pa-PK","pl-PL","pt-AO","pt-BR","pt-GQ","pt-CV","pt-PT","ro-RO","ru-BY","ru-GE","ru-KG","ru-KZ","ru-RU","ru-UA","si-LK", "sk-SK","sl-SI","sq-AL","sq-ME","sr-Latn-ME","sr-Latn-RS","sv-FI","sv-SE","sw-KE","ta-IN","ta-SG","te-IN","tr-AM","tr-AZ", diff --git a/js/test/date/testclock.js b/js/test/date/testclock.js index f6cc085945..6a3b94724a 100644 --- a/js/test/date/testclock.js +++ b/js/test/date/testclock.js @@ -1,4 +1,4 @@ - /* +/* * testclock.js - test the 12/24 hour support amongst various locales * * Copyright © 2019-2020, JEDLSoft @@ -1773,6 +1773,15 @@ module.exports.testclock = { test.equal(info.getClock(), 24); + test.done(); + }, + testClock_hy_AM: function(test) { + test.expect(2); + var info = new LocaleInfo("hy-AM"); + test.ok(info !== null); + + test.equal(info.getClock(), 24); + test.done(); } } diff --git a/js/test/date/testdatefmt_hy_AM.js b/js/test/date/testdatefmt_hy_AM.js new file mode 100644 index 0000000000..aea24e102b --- /dev/null +++ b/js/test/date/testdatefmt_hy_AM.js @@ -0,0 +1,1788 @@ +/* + * testdatefmt_hy_AM.js - test the date formatter object in Armenian/Armenia + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(JulianDate) === "undefined") { + var JulianDate = require("../../lib/JulianDate.js"); +} +if (typeof(GregorianDate) === "undefined") { + var GregorianDate = require("../../lib/GregorianDate.js"); +} +if (typeof(DateFmt) === "undefined") { + var DateFmt = require("../../lib/DateFmt.js"); +} +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testdatefmt_hy_AM = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + + testDateFmtConstructorEmpty_hy_AM: function(test) { + test.expect(1); + var fmt = new DateFmt({locale: "hy-AM"}); + + test.ok(fmt !== null); + test.done(); + }, + + testDateFmtSimpleShort_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "short"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29.09.11"); + test.done(); + }, + + testDateFmtSimpleMedium_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "medium"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29 սեպ, 2011 թ."); + test.done(); + }, + + testDateFmtSimpleLong_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "long"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29 սեպտեմբերի, 2011 թ."); + test.done(); + }, + + testDateFmtSimpleFull_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011 թ. սեպտեմբերի 29'); + test.done(); + }, + + testDateFmtSimpleTimeShort_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "short", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeMedium_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "medium", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeLong_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", timelength: "long", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeFull_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 1, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '01:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleShort_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "short", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11, 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleMedium_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "medium", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 սեպ, 2011 թ., 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleLong_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "long", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 սեպտեմբերի, 2011 թ., 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleFull_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011 թ. սեպտեմբերի 29, 13:45'); + test.done(); + }, + + + testDateFmtTemplateCalendar_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", calendar: "julian", template: "yyyy-MM-dd"}); + test.ok(fmt !== null); + + var date = new JulianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011-09-29"); + test.done(); + }, + + testDateFmtTemplateCalendarIncompatibleDateType_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", calendar: "julian", template: "yyyy-MM-dd HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + // convert automatically to a Julian calendar date + test.equal(fmt.format(date), "2011-09-16 13:45"); + test.done(); + }, + + testDateFmtTemplateClock12SwitchHH_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", clock: "12", template: "HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateClock12Switchkk_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", clock: "12", template: "kk:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateClock24Switchhh_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", clock: "24", template: "hh:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateClock24SwitchKK: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", clock: "24", template: "KK:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault12hh_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", template: "hh:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault12KK: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", template: "KK:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault24HH_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", template: "HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault24kk_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", template: "kk:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + + testDateFmtTypeDate_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "date"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11'); + test.done(); + }, + + testDateFmtTypeTime_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtTypeDateTime_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11, 13:45'); + test.done(); + }, + + testDateFmtShortDateComponentsY_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", date: "y"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "11"); + test.done(); + }, + + testDateFmtShortDateComponentsM_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", date: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "սե"); + test.done(); + }, + + testDateFmtShortDateComponentsN_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", date: "n"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'ս'); + test.done(); + }, + + testDateFmtShortDateComponentsD_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", date: "d"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29"); + test.done(); + }, + + testDateFmtShortDateComponentsDM_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", date: "dm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09'); + test.done(); + }, + + testDateFmtShortDateComponentsMY_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", date: "my"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '09.11'); + test.done(); + }, + + testDateFmtShortDateComponentsDMY_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", date: "dmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11'); + test.done(); + }, + + testDateFmtShortDateComponentsWDM_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", date: "wdm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09, Հ'); + test.done(); + }, + + testDateFmtShortDateComponentsWDMY_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", date: "wdmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11, Հ'); + test.done(); + }, + + testDateFmtLongDateComponentsWDM_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", date: "wdm", length: "long"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 սեպտեմբերի, հնգ'); + test.done(); + }, + + testDateFmtFullDateComponentsY_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full", date: "y"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011"); + test.done(); + }, + + testDateFmtFullDateComponentsM_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full", date: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "սեպտեմբեր"); + test.done(); + }, + + testDateFmtFullDateComponentsD_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full", date: "d"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29"); + test.done(); + }, + + testDateFmtFullDateComponentsDM_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full", date: "dm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'սեպտեմբերի 29'); + test.done(); + }, + + testDateFmtFullDateComponentsMY_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full", date: "my"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011 թ. սեպտեմբեր'); + test.done(); + }, + + testDateFmtFullDateComponentsDMY_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full", date: "dmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011 թ. սեպտեմբերի 29'); + test.done(); + }, + + testDateFmtFullDateComponentsWDM_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full", date: "wdm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'սեպտեմբերի 29, հինգշաբթի'); + test.done(); + }, + + testDateFmtFullDateComponentsWDMY_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full", date: "wdmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011 թ. սեպտեմբերի 29, հինգշաբթի'); + test.done(); + }, + + testDateFmtShortTimeComponentsS_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", time: "s"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "37"); + test.done(); + }, + + testDateFmtShortTimeComponentsM_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", time: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45"); + test.done(); + }, + + testDateFmtShortTimeComponentsH_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", time: "h"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13"); + test.done(); + }, + + testDateFmtShortTimeComponentsMS_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", time: "ms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHM_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", time: "hm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMS_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", time: "hms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMA_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", time: "hma"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMZ_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "hy-AM", + type: "time", + time: "hmz", + timezone: "Asia/Yerevan" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 +04/+05"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMAZ_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "hy-AM", + type: "time", + time: "hmaz", + timezone: "Asia/Yerevan" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 +04/+05"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSA_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", time: "hmsa"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSZ_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "hy-AM", + type: "time", + time: "hmsz", + timezone: "Asia/Yerevan" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 +04/+05"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSAZ_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "hy-AM", + type: "time", + time: "hmsaz", + timezone: "Asia/Yerevan" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 +04/+05"); + test.done(); + }, + + testDateFmtFullTimeComponentsS_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", length: "full", time: "s"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "37"); + test.done(); + }, + + testDateFmtFullTimeComponentsM_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", length: "full", time: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45"); + test.done(); + }, + + testDateFmtFullTimeComponentsH_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", length: "full", time: "h"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13"); + test.done(); + }, + + testDateFmtFullTimeComponentsMS_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", length: "full", time: "ms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHM_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", length: "full", time: "hm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMS_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", length: "full", time: "hms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMA_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", length: "full", time: "hma"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMZ_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "hy-AM", + type: "time", + length: "full", + time: "hmz", + timezone: "Asia/Yerevan" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 +04/+05"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMAZ_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "hy-AM", + type: "time", + length: "full", + time: "hmaz", + timezone: "Asia/Yerevan" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 +04/+05"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSA_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", type: "time", length: "full", time: "hmsa"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSZ_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "hy-AM", + type: "time", + length: "full", + time: "hmsz", + timezone: "Asia/Yerevan" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 +04/+05"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSAZ_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "hy-AM", + type: "time", + length: "full", + time: "hmsaz", + timezone: "Asia/Yerevan" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 +04/+05"); + test.done(); + }, + + testDateFmtWithTimeZoneAndNoDST_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "hy-AM", + type: "time", + length: "full", + time: "hmsz", + timezone: "Asia/Yerevan" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 12, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 +04/+05"); + test.done(); + }, + + testDateFmtFormatRelativeWithinMinuteAfter_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 30, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "30 վայրկյանից"); + test.done(); + }, +testDateFmtFormatRelativeWithinMinuteBefore_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 44, + second: 30, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "30 վայրկյան առաջ"); + test.done(); + }, +testDateFmtFormatRelativeWithinHourAfter_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "10 րոպեից"); + test.done(); + }, +testDateFmtFormatRelativeWithinHourBefore_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '10 րոպե առաջ'); + test.done(); + }, +testDateFmtFormatRelativeWithinDayAfter_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 17, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '4 ժամից'); + test.done(); + }, +testDateFmtFormatRelativeWithinDayBefore_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '4 ժամ առաջ'); + test.done(); + }, + + testDateFmtFormatRelativeWithinFortnightAfter_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '4 օրից'); + test.done(); + }, +testDateFmtFormatRelativeWithinFortnightBefore_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 16, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '4 օր առաջ'); + test.done(); + }, + + testDateFmtFormatRelativeWithinQuarterAfter_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 11, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '9 շաբաթից'); + test.done(); + }, +testDateFmtFormatRelativeWithinQuarterBefore_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '9 շաբաթ առաջ'); + test.done(); + }, + + testDateFmtFormatRelativeWithinTwoYearsAfter_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2013, + month: 1, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '16 ամսից'); + test.done(); + }, +testDateFmtFormatRelativeWithinTwoYearsBefore_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2010, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '14 ամիս առաջ'); + test.done(); + }, + + testDateFmtFormatRelativeYearsAfter_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 2025, + month: 10, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '14 տարուց'); + test.done(); + }, +testDateFmtFormatRelativeYearsBefore_hy_AM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "hy-AM", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "hy-AM", + year: 1990, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '21 տարի առաջ'); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/date/testdatetimefmt.js b/js/test/date/testdatetimefmt.js index 2ad5c635b2..d4fa0b36fe 100644 --- a/js/test/date/testdatetimefmt.js +++ b/js/test/date/testdatetimefmt.js @@ -5128,6 +5128,32 @@ module.exports.testdatetimeformat = { result1 = new DateFmt({locale:"ka-GE", type:"time", time:"ahmsz", length:"full", useNative:false, timezone:"local"}).template; test.equal(result1, "HH:mm:ss z"); + test.done(); + }, + testDateTimeFormat_hy_AM: function(test) { + test.expect(7); + + var result1, result2, result3, result4; + + result1 = new DateFmt({locale:"hy-AM", type:"date", date:"dmwy", length: "full", useNative:false, timezone:"local"}).template; + result2 = new DateFmt({locale:"hy-AM", type:"date", date:"dmwy", length: "long", useNative:false, timezone:"local"}).template; + result3 = new DateFmt({locale:"hy-AM", type:"date", date:"dmwy", length: "medium", useNative:false, timezone:"local"}).template; + result4 = new DateFmt({locale:"hy-AM", type:"date", date:"dmwy", length: "short", useNative:false, timezone:"local"}).template; + + test.equal(result1, "yyyy թ. MMMM d, EEEE"); + test.equal(result2, "dd MMMM, yyyy թ., EEE"); + test.equal(result3, "dd MMM, yyyy թ., EE"); + test.equal(result4, "dd.MM.yy, E"); + + result1 = new DateFmt({locale:"hy-AM", type:"datetime", date:"dmwy", length: "full", useNative:false, timezone:"local"}).template; + result2 = new DateFmt({locale:"hy-AM", type:"datetime", date:"dmwy", length: "short", useNative:false, timezone:"local"}).template; + + test.equal(result1, "yyyy թ. MMMM d, EEEE, HH:mm"); + test.equal(result2, "dd.MM.yy, E, HH:mm"); + + result1 = new DateFmt({locale:"hy-AM", type:"time", time:"ahmsz", length:"full", useNative:false, timezone:"local"}).template; + test.equal(result1, "HH:mm:ss z"); + test.done(); } } \ No newline at end of file diff --git a/js/test/daterange/testdatefmtrange_fmttemplate.js b/js/test/daterange/testdatefmtrange_fmttemplate.js index 05cf803d08..37ea93369c 100644 --- a/js/test/daterange/testdatefmtrange_fmttemplate.js +++ b/js/test/daterange/testdatefmtrange_fmttemplate.js @@ -13864,6 +13864,78 @@ module.exports.testdaterangefmt = { test.equal(templatec30[2], "{sy} – {ey}"); test.equal(templatec30[3], "{sy} – {ey}"); + test.done(); + }, + testDateRngFmt_hy_AM: function(test) { + test.expect(36); + var fmt; + var data = setVariables(); + var length = data["fullLength"]; + var abbrLength = data["abbrLength"]; + + var templatec00 = [],templatec01 = [],templatec02 = [],templatec03 = []; + var templatec10 = [],templatec11 = [],templatec12 = [],templatec20 = []; + var templatec30 = []; + + //dmy + for (var i=0; i < 4; i++) { + fmt = new DateRngFmt({locale:"hy-AM", length: length[i]}) + templatec00.push(fmt.dateFmt.formats.range["c00"][abbrLength[i]]); + templatec01.push(fmt.dateFmt.formats.range["c01"][abbrLength[i]]); + templatec02.push(fmt.dateFmt.formats.range["c02"][abbrLength[i]]); + templatec03.push(fmt.dateFmt.formats.range["c03"][abbrLength[i]]); + templatec10.push(fmt.dateFmt.formats.range["c10"][abbrLength[i]]); + templatec11.push(fmt.dateFmt.formats.range["c11"][abbrLength[i]]); + templatec12.push(fmt.dateFmt.formats.range["c12"][abbrLength[i]]); + templatec20.push(fmt.dateFmt.formats.range["c20"][abbrLength[i]]); + templatec30.push(fmt.dateFmt.formats.range["c30"][abbrLength[i]]); + } + + test.equal(templatec00[0], '{sy} թ. {sm} {sd}, {st} – {et}'); + test.equal(templatec00[1], '{sd} {sm}, {sy} թ., {st} – {et}'); + test.equal(templatec00[2], '{sd} {sm}, {sy} թ., {st} – {et}'); + test.equal(templatec00[3], '{sd}.{sm}.{sy}, {st} – {et}'); + + test.equal(templatec01[0], '{sy} թ. {sm} {sd}, {st} – {ey} թ. {em} {ed}, {et}'); + test.equal(templatec01[1], '{sd} {sm}, {sy} թ., {st} – {ed} {em}, {ey} թ., {et}'); + test.equal(templatec01[2], '{sd} {sm}, {sy} թ., {st} – {ed} {em}, {ey} թ., {et}'); + test.equal(templatec01[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + + test.equal(templatec02[0], '{sy} թ. {sm} {sd}, {st} – {ey} թ. {em} {ed}, {et}'); + test.equal(templatec02[1], '{sd} {sm}, {sy} թ., {st} – {ed} {em}, {ey} թ., {et}'); + test.equal(templatec02[2], '{sd} {sm}, {sy} թ., {st} – {ed} {em}, {ey} թ., {et}'); + test.equal(templatec02[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + + test.equal(templatec03[0], '{sy} թ. {sm} {sd}, {st} – {ey} թ. {em} {ed}, {et}'); + test.equal(templatec03[1], '{sd} {sm}, {sy} թ., {st} – {ed} {em}, {ey} թ., {et}'); + test.equal(templatec03[2], '{sd} {sm}, {sy} թ., {st} – {ed} {em}, {ey} թ., {et}'); + test.equal(templatec03[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + + test.equal(templatec10[0], '{sy} թ. {sm} {sd} – {ed}'); + test.equal(templatec10[1], '{sd} – {ed} {em}, {ey} թ.'); + test.equal(templatec10[2], '{sd} – {ed} {em}, {ey} թ.'); + test.equal(templatec10[3], '{sd} – {ed}.{em}.{ey}'); + + test.equal(templatec11[0], '{sy} թ. {sm} {sd} – {em} {ed}'); + test.equal(templatec11[1], '{sd} {sm} – {ed} {em}, {ey} թ.'); + test.equal(templatec11[2], '{sd} {sm} – {ed} {em}, {ey} թ.'); + test.equal(templatec11[3], '{sd}.{sm} – {ed}.{em}.{ey}'); + + test.equal(templatec12[0], '{sy} թ. {sm} {sd} – {ey} թ. {em} {ed}'); + test.equal(templatec12[1], '{sd} {sm}, {sy} թ. – {ed} {em}, {ey} թ.'); + test.equal(templatec12[2], '{sd} {sm}, {sy} թ. – {ed} {em}, {ey} թ.'); + test.equal(templatec12[3], '{sd}.{sm}.{sy} – {ed}.{em}.{ey}'); + + test.equal(templatec20[0], '{sy} թ. {sm} – {ey} թ. {em}'); + test.equal(templatec20[1], '{sm}, {sy} թ. – {em}, {ey} թ.'); + test.equal(templatec20[2], '{sm}, {sy} թ. – {em}, {ey} թ.'); + test.equal(templatec20[3], '{sm}.{sy} – {em}.{ey}'); + + test.equal(templatec30[0], "{sy} – {ey}"); + test.equal(templatec30[1], "{sy} – {ey}"); + test.equal(templatec30[2], "{sy} – {ey}"); + test.equal(templatec30[3], "{sy} – {ey}"); + test.done(); } } \ No newline at end of file diff --git a/js/test/durfmt/testdurfmt2.js b/js/test/durfmt/testdurfmt2.js index 5d8c54d100..513fc15ad5 100644 --- a/js/test/durfmt/testdurfmt2.js +++ b/js/test/durfmt/testdurfmt2.js @@ -9035,6 +9035,47 @@ module.exports.testdurfmt2 = { test.equal(clockformatted_18[2], '18სთ, 18წთ, 18წმ'); test.equal(clockformatted_18[3], '18სთ, 18წთ, 18წმ'); + test.done(); + }, + testDurFmt_hy_AM: function(test) { + test.expect(16); + // 1 18 + var textfmt; + var data = setVariable(); + var length = data["fullLength"]; + + var textformatted_1 = [],textformatted_15 = []; + var clockformatted_1 = [],clockformatted_15 = []; + + for (var i=0; i<4; i++) { + textfmt = new DurationFmt({locale: "hy-AM", style:"text", length:length[i]}); + textformatted_1.push(textfmt.format({year: 1,month: 1,week: 1,day: 1}).toString()); + textformatted_15.push(textfmt.format({year: 15,month: 15,week: 15,day: 15}).toString()); + + clockformatted_1.push(textfmt.format({hour: 1,minute: 1,second: 1}).toString()); + clockformatted_15.push(textfmt.format({hour: 15,minute: 15,second: 15}).toString()); + } + + test.equal(textformatted_1[0], '1 տարի, 1 ամիս, 1 շաբաթ և 1 օր'); + test.equal(textformatted_1[1], '1 տ 1 ամս 1 շաբ 1 օր'); + test.equal(textformatted_1[2], '1 տ 1 ա 1 շ 1 օ'); + test.equal(textformatted_1[3], '1 տ 1 ա 1 շ 1 օ'); + + test.equal(textformatted_15[0], '15 տարի, 15 ամիս, 15 շաբաթ և 15 օր'); + test.equal(textformatted_15[1], '15 տ 15 ամս 15 շաբ 15 օր'); + test.equal(textformatted_15[2], '15 տ 15 ա 15 շ 15 օ'); + test.equal(textformatted_15[3], '15 տ 15 ա 15 շ 15 օ'); + + test.equal(clockformatted_1[0], '1 ժամ, 1 րոպե և 1 վայրկյան'); + test.equal(clockformatted_1[1], '1 ժ 1 ր 1 վրկ'); + test.equal(clockformatted_1[2], '1 ժ 1 ր 1 վ'); + test.equal(clockformatted_1[3], '1 ժ 1 ր 1 վ'); + + test.equal(clockformatted_15[0], '15 ժամ, 15 րոպե և 15 վայրկյան'); + test.equal(clockformatted_15[1], '15 ժ 15 ր 15 վրկ'); + test.equal(clockformatted_15[2], '15 ժ 15 ր 15 վ'); + test.equal(clockformatted_15[3], '15 ժ 15 ր 15 վ'); + test.done(); } } diff --git a/js/test/number/testnumfmt2.js b/js/test/number/testnumfmt2.js index 845f03f896..1efde921d5 100644 --- a/js/test/number/testnumfmt2.js +++ b/js/test/number/testnumfmt2.js @@ -3773,5 +3773,24 @@ module.exports.testnumfmt2 = { test.equal(li.getCurrencyFormats().commonNegative, "-{n} {s}"); test.equal(curfmt.format(57.05), "57,05 ₾"); //GEL test.done(); + }, + testNumFmt_hy_AM: function(test) { + test.expect(9); + var li = new LocaleInfo("hy-AM"); + var fmt = new NumFmt({locale:"hy-AM", type:"standard", useNative:false}); + test.equal(li.getDecimalSeparator(), ","); + test.equal(li.getGroupingSeparator(), " "); + test.equal(fmt.format(123456789.45), "123 456 789,45"); + + var pctfmt = new NumFmt({locale:"hy-AM", type:"percentage", useNative:false}); + test.equal(li.getPercentageFormat(), "{n}%"); + test.equal(li.getNegativePercentageFormat(), "-{n}%"); + test.equal(pctfmt.format(34), "34%"); + + var curfmt = new NumFmt({locale: "hy-AM", type: "currency", useNative:false, currency:li.getCurrency()}); + test.equal(li.getCurrencyFormats().common, "{n} {s}"); + test.equal(li.getCurrencyFormats().commonNegative, "-{n} {s}"); + test.equal(curfmt.format(57.05), "57,05 դր."); + test.done(); } } \ No newline at end of file diff --git a/js/test/root/testlocaleinfo.js b/js/test/root/testlocaleinfo.js index 9949aaee2f..e96dadb626 100644 --- a/js/test/root/testlocaleinfo.js +++ b/js/test/root/testlocaleinfo.js @@ -13388,5 +13388,15 @@ module.exports.testlocaleinfo = { test.equal(info.getDelimiterQuotationEnd(), "“"); test.equal(info.getPaperSize(), "A4"); test.done(); + }, + testLocaleInfoQuotation_hy_AM: function(test) { + test.expect(4); + var info = new LocaleInfo("hy-AM"); + test.ok(info !== null); + + test.equal(info.getDelimiterQuotationStart(), "«"); + test.equal(info.getDelimiterQuotationEnd(), "»"); + test.equal(info.getPaperSize(), "A4"); + test.done(); } }; \ No newline at end of file diff --git a/js/test/root/testscriptinfo.js b/js/test/root/testscriptinfo.js index c686e0409e..7f6af7de07 100644 --- a/js/test/root/testscriptinfo.js +++ b/js/test/root/testscriptinfo.js @@ -2185,5 +2185,15 @@ module.exports.testscriptinfo = { test.equal(li.getScript(), "Geor"); test.equal(scinfo.getScriptDirection(), "ltr"); test.done(); + }, + testScriptInfo_hy_AM: function(test) { + test.expect(4); + var li = new LocaleInfo("hy-AM"); + var scinfo = new ScriptInfo(li.getScript()); + test.ok(li !== null); + test.ok(scinfo !== null); + test.equal(li.getScript(), "Armn"); + test.equal(scinfo.getScriptDirection(), "ltr"); + test.done(); } }; From d081eed7747ae158a880ed7c7f443e7d09bfdcf3 Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Mon, 24 Aug 2020 10:49:25 +0900 Subject: [PATCH 26/48] Add testcases to verify hy-AM --- js/test/daterange/testSuite.html | 1 + js/test/daterange/testSuiteFiles.js | 1 + js/test/daterange/testdatefmtrange_hy_AM.js | 692 ++++++++++++++++++++ js/test/root/testcountry.js | 26 + js/test/root/testlocalematch.js | 56 ++ js/test/root/teststrings.js | 40 ++ js/test/strings-ext/testSuite.html | 1 + js/test/strings-ext/testSuiteCompiled.html | 1 + js/test/strings-ext/testSuiteFiles.js | 1 + js/test/strings-ext/testlistfmt_hy_AM.js | 253 +++++++ js/test/units/testSuite.html | 1 + js/test/units/testSuiteFiles.js | 1 + js/test/units/testunitfmt_hy_AM.js | 331 ++++++++++ 13 files changed, 1405 insertions(+) create mode 100644 js/test/daterange/testdatefmtrange_hy_AM.js create mode 100644 js/test/strings-ext/testlistfmt_hy_AM.js create mode 100644 js/test/units/testunitfmt_hy_AM.js diff --git a/js/test/daterange/testSuite.html b/js/test/daterange/testSuite.html index 3d48d1a1e9..638ec68707 100644 --- a/js/test/daterange/testSuite.html +++ b/js/test/daterange/testSuite.html @@ -64,6 +64,7 @@ + diff --git a/js/test/daterange/testSuiteFiles.js b/js/test/daterange/testSuiteFiles.js index d79236ec11..2271e6e397 100644 --- a/js/test/daterange/testSuiteFiles.js +++ b/js/test/daterange/testSuiteFiles.js @@ -52,6 +52,7 @@ module.exports.files = [ "testdatefmtrange_hi_IN.js", "testdatefmtrange_hr_HR.js", "testdatefmtrange_hu_HU.js", + "testdatefmtrange_hy_AM.js", "testdatefmtrange_id_ID.js", "testdatefmtrange_it_IT.js", "testdatefmtrange_ja_JP.js", diff --git a/js/test/daterange/testdatefmtrange_hy_AM.js b/js/test/daterange/testdatefmtrange_hy_AM.js new file mode 100644 index 0000000000..71dc7ac6a9 --- /dev/null +++ b/js/test/daterange/testdatefmtrange_hy_AM.js @@ -0,0 +1,692 @@ +/* + * testdatefmtrange_hy_AM.js - test the date range formatter object Georgian/Georgia + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(GregorianDate) === "undefined") { + var GregorianDate = require("../../lib/GregorianDate.js"); +} +if (typeof(DateRngFmt) === "undefined") { + var DateRngFmt = require("../../lib/DateRngFmt.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testdatefmtrange_hy_AM = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + + testDateRngFmthyAMRangeInDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "31.12.11, 13:45 – 14:30"); + test.done(); + }, + testDateRngFmthyAMRangeInDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "31 դեկ, 2011 թ., 13:45 – 14:30"); + test.done(); + }, + testDateRngFmthyAMRangeInDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "31 դեկտեմբերի, 2011 թ., 13:45 – 14:30"); + test.done(); + }, + testDateRngFmthyAMRangeInDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011 թ. դեկտեմբերի 31, 13:45 – 14:30"); + test.done(); + }, + + testDateRngFmthyAMRangeNextDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "30.12.11, 13:45 – 31.12.11, 14:30"); + test.done(); + }, + testDateRngFmthyAMRangeNextDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "30 դեկ, 2011 թ., 13:45 – 31 դեկ, 2011 թ., 14:30"); + test.done(); + }, + testDateRngFmthyAMRangeNextDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "30 դեկտեմբերի, 2011 թ., 13:45 – 31 դեկտեմբերի, 2011 թ., 14:30"); + test.done(); + }, + testDateRngFmthyAMRangeNextDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011 թ. դեկտեմբերի 30, 13:45 – 2011 թ. դեկտեմբերի 31, 14:30"); + test.done(); + }, + + testDateRngFmthyAMRangeMultiDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31.12.11"); + test.done(); + }, + testDateRngFmthyAMRangeMultiDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31 դեկ, 2011 թ."); + test.done(); + }, + testDateRngFmthyAMRangeMultiDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31 դեկտեմբերի, 2011 թ."); + test.done(); + }, + testDateRngFmthyAMRangeMultiDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011 թ. դեկտեմբերի 20 – 31"); + test.done(); + }, + + testDateRngFmthyAMRangeNextMonthShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20.11 – 31.12.11"); + test.done(); + }, + testDateRngFmthyAMRangeNextMonthMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 նոյ – 31 դեկ, 2011 թ."); + test.done(); + }, + testDateRngFmthyAMRangeNextMonthLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 նոյեմբերի – 31 դեկտեմբերի, 2011 թ."); + test.done(); + }, + testDateRngFmthyAMRangeNextMonthFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011 թ. նոյեմբերի 20 – դեկտեմբերի 31"); + test.done(); + }, + + testDateRngFmthyAMRangeNextYearShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20.11.11 – 31.01.12"); + test.done(); + }, + testDateRngFmthyAMRangeNextYearMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 նոյ, 2011 թ. – 31 հնվ, 2012 թ."); + test.done(); + }, + testDateRngFmthyAMRangeNextYearLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 նոյեմբերի, 2011 թ. – 31 հունվարի, 2012 թ."); + test.done(); + }, + testDateRngFmthyAMRangeNextYearFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011 թ. նոյեմբերի 20 – 2012 թ. հունվարի 31"); + test.done(); + }, + + testDateRngFmthyAMRangeMultiYearShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "11.11 – 01.14"); + test.done(); + }, + testDateRngFmthyAMRangeMultiYearMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "նոյ, 2011 թ. – հնվ, 2014 թ."); + test.done(); + }, + testDateRngFmthyAMRangeMultiYearLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "նոյեմբերի, 2011 թ. – հունվարի, 2014 թ."); + test.done(); + }, + testDateRngFmthyAMRangeMultiYearFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011 թ. նոյեմբերի – 2014 թ. հունվարի"); + test.done(); + }, + testDateRngFmthyAMManyYearsFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "hy-AM", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2064, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011 – 2064"); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/root/testcountry.js b/js/test/root/testcountry.js index f059070888..d48f76fee5 100644 --- a/js/test/root/testcountry.js +++ b/js/test/root/testcountry.js @@ -172,6 +172,32 @@ module.exports.testcountry = { test.equal(locale.toString(), "en-AU"); test.done(); }, + testCountryLocalehy_AM: function(test) { + test.expect(4); + var ctry = new Country({ + locale: "hy-AM" + }); + test.ok(ctry !== null); + + test.equal(ctry.getName("MO"), "Չինաստանի Մակաո ՀՎՇ"); + test.equal(ctry.getCode("Չինաստանի Մակաո ՀՎՇ"), "MO"); + var locale = ctry.getLocale(); + test.equal(locale.toString(), "hy-AM"); + test.done(); + }, + testCountryLocalehy_AM2: function(test) { + test.expect(4); + var ctry = new Country({ + locale: "hy-AM" + }); + test.ok(ctry !== null); + + test.equal(ctry.getName("KR"), 'Հարավային Կորեա'); + test.equal(ctry.getCode('Հարավային Կորեա'), "KR"); + var locale = ctry.getLocale(); + test.equal(locale.toString(), "hy-AM"); + test.done(); + }, testCountryGetByCodeUnknown: function(test) { try { diff --git a/js/test/root/testlocalematch.js b/js/test/root/testlocalematch.js index 850772fff3..be9d458940 100644 --- a/js/test/root/testlocalematch.js +++ b/js/test/root/testlocalematch.js @@ -1106,6 +1106,39 @@ module.exports.testlocalematch = { test.equal(locale.getSpec(), "ka-Geor-GE"); test.done(); }, + testLocaleMatcherGetLikelyLocaleByLocaleCodehy: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "hy" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "hy-Armn-AM"); + test.done(); + }, + testLocaleMatcherGetLikelyLocaleByLocaleCodehy2: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "AM" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "hy-Armn-AM"); + test.done(); + }, + testLocaleMatcherGetLikelyLocaleByLocaleCodehy3: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "Aram-AM" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "hy-Armn-AM"); + test.done(); + }, testLocaleMatcherMatchExactFullLocale: function(test) { test.expect(2); @@ -1835,5 +1868,28 @@ module.exports.testlocalematch = { test.ok(typeof(locale) !== "undefined"); test.equal(locale.getSpec(), "ar-Hebr-IL"); test.done(); + }, + testLocaleMatcherGetLikelyLocaleMinimalNonDefaultLocalehyAM: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "hy-AM" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocaleMinimal(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "hy-AM"); + test.done(); + }, + testLocaleMatcherGetLikelyLocaleMinimalNonDefaultLocalehyAM2: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "hy-Aram" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocaleMinimal(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "hy-AM"); + test.done(); } + }; diff --git a/js/test/root/teststrings.js b/js/test/root/teststrings.js index 57a8473b46..a5f0fa2f2e 100644 --- a/js/test/root/teststrings.js +++ b/js/test/root/teststrings.js @@ -3406,6 +3406,26 @@ module.exports.teststrings = { test.equal(str.formatChoice(1), "There items are one"); test.done(); }, + testStringFormatChoiceCharClassesComplexhyAM: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("hy-AM"); + + test.ok(str !== null); + + test.equal(str.formatChoice(1), "There items are one"); + test.done(); + }, + testStringFormatChoiceCharClassesComplexhyAM2: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("hy-AM"); + + test.ok(str !== null); + + test.equal(str.formatChoice(15), "Default items"); + test.done(); + }, testStringFormatChoiceDecimal1: function(test) { test.expect(2); @@ -3670,5 +3690,25 @@ module.exports.teststrings = { test.equal(str.formatChoice(1.7), "Default items"); test.done(); + }, + testStringFormatChoiceDecimalhyAM: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("hy-AM"); + + test.ok(str !== null); + + test.equal(str.formatChoice(1.0), "There items are one"); + test.done(); + }, + testStringFormatChoiceDecimalhyAM2: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("hy-AM"); + + test.ok(str !== null); + + test.equal(str.formatChoice(3.5), "Default items"); + test.done(); } }; \ No newline at end of file diff --git a/js/test/strings-ext/testSuite.html b/js/test/strings-ext/testSuite.html index ea49ebf3d4..f58a81c7a3 100644 --- a/js/test/strings-ext/testSuite.html +++ b/js/test/strings-ext/testSuite.html @@ -45,6 +45,7 @@ + diff --git a/js/test/strings-ext/testSuiteCompiled.html b/js/test/strings-ext/testSuiteCompiled.html index 9f6602f423..2d52b0a6e3 100644 --- a/js/test/strings-ext/testSuiteCompiled.html +++ b/js/test/strings-ext/testSuiteCompiled.html @@ -46,6 +46,7 @@ + diff --git a/js/test/strings-ext/testSuiteFiles.js b/js/test/strings-ext/testSuiteFiles.js index b290555e25..d4099d70ad 100644 --- a/js/test/strings-ext/testSuiteFiles.js +++ b/js/test/strings-ext/testSuiteFiles.js @@ -34,6 +34,7 @@ module.exports.files = [ "testlistfmt_he_IL.js", "testlistfmt_hi_IN.js", "testlistfmt_hr.js", + "testlistfmt_hy_AM.js", "testlistfmt_it.js", "testlistfmt_ja_JP.js", "testlistfmt_ka_GE.js", diff --git a/js/test/strings-ext/testlistfmt_hy_AM.js b/js/test/strings-ext/testlistfmt_hy_AM.js new file mode 100644 index 0000000000..53c87a3f32 --- /dev/null +++ b/js/test/strings-ext/testlistfmt_hy_AM.js @@ -0,0 +1,253 @@ +/* + * testlistfmt_hy_AM.js - test the list formatter object + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSe-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(ListFmt) === "undefined") { + var ListFmt = require("../../lib/ListFmt.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testlistfmt_hy_AM = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + testListFmtkaGENumberFormatOne: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ"]), "մեկ"); + test.done(); + }, + testListFmtkaGENumberFormatTwo: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու"]), "մեկ և երկու"); + test.done(); + }, + testListFmtkaGENumberFormatThree: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու", "երեքը"]), "մեկ, երկու և երեքը"); + test.done(); + }, + testListFmtkaGENumberFormatFour: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու", "երեքը", "չորսը"]), "մեկ, երկու, երեքը և չորսը"); + test.done(); + }, + testListFmtkaGENumberFormatFive: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու", "երեքը", "չորսը", "հինգը"]), "մեկ, երկու, երեքը, չորսը և հինգը"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatOneShort: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ"]), "մեկ"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatTwoShort: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու"]), "մեկ և երկու"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatThreeShort: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու", "երեքը"]), "մեկ երկու և երեքը"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatFourShort: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու", "երեքը", "չորսը"]), "մեկ երկու երեքը և չորսը"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatFiveShort: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու", "երեքը", "չորսը", "հինգը"]), "մեկ երկու երեքը չորսը և հինգը"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatOneFull: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ"]), "մեկ"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatTwoFull: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու"]), "մեկ և երկու"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatThreeFull: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու", "երեքը"]), "մեկ, երկու և երեքը"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatFourFull: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու", "երեքը", "չորսը"]), "մեկ, երկու, երեքը և չորսը"); + test.done(); + }, + testListFmtUnitStylekaGENumberFormatFiveFull: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու", "երեքը", "չորսը", "հինգը"]), "մեկ, երկու, երեքը, չորսը և հինգը"); + test.done(); + }, + testListFmtORStylekaGENumberFormatOne: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ"]), "մեկ"); + test.done(); + }, + testListFmtORStylekaGENumberFormatTwo: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու"]), "մեկ կամ երկու"); + test.done(); + }, + testListFmtORStylekaGENumberFormatThree: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու", "երեքը"]), "մեկ, երկու կամ երեքը"); + test.done(); + }, + testListFmtORStylekaGENumberFormatFour: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու", "երեքը", "չորսը"]), "մեկ, երկու, երեքը կամ չորսը"); + test.done(); + }, + testListFmtORStylekaGENumberFormatFiveFull: function(test) { + var fmt = new ListFmt({ + locale: "hy-AM", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["մեկ", "երկու", "երեքը", "չորսը", "հինգը"]), "մեկ, երկու, երեքը, չորսը կամ հինգը"); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/units/testSuite.html b/js/test/units/testSuite.html index 39c7e003c9..08d7e1dac7 100644 --- a/js/test/units/testSuite.html +++ b/js/test/units/testSuite.html @@ -43,6 +43,7 @@ + diff --git a/js/test/units/testSuiteFiles.js b/js/test/units/testSuiteFiles.js index 152892446b..3c21682424 100644 --- a/js/test/units/testSuiteFiles.js +++ b/js/test/units/testSuiteFiles.js @@ -31,6 +31,7 @@ module.exports.files = [ "testtemp.js", "testtime.js", "testunitfmt.js", + "testunitfmt_hy_AM.js", "testunits.js", "testunitfmtasync.js", "testdigitalspeed.js", diff --git a/js/test/units/testunitfmt_hy_AM.js b/js/test/units/testunitfmt_hy_AM.js new file mode 100644 index 0000000000..868112b4df --- /dev/null +++ b/js/test/units/testunitfmt_hy_AM.js @@ -0,0 +1,331 @@ +/* + * testunitfmt_hy_AM.js - test the unitfmt for hy-AM + * + * Copyright © 2020 JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(UnitFmt) === "undefined") { + var UnitFmt = require("../../lib/UnitFmt.js"); +} +if (typeof(Measurement) === "undefined") { + var Measurement = require("../../lib/Measurement.js"); +} + +if (typeof(MeasurementFactory) === "undefined") { + var MeasurementFactory = require("../../lib/MeasurementFactory.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testunitfmt_hy_AM = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + testUnitFormatGetLocale_hy_AM: function(test) { + test.expect(2); + var uf = new UnitFmt({ + locale: "hy-AM" + }); + test.ok(uf.getLocale()); + test.equal(uf.getLocale().getSpec(), "hy-AM"); + test.done(); + }, + testGetMeasurementSystem_hy_AM: function(test) { + test.expect(1); + + test.equal(Measurement.getMeasurementSystemForLocale("hy-AM"), "metric"); + test.done(); + }, + testUnitFormatTemperature1_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "fahrenheit", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + length: "short", + autoConvert: true, + maxFractionDigits: 2, + roundingMode: "down" + }); + var str = uf.format(m1); + test.equal(str, "-16,66 °C"); + test.done(); + }, + testUnitFormatTemperature2_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "fahrenheit", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + autoConvert: true, + autoScale: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "-16,666666666666668 աստիճան ըստ Ցելսիուսի"); + test.done(); + }, + + testUnitFormatArea1_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "square centimeter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + autoConvert:true, + length:"short" + }); + + var str = uf.format(m1); + test.equal(str, "2 սմ²"); + test.done(); + }, + testUnitFormatArea2_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "square centimeter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + autoConvert: true, + length: "long" + }); + + var str = uf.format(m1); + test.equal(str, "2 քառակուսի սանտիմետր"); + test.done(); + }, + testUnitFormatArea3_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "hectare", + amount: 1000 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + autoConvert: true, + length: "short" + }); + + var str = uf.format(m1); + test.equal(str, "10 կմ²"); + test.done(); + }, + testUnitFormatArea4_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "hectare", + amount: 1000 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + autoConvert: true, + length: "long" + }); + + var str = uf.format(m1); + test.equal(str, "10 քառակուսի կիլոմետր"); + test.done(); + }, + testUnitFormatFuelConsumption1_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km/liter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + autoConvert: true, + length: "short" + }); + var str = uf.format(m1); + test.equal(str, "2 կմ/լ"); + test.done(); + }, + testUnitFormatFuelConsumption2_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km/liter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + autoConvert: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "2 կիլոմետր լիտրի վրա"); + test.done(); + }, + testUnitFormatLength1_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "mile", + amount: 2000 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + autoConvert: true, + length: "short" + }); + var str = uf.format(m1); + test.equal(str, "3,21868 Mm"); + test.done(); + }, + testUnitFormatLength2_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "mile", + amount: 2000 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + autoConvert: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "3,21868 megameters"); + test.done(); + }, + testUnitFormatWithUsageVehicleDistance1_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km", + amount: 10 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + usage: "vehicleDistance", + length: "short", + autoConvert: true, + }); + var str = uf.format(m1); + test.equal(str, "10 կմ"); + test.done(); + }, + testUnitFormatWithUsageVehicleDistance2_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km", + amount: 10 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + usage: "vehicleDistance", + length: "long", + autoConvert: true + }); + var str = uf.format(m1); + test.equal(str, "10 կիլոմետր"); + test.done(); + }, + testUnitFormatWithUsageFuelVolume1_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "imperial gallon", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + usage: "fuelVolume", + length: "short", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "9,09 լ"); + test.done(); + }, + testUnitFormatWithUsageFuelVolume2_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "imperial gallon", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + usage: "fuelVolume", + length: "long", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "9,09 լիտր"); + test.done(); + }, + testUnitFormatWithUsageOverrideSignificantDigits1_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "kWh", + amount: 102.338322234 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + usage: "electricalEnergy", + length: "short", + significantDigits: "6", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "102,338 կՎտ·ժ"); + test.done(); + }, + testUnitFormatWithUsageOverrideSignificantDigits2_hy_AM: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "kWh", + amount: 102.338322234 + }); + + var uf = new UnitFmt({ + locale: "hy-AM", + usage: "electricalEnergy", + length: "long", + significantDigits: "6", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "102,338 կիլովատտ-ժամ"); + test.done(); + } +} \ No newline at end of file From bfda53718bced7eb1e3d7b150f438600367ef6ed Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Mon, 24 Aug 2020 16:17:11 +0900 Subject: [PATCH 27/48] Add test cases to verify ca-AD, ca-ES --- js/test/date/testDayOfWeek.js | 20 + js/test/date/testMeridiems.js | 20 + js/test/date/testMonthTranslation.js | 90 + js/test/date/testSuite.html | 3 +- js/test/date/testSuiteFiles.js | 1 + js/test/date/testWeekdayTranslation.js | 142 + js/test/date/testcalendar.js | 4 +- js/test/date/testclock.js | 18 + js/test/date/testdatefmt_ca.js | 3536 +++++++++++++++++ js/test/date/testdatetimefmt.js | 52 + js/test/daterange/testSuite.html | 3 +- js/test/daterange/testSuiteFiles.js | 3 +- js/test/daterange/testdatefmtrange_ca.js | 1348 +++++++ .../daterange/testdatefmtrange_fmttemplate.js | 144 + js/test/durfmt/testdurfmt2.js | 82 + js/test/number/testcurrency.js | 20 +- js/test/number/testnumfmt2.js | 38 + js/test/root/testcountry.js | 28 +- js/test/root/testlocalematch.js | 23 + js/test/root/testscriptinfo.js | 20 + js/test/root/teststrings.js | 41 + js/test/strings-ext/testSuite.html | 3 +- js/test/strings-ext/testSuiteCompiled.html | 3 +- js/test/strings-ext/testSuiteFiles.js | 3 +- js/test/strings-ext/testlistfmt_ca.js | 475 +++ js/test/units/testSuite.html | 3 +- js/test/units/testSuiteFiles.js | 3 +- js/test/units/testunitfmt_ca.js | 626 +++ 28 files changed, 6740 insertions(+), 12 deletions(-) create mode 100644 js/test/date/testdatefmt_ca.js create mode 100644 js/test/daterange/testdatefmtrange_ca.js create mode 100644 js/test/strings-ext/testlistfmt_ca.js create mode 100644 js/test/units/testunitfmt_ca.js diff --git a/js/test/date/testDayOfWeek.js b/js/test/date/testDayOfWeek.js index 0aa7c5b75a..7a05b4cb3b 100644 --- a/js/test/date/testDayOfWeek.js +++ b/js/test/date/testDayOfWeek.js @@ -1964,6 +1964,26 @@ module.exports.testweekdata = { var info = new LocaleInfo("ka-GE"); test.ok(info !== null); + test.equal(info.getFirstDayOfWeek(), 1); + test.equal(info.getWeekEndStart(), 6); + test.equal(info.getWeekEndEnd(), 0); + test.done(); + }, + testWeekData_ca_AD: function(test) { + test.expect(4); + var info = new LocaleInfo("ca-AD"); + test.ok(info !== null); + + test.equal(info.getFirstDayOfWeek(), 1); + test.equal(info.getWeekEndStart(), 6); + test.equal(info.getWeekEndEnd(), 0); + test.done(); + }, + testWeekData_ca_ES: function(test) { + test.expect(4); + var info = new LocaleInfo("ca-ES"); + test.ok(info !== null); + test.equal(info.getFirstDayOfWeek(), 1); test.equal(info.getWeekEndStart(), 6); test.equal(info.getWeekEndEnd(), 0); diff --git a/js/test/date/testMeridiems.js b/js/test/date/testMeridiems.js index 44fb518658..547cb3b8f8 100644 --- a/js/test/date/testMeridiems.js +++ b/js/test/date/testMeridiems.js @@ -1972,6 +1972,26 @@ module.exports.testmeridiems = { test.equal(fmt[0].name, "AM"); test.equal(fmt[1].name, "PM"); + test.done(); + }, + testMeridiem_ca_AD: function(test) { + test.expect(3); + var fmt = DateFmt.getMeridiemsRange({locale:"ca-AD"}); + test.ok(fmt !== null); + + test.equal(fmt[0].name, "a. m."); + test.equal(fmt[1].name, "p. m."); + + test.done(); + }, + testMeridiem_ca_ES: function(test) { + test.expect(3); + var fmt = DateFmt.getMeridiemsRange({locale:"ca-ES"}); + test.ok(fmt !== null); + + test.equal(fmt[0].name, "a. m."); + test.equal(fmt[1].name, "p. m."); + test.done(); } } \ No newline at end of file diff --git a/js/test/date/testMonthTranslation.js b/js/test/date/testMonthTranslation.js index d468675dc9..6013ed0aad 100644 --- a/js/test/date/testMonthTranslation.js +++ b/js/test/date/testMonthTranslation.js @@ -7315,6 +7315,96 @@ module.exports.testmonthtranslation = { test.equal(value[10], "ნოე"); test.equal(value[11], "დეკ"); + test.done(); + }, + testMonthTranslate_ca_AD: function(test) { + test.expect(24); + + // full, long: MMMM + // medium: MMM + // short: M + + var value = [], i; + var fmt = new DateFmt({locale:"ca-AD", date:"m", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + test.equal(value[0], "gener"); + test.equal(value[1], "febrer"); + test.equal(value[2], "març"); + test.equal(value[3], "abril"); + test.equal(value[4], "maig"); + test.equal(value[5], "juny"); + test.equal(value[6], "juliol"); + test.equal(value[7], "agost"); + test.equal(value[8], "setembre"); + test.equal(value[9], "octubre"); + test.equal(value[10], "novembre"); + test.equal(value[11], "desembre"); + + var fmt = new DateFmt({locale:"ca-AD", date:"m", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + + test.equal(value[0], "gen."); + test.equal(value[1], "febr."); + test.equal(value[2], "març"); + test.equal(value[3], "abr."); + test.equal(value[4], "maig"); + test.equal(value[5], "juny"); + test.equal(value[6], "jul."); + test.equal(value[7], "ag."); + test.equal(value[8], "set."); + test.equal(value[9], "oct."); + test.equal(value[10], "nov."); + test.equal(value[11], "des."); + + test.done(); + }, + testMonthTranslate_ca_ES: function(test) { + test.expect(24); + + // full, long: MMMM + // medium: MMM + // short: M + + var value = [], i; + var fmt = new DateFmt({locale:"ca-ES", date:"m", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + test.equal(value[0], "gener"); + test.equal(value[1], "febrer"); + test.equal(value[2], "març"); + test.equal(value[3], "abril"); + test.equal(value[4], "maig"); + test.equal(value[5], "juny"); + test.equal(value[6], "juliol"); + test.equal(value[7], "agost"); + test.equal(value[8], "setembre"); + test.equal(value[9], "octubre"); + test.equal(value[10], "novembre"); + test.equal(value[11], "desembre"); + + var fmt = new DateFmt({locale:"ca-AD", date:"m", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + + test.equal(value[0], "gen."); + test.equal(value[1], "febr."); + test.equal(value[2], "març"); + test.equal(value[3], "abr."); + test.equal(value[4], "maig"); + test.equal(value[5], "juny"); + test.equal(value[6], "jul."); + test.equal(value[7], "ag."); + test.equal(value[8], "set."); + test.equal(value[9], "oct."); + test.equal(value[10], "nov."); + test.equal(value[11], "des."); + test.done(); } } diff --git a/js/test/date/testSuite.html b/js/test/date/testSuite.html index 98d7e4a687..5e4c33a134 100644 --- a/js/test/date/testSuite.html +++ b/js/test/date/testSuite.html @@ -1,7 +1,7 @@ diff --git a/js/data/locale/ky/dateformats.json b/js/data/locale/ky/dateformats.json index 662df71b23..7999d42c94 100644 --- a/js/data/locale/ky/dateformats.json +++ b/js/data/locale/ky/dateformats.json @@ -3,40 +3,40 @@ "order": "{date} {time}", "date": { "dmwy": { - "f": "‏yyyy-'ж'., d-MMMM, EEEE", - "l": "‏yyyy-'ж'., d-MMMM, EEE", - "m": "‏yyyy-'ж'., d-MMM, EE", - "s": "‏d/M/yy, E" + "f": "yyyy-'ж'., d-MMMM, EEEE", + "l": "yyyy-'ж'., d-MMMM, EEE", + "m": "yyyy-'ж'., d-MMM, EE", + "s": "d/M/yy, E" }, "dmy": { - "f": "‏yyyy-'ж'., d-MMMM", - "l": "‏yyyy-'ж'., d-MMMM", - "m": "‏yyyy-'ж'., d-MMM", - "s": "‏d/M/yy" + "f": "yyyy-'ж'., d-MMMM", + "l": "yyyy-'ж'., d-MMMM", + "m": "yyyy-'ж'., d-MMM", + "s": "d/M/yy" }, "dmw": { - "f": "‏d-MMMM, EEEE", - "l": "‏d-MMMM, EEE", - "m": "‏d-MMM, EE", - "s": "‏d/M, E" + "f": "d-MMMM, EEEE", + "l": "d-MMMM, EEE", + "m": "d-MMM, EE", + "s": "d/M, E" }, "dm": { - "f": "‏d-MMMM", - "l": "‏d-MMMM", - "m": "‏d-MMM", - "s": "‏d/M" + "f": "d-MMMM", + "l": "d-MMMM", + "m": "d-MMM", + "s": "d/M" }, "my": { - "f": "‏yyyy-'ж'., LLLL", - "l": "‏yyyy-'ж'., LLLL", - "m": "‏yyyy-'ж'., LLL", - "s": "‏M/yy" + "f": "yyyy-'ж'., LLLL", + "l": "yyyy-'ж'., LLLL", + "m": "yyyy-'ж'., LLL", + "s": "M/yy" }, "dw": { - "f": "‏d-EEEE", - "l": "‏d-EEE", - "m": "‏d-EE", - "s": "‏d/E" + "f": "d-EEEE", + "l": "d-EEE", + "m": "d-EE", + "s": "d/E" }, "w": { "f": "EEEE", @@ -80,87 +80,87 @@ "h": "h", "m": "mm", "s": "ss", - "ah": "‏h a", - "hm": "‏h:mm", + "ah": "h a", + "hm": "h:mm", "ms": "mm:ss", - "ahm": "‏h:mm a", - "hms": "‏h:mm:ss", - "hmz": "‏h:mm z", - "ahmz": "‏h:mm a z", - "ahms": "‏h:mm:ss a", - "hmsz": "‏h:mm:ss z", - "ahmsz": "‏h:mm:ss a z" + "ahm": "h:mm a", + "hms": "h:mm:ss", + "hmz": "h:mm z", + "ahmz": "h:mm a z", + "ahms": "h:mm:ss a", + "hmsz": "h:mm:ss z", + "ahmsz": "h:mm:ss a z" }, "24": { "h": "HH", "m": "mm", "s": "ss", - "ah": "‏HH", - "hm": "‏HH:mm", + "ah": "HH", + "hm": "HH:mm", "ms": "mm:ss", - "ahm": "‏HH:mm", - "hms": "‏HH:mm:ss", - "hmz": "‏HH:mm z", - "ahmz": "‏HH:mm z", - "ahms": "‏HH:mm:ss", - "hmsz": "‏HH:mm:ss z", - "ahmsz": "‏HH:mm:ss z" + "ahm": "HH:mm", + "hms": "HH:mm:ss", + "hmz": "HH:mm z", + "ahmz": "HH:mm z", + "ahms": "HH:mm:ss", + "hmsz": "HH:mm:ss z", + "ahmsz": "HH:mm:ss z" } }, "range": { "c00": { - "f": "‏{sy}-ж., {sd}-{sm} {st} – {et}", - "l": "‏{sy}-ж., {sd}-{sm} {st} – {et}", - "m": "‏{sy}-ж., {sd}-{sm} {st} – {et}", - "s": "‏{sd}/{sm}/{sy} {st} – {et}" + "f": "{sy}-ж., {sd}-{sm} {st} – {et}", + "l": "{sy}-ж., {sd}-{sm} {st} – {et}", + "m": "{sy}-ж., {sd}-{sm} {st} – {et}", + "s": "{sd}/{sm}/{sy} {st} – {et}" }, "c01": { - "f": "‏{sy}-ж., {sd}-{sm} {st} – ‏{ey}-ж., {ed}-{em} {et}", - "l": "‏{sy}-ж., {sd}-{sm} {st} – ‏{ey}-ж., {ed}-{em} {et}", - "m": "‏{sy}-ж., {sd}-{sm} {st} – ‏{ey}-ж., {ed}-{em} {et}", - "s": "‏{sd}/{sm}/{sy} {st} – ‏{ed}/{em}/{ey} {et}" + "f": "{sy}-ж., {sd}-{sm} {st} – {ey}-ж., {ed}-{em} {et}", + "l": "{sy}-ж., {sd}-{sm} {st} – {ey}-ж., {ed}-{em} {et}", + "m": "{sy}-ж., {sd}-{sm} {st} – {ey}-ж., {ed}-{em} {et}", + "s": "{sd}/{sm}/{sy} {st} – {ed}/{em}/{ey} {et}" }, "c02": { - "f": "‏{sy}-ж., {sd}-{sm} {st} – ‏{ey}-ж., {ed}-{em} {et}", - "l": "‏{sy}-ж., {sd}-{sm} {st} – ‏{ey}-ж., {ed}-{em} {et}", - "m": "‏{sy}-ж., {sd}-{sm} {st} – ‏{ey}-ж., {ed}-{em} {et}", - "s": "‏{sd}/{sm}/{sy} {st} – ‏{ed}/{em}/{ey} {et}" + "f": "{sy}-ж., {sd}-{sm} {st} – {ey}-ж., {ed}-{em} {et}", + "l": "{sy}-ж., {sd}-{sm} {st} – {ey}-ж., {ed}-{em} {et}", + "m": "{sy}-ж., {sd}-{sm} {st} – {ey}-ж., {ed}-{em} {et}", + "s": "{sd}/{sm}/{sy} {st} – {ed}/{em}/{ey} {et}" }, "c03": { - "f": "‏{sy}-ж., {sd}-{sm} {st} – ‏{ey}-ж., {ed}-{em} {et}", - "l": "‏{sy}-ж., {sd}-{sm} {st} – ‏{ey}-ж., {ed}-{em} {et}", - "m": "‏{sy}-ж., {sd}-{sm} {st} – ‏{ey}-ж., {ed}-{em} {et}", - "s": "‏{sd}/{sm}/{sy} {st} – ‏{ed}/{em}/{ey} {et}" + "f": "{sy}-ж., {sd}-{sm} {st} – {ey}-ж., {ed}-{em} {et}", + "l": "{sy}-ж., {sd}-{sm} {st} – {ey}-ж., {ed}-{em} {et}", + "m": "{sy}-ж., {sd}-{sm} {st} – {ey}-ж., {ed}-{em} {et}", + "s": "{sd}/{sm}/{sy} {st} – {ed}/{em}/{ey} {et}" }, "c10": { - "f": "‏{sy}-ж., {sd}-{sm} – ‏{ed}-{em}", - "l": "‏{sy}-ж., {sd}-{sm} – ‏{ed}-{em}", - "m": "‏{sy}-ж., {sd}-{sm} – ‏{ed}-{em}", - "s": "‏{sd} – ‏{ed}/{em}/{ey}" + "f": "{sy}-ж., {sd}-{sm} – {ed}-{em}", + "l": "{sy}-ж., {sd}-{sm} – {ed}-{em}", + "m": "{sy}-ж., {sd}-{sm} – {ed}-{em}", + "s": "{sd} – {ed}/{em}/{ey}" }, "c11": { - "f": "‏{sy}-ж., {sd}-{sm} – ‏{ey}-ж., {ed}-{em}", - "l": "‏{sy}-ж., {sd}-{sm} – ‏{ey}-ж., {ed}-{em}", - "m": "‏{sy}-ж., {sd}-{sm} – ‏{ey}-ж., {ed}-{em}", - "s": "‏{sd}/{sm} – ‏{ed}/{em}/{ey}" + "f": "{sy}-ж., {sd}-{sm} – {ey}-ж., {ed}-{em}", + "l": "{sy}-ж., {sd}-{sm} – {ey}-ж., {ed}-{em}", + "m": "{sy}-ж., {sd}-{sm} – {ey}-ж., {ed}-{em}", + "s": "{sd}/{sm} – {ed}/{em}/{ey}" }, "c12": { - "f": "‏{sy}-ж., {sd}-{sm} – ‏{ey}-ж., {ed}-{em}", - "l": "‏{sy}-ж., {sd}-{sm} – ‏{ey}-ж., {ed}-{em}", - "m": "‏{sy}-ж., {sd}-{sm} – ‏{ey}-ж., {ed}-{em}", - "s": "‏{sd}/{sm}/{sy} – ‏{ed}/{em}/{ey}" + "f": "{sy}-ж., {sd}-{sm} – {ey}-ж., {ed}-{em}", + "l": "{sy}-ж., {sd}-{sm} – {ey}-ж., {ed}-{em}", + "m": "{sy}-ж., {sd}-{sm} – {ey}-ж., {ed}-{em}", + "s": "{sd}/{sm}/{sy} – {ed}/{em}/{ey}" }, "c20": { - "f": "‏{sy}-ж., {sm} – ‏{ey}-ж., {em}", - "l": "‏{sy}-ж., {sm} – ‏{ey}-ж., {em}", - "m": "‏{sy}-ж., {sm} – ‏{ey}-ж., {em}", - "s": "‏{sm}/{sy} – ‏{em}/{ey}" + "f": "{sy}-ж., {sm} – {ey}-ж., {em}", + "l": "{sy}-ж., {sm} – {ey}-ж., {em}", + "m": "{sy}-ж., {sm} – {ey}-ж., {em}", + "s": "{sm}/{sy} – {em}/{ey}" }, "c30": { - "f": "‏{sy} – {ey}", - "l": "‏{sy} – {ey}", - "m": "‏{sy} – {ey}", - "s": "‏{sy} – {ey}" + "f": "{sy} – {ey}", + "l": "{sy} – {ey}", + "m": "{sy} – {ey}", + "s": "{sy} – {ey}" } } } diff --git a/js/data/locale/ky/scripts.jf b/js/data/locale/ky/scripts.jf index e7638ec9e0..9a7500e3e6 100644 --- a/js/data/locale/ky/scripts.jf +++ b/js/data/locale/ky/scripts.jf @@ -1,7 +1,7 @@ { "scripts": [ - "Arab", "Cyrl", + "Arab", "Latn" ], "generated": true diff --git a/js/data/locale/ky/sysres.json b/js/data/locale/ky/sysres.json index 4430e14c1f..11dc15ec70 100644 --- a/js/data/locale/ky/sysres.json +++ b/js/data/locale/ky/sysres.json @@ -187,48 +187,48 @@ "#{num}w": "one#{num} ап|#{num} ап", "durationShortMonths": "one#{num} ай|#{num} ай", "#{num}y": "one#{num} ж.|#{num} ж.", - "1#in 1 second|#in {num} seconds": "one#‏{num} секунддан кийин|#‏{num} секунддан кийин", - "1#in 1 minute|#in {num} minutes": "one#‏{num} мүнөттөн кийин|#‏{num} мүнөттөн кийин", - "1#in 1 hour|#in {num} hours": "one#‏{num} сааттан кийин|#‏{num} сааттан кийин", - "1#in 1 day|#in {num} days": "one#‏{num} күндөн кийин|#‏{num} күндөн кийин", - "1#in 1 week|#in {num} weeks": "one#‏{num} аптадан кийин|#‏{num} аптадан кийин", - "1#in 1 month|#in {num} months": "one#‏{num} айдан кийин|#‏{num} айдан кийин", - "1#in 1 year|#in {num} years": "one#‏{num} жылдан кийин|#‏{num} жылдан кийин", - "1#in 1 sec|#in {num} sec": "one#‏{num} секунддан кийин|#‏{num} секунддан кийин", - "1#in 1 min|#in {num} min": "one#‏{num} мүнөттөн кийин|#‏{num} мүнөттөн кийин", - "1#in 1 hr|#in {num} hrs": "one#‏{num} сааттан кийин|#‏{num} сааттан кийин", - "1#in 1 dy|#in {num} dys": "one#‏{num} күндөн кийин|#‏{num} күндөн кийин", - "1#in 1 wk|#in {num} wks": "one#‏{num} аптадан кийин|#‏{num} аптадан кийин", - "1#in 1 mon|#in {num} mons": "one#‏{num} айдан кийин|#‏{num} айдан кийин", - "1#in 1 yr|#in {num} yrs": "one#‏{num} жылдан кийин|#‏{num} жылдан кийин", - "#in {num}s": "one#‏{num} сек. кийин|#‏{num} сек. кийин", - "#in {num}mi": "one#‏{num} мүн. кийин|#‏{num} мүн. кийин", - "#in {num}h": "one#‏{num} саат. кийин|#‏{num} саат. кийин", - "#in {num}d": "one#‏{num} күн. кийин|#‏{num} күн. кийин", - "#in {num}w": "one#‏{num} апт. кийин|#‏{num} апт. кийин", - "#in {num}mo": "one#‏{num} айд. кийин|#‏{num} айд. кийин", - "#in {num}y": "one#‏{num} жыл. кийин|#‏{num} жыл. кийин", - "1#1 second ago|#{num} seconds ago": "one#‏{num} секунд мурун|#‏{num} секунд мурун", - "1#1 minute ago|#{num} minutes ago": "one#‏{num} мүнөт мурун|#‏{num} мүнөт мурун", - "1#1 hour ago|#{num} hours ago": "one#‏{num} саат мурун|#‏{num} саат мурун", - "1#1 day ago|#{num} days ago": "one#‏{num} күн мурун|#‏{num} күн мурун", - "1#1 week ago|#{num} weeks ago": "one#‏{num} апта мурун|#‏{num} апта мурун", - "1#1 month ago|#{num} months ago": "one#‏{num} ай мурун|#‏{num} ай мурун", - "1#1 year ago|#{num} years ago": "one#‏{num} жыл мурун|#‏{num} жыл мурун", - "1#1 sec ago|#{num} sec ago": "one#‏{num} секунд мурун|#‏{num} секунд мурун", - "1#1 min ago|#{num} min ago": "one#‏{num} мүнөт мурун|#‏{num} мүнөт мурун", - "1#1 hr ago|#{num} hrs ago": "one#‏{num} саат мурун|#‏{num} саат мурун", - "1#1 dy ago|#{num} dys ago": "one#‏{num} күн мурун|#‏{num} күн мурун", - "1#1 wk ago|#{num} wks ago": "one#‏{num} апта мурун|#‏{num} апта мурун", - "1#1 mon ago|#{num} mons ago": "one#‏{num} ай мурун|#‏{num} ай мурун", - "1#1 yr ago|#{num} yrs ago": "one#‏{num} жыл мурун|#‏{num} жыл мурун", - "#{num}s ago": "one#‏{num} сек. мурун|#‏{num} сек. мурун", - "#{num}mi ago": "one#‏{num} мүн. мурун|#‏{num} мүн. мурун", - "#{num}h ago": "one#‏{num} саат. мурун|#‏{num} саат. мурун", - "#{num}d ago": "one#‏{num} күн мурун|#‏{num} күн мурун", - "#{num}w ago": "one#‏{num} апт. мурун|#‏{num} апт. мурун", - "#{num}mo ago": "one#‏{num} ай мурун|#‏{num} ай мурун", - "#{num}y ago": "one#‏{num} жыл мурун|#‏{num} жыл мурун", + "1#in 1 second|#in {num} seconds": "one#{num} секунддан кийин|#{num} секунддан кийин", + "1#in 1 minute|#in {num} minutes": "one#{num} мүнөттөн кийин|#{num} мүнөттөн кийин", + "1#in 1 hour|#in {num} hours": "one#{num} сааттан кийин|#{num} сааттан кийин", + "1#in 1 day|#in {num} days": "one#{num} күндөн кийин|#{num} күндөн кийин", + "1#in 1 week|#in {num} weeks": "one#{num} аптадан кийин|#{num} аптадан кийин", + "1#in 1 month|#in {num} months": "one#{num} айдан кийин|#{num} айдан кийин", + "1#in 1 year|#in {num} years": "one#{num} жылдан кийин|#{num} жылдан кийин", + "1#in 1 sec|#in {num} sec": "one#{num} секунддан кийин|#{num} секунддан кийин", + "1#in 1 min|#in {num} min": "one#{num} мүнөттөн кийин|#{num} мүнөттөн кийин", + "1#in 1 hr|#in {num} hrs": "one#{num} сааттан кийин|#{num} сааттан кийин", + "1#in 1 dy|#in {num} dys": "one#{num} күндөн кийин|#{num} күндөн кийин", + "1#in 1 wk|#in {num} wks": "one#{num} аптадан кийин|#{num} аптадан кийин", + "1#in 1 mon|#in {num} mons": "one#{num} айдан кийин|#{num} айдан кийин", + "1#in 1 yr|#in {num} yrs": "one#{num} жылдан кийин|#{num} жылдан кийин", + "#in {num}s": "one#{num} сек. кийин|#{num} сек. кийин", + "#in {num}mi": "one#{num} мүн. кийин|#{num} мүн. кийин", + "#in {num}h": "one#{num} саат. кийин|#{num} саат. кийин", + "#in {num}d": "one#{num} күн. кийин|#{num} күн. кийин", + "#in {num}w": "one#{num} апт. кийин|#{num} апт. кийин", + "#in {num}mo": "one#{num} айд. кийин|#{num} айд. кийин", + "#in {num}y": "one#{num} жыл. кийин|#{num} жыл. кийин", + "1#1 second ago|#{num} seconds ago": "one#{num} секунд мурун|#{num} секунд мурун", + "1#1 minute ago|#{num} minutes ago": "one#{num} мүнөт мурун|#{num} мүнөт мурун", + "1#1 hour ago|#{num} hours ago": "one#{num} саат мурун|#{num} саат мурун", + "1#1 day ago|#{num} days ago": "one#{num} күн мурун|#{num} күн мурун", + "1#1 week ago|#{num} weeks ago": "one#{num} апта мурун|#{num} апта мурун", + "1#1 month ago|#{num} months ago": "one#{num} ай мурун|#{num} ай мурун", + "1#1 year ago|#{num} years ago": "one#{num} жыл мурун|#{num} жыл мурун", + "1#1 sec ago|#{num} sec ago": "one#{num} секунд мурун|#{num} секунд мурун", + "1#1 min ago|#{num} min ago": "one#{num} мүнөт мурун|#{num} мүнөт мурун", + "1#1 hr ago|#{num} hrs ago": "one#{num} саат мурун|#{num} саат мурун", + "1#1 dy ago|#{num} dys ago": "one#{num} күн мурун|#{num} күн мурун", + "1#1 wk ago|#{num} wks ago": "one#{num} апта мурун|#{num} апта мурун", + "1#1 mon ago|#{num} mons ago": "one#{num} ай мурун|#{num} ай мурун", + "1#1 yr ago|#{num} yrs ago": "one#{num} жыл мурун|#{num} жыл мурун", + "#{num}s ago": "one#{num} сек. мурун|#{num} сек. мурун", + "#{num}mi ago": "one#{num} мүн. мурун|#{num} мүн. мурун", + "#{num}h ago": "one#{num} саат. мурун|#{num} саат. мурун", + "#{num}d ago": "one#{num} күн мурун|#{num} күн мурун", + "#{num}w ago": "one#{num} апт. мурун|#{num} апт. мурун", + "#{num}mo ago": "one#{num} ай мурун|#{num} ай мурун", + "#{num}y ago": "one#{num} жыл мурун|#{num} жыл мурун", "separatorFull": ", ", "finalSeparatorFull": ", ", "separatorLong": ", ", diff --git a/js/test/date/testDayOfWeek.js b/js/test/date/testDayOfWeek.js index 0aa7c5b75a..8eeb982883 100644 --- a/js/test/date/testDayOfWeek.js +++ b/js/test/date/testDayOfWeek.js @@ -1964,6 +1964,16 @@ module.exports.testweekdata = { var info = new LocaleInfo("ka-GE"); test.ok(info !== null); + test.equal(info.getFirstDayOfWeek(), 1); + test.equal(info.getWeekEndStart(), 6); + test.equal(info.getWeekEndEnd(), 0); + test.done(); + }, + testWeekData_ky_KG: function(test) { + test.expect(4); + var info = new LocaleInfo("ky-KG"); + test.ok(info !== null); + test.equal(info.getFirstDayOfWeek(), 1); test.equal(info.getWeekEndStart(), 6); test.equal(info.getWeekEndEnd(), 0); diff --git a/js/test/date/testMeridiems.js b/js/test/date/testMeridiems.js index 44fb518658..56bd56e330 100644 --- a/js/test/date/testMeridiems.js +++ b/js/test/date/testMeridiems.js @@ -1972,6 +1972,16 @@ module.exports.testmeridiems = { test.equal(fmt[0].name, "AM"); test.equal(fmt[1].name, "PM"); + test.done(); + }, + testMeridiem_ky_KG: function(test) { + test.expect(3); + var fmt = DateFmt.getMeridiemsRange({locale:"ky-KG"}); + test.ok(fmt !== null); + + test.equal(fmt[0].name, "таңкы"); + test.equal(fmt[1].name, "түштөн кийинки"); + test.done(); } } \ No newline at end of file diff --git a/js/test/date/testMonthTranslation.js b/js/test/date/testMonthTranslation.js index d468675dc9..0ca719a3fc 100644 --- a/js/test/date/testMonthTranslation.js +++ b/js/test/date/testMonthTranslation.js @@ -7315,6 +7315,51 @@ module.exports.testmonthtranslation = { test.equal(value[10], "ნოე"); test.equal(value[11], "დეკ"); + test.done(); + }, + testMonthTranslate_ky_KG: function(test) { + test.expect(24); + + // full, long: MMMM + // medium: MMM + // short: M + + var value = [], i; + var fmt = new DateFmt({locale:"ky-KG", date:"m", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + test.equal(value[0], "Январь"); + test.equal(value[1], "Февраль"); + test.equal(value[2], "Март"); + test.equal(value[3], "Апрель"); + test.equal(value[4], "Май"); + test.equal(value[5], "Июнь"); + test.equal(value[6], "Июль"); + test.equal(value[7], "Август"); + test.equal(value[8], "Сентябрь"); + test.equal(value[9], "Октябрь"); + test.equal(value[10], "Ноябрь"); + test.equal(value[11], "Декабрь"); + + var fmt = new DateFmt({locale:"ky-KG", date:"m", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + + test.equal(value[0], "Янв"); + test.equal(value[1], "Фев"); + test.equal(value[2], "Мар"); + test.equal(value[3], "Апр"); + test.equal(value[4], "Май"); + test.equal(value[5], "Июн"); + test.equal(value[6], "Июл"); + test.equal(value[7], "Авг"); + test.equal(value[8], "Сен"); + test.equal(value[9], "Окт"); + test.equal(value[10], "Ноя"); + test.equal(value[11], "Дек"); + test.done(); } } diff --git a/js/test/date/testSuite.html b/js/test/date/testSuite.html index 98d7e4a687..9418bbda2d 100644 --- a/js/test/date/testSuite.html +++ b/js/test/date/testSuite.html @@ -1,7 +1,7 @@ diff --git a/js/test/date/testDayOfWeek.js b/js/test/date/testDayOfWeek.js index 0aa7c5b75a..3430bc9f87 100644 --- a/js/test/date/testDayOfWeek.js +++ b/js/test/date/testDayOfWeek.js @@ -1968,5 +1968,15 @@ module.exports.testweekdata = { test.equal(info.getWeekEndStart(), 6); test.equal(info.getWeekEndEnd(), 0); test.done(); + }, + testWeekData_lo_LA: function(test) { + test.expect(4); + var info = new LocaleInfo("lo-LA"); + test.ok(info !== null); + + test.equal(info.getFirstDayOfWeek(), 0); + test.equal(info.getWeekEndStart(), 6); + test.equal(info.getWeekEndEnd(), 0); + test.done(); } } diff --git a/js/test/date/testMeridiems.js b/js/test/date/testMeridiems.js index 44fb518658..4ed3e19aa3 100644 --- a/js/test/date/testMeridiems.js +++ b/js/test/date/testMeridiems.js @@ -1972,6 +1972,16 @@ module.exports.testmeridiems = { test.equal(fmt[0].name, "AM"); test.equal(fmt[1].name, "PM"); + test.done(); + }, + testMeridiem_lo_LA: function(test) { + test.expect(3); + var fmt = DateFmt.getMeridiemsRange({locale:"lo-LA"}); + test.ok(fmt !== null); + + test.equal(fmt[0].name, "ກ່ອນທ່ຽງ"); + test.equal(fmt[1].name, "ຫຼັງທ່ຽງ"); + test.done(); } } \ No newline at end of file diff --git a/js/test/date/testMonthTranslation.js b/js/test/date/testMonthTranslation.js index d468675dc9..55304fbdb8 100644 --- a/js/test/date/testMonthTranslation.js +++ b/js/test/date/testMonthTranslation.js @@ -7315,6 +7315,51 @@ module.exports.testmonthtranslation = { test.equal(value[10], "ნოე"); test.equal(value[11], "დეკ"); + test.done(); + }, + testMonthTranslate_lo_LA: function(test) { + test.expect(24); + + // full, long: MMMM + // medium: MMM + // short: MM + + var value = [], i; + var fmt = new DateFmt({locale:"lo-LA", date:"m", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + test.equal(value[0], "ມັງກອນ"); + test.equal(value[1], "ກຸມພາ"); + test.equal(value[2], "ມີນາ"); + test.equal(value[3], "ເມສາ"); + test.equal(value[4], "ພຶດສະພາ"); + test.equal(value[5], "ມິຖຸນາ"); + test.equal(value[6], "ກໍລະກົດ"); + test.equal(value[7], "ສິງຫາ"); + test.equal(value[8], "ກັນຍາ"); + test.equal(value[9], "ຕຸລາ"); + test.equal(value[10], "ພະຈິກ"); + test.equal(value[11], "ທັນວາ"); + + var fmt = new DateFmt({locale:"lo-LA", date:"m", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + + test.equal(value[0], "ມ.ກ."); + test.equal(value[1], "ກ.ພ."); + test.equal(value[2], "ມ.ນ."); + test.equal(value[3], "ມ.ສ."); + test.equal(value[4], "ພ.ພ."); + test.equal(value[5], "ມິ.ຖ."); + test.equal(value[6], "ກ.ລ."); + test.equal(value[7], "ສ.ຫ."); + test.equal(value[8], "ກ.ຍ."); + test.equal(value[9], "ຕ.ລ."); + test.equal(value[10], "ພ.ຈ."); + test.equal(value[11], "ທ.ວ."); + test.done(); } } diff --git a/js/test/date/testSuite.html b/js/test/date/testSuite.html index 98d7e4a687..f76d137f83 100644 --- a/js/test/date/testSuite.html +++ b/js/test/date/testSuite.html @@ -1,7 +1,7 @@ diff --git a/js/test/date/testSuite.html b/js/test/date/testSuite.html index 00c43149e6..7fa9c3d4c8 100644 --- a/js/test/date/testSuite.html +++ b/js/test/date/testSuite.html @@ -1,7 +1,7 @@ + diff --git a/js/test/date/testSuiteFiles.js b/js/test/date/testSuiteFiles.js index 4e79853723..6fc6f4e9b9 100644 --- a/js/test/date/testSuiteFiles.js +++ b/js/test/date/testSuiteFiles.js @@ -79,6 +79,7 @@ module.exports.files = [ "testdatefmt_mn_Cyrl_MN.js", "testdatefmt_mr_IN.js", "testdatefmt_ms_MY.js", + "testdatefmt_my_MM.js", "testdatefmt_nb_NO.js", "testdatefmt_nl_NL.js", "testdatefmt_or_IN.js", diff --git a/js/test/date/testdatefmt_my_MM.js b/js/test/date/testdatefmt_my_MM.js new file mode 100644 index 0000000000..e0ef01302b --- /dev/null +++ b/js/test/date/testdatefmt_my_MM.js @@ -0,0 +1,1802 @@ +/* + * testdatefmt_my_MM.js - test the date formatter object in Basque/Spain + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(JulianDate) === "undefined") { + var JulianDate = require("../../lib/JulianDate.js"); +} +if (typeof(GregorianDate) === "undefined") { + var GregorianDate = require("../../lib/GregorianDate.js"); +} +if (typeof(DateFmt) === "undefined") { + var DateFmt = require("../../lib/DateFmt.js"); +} +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testdatefmt_my_MM = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + + testDateFmtConstructorEmpty_my_MM: function(test) { + test.expect(1); + var fmt = new DateFmt({locale: "my-MM"}); + + test.ok(fmt !== null); + test.done(); + }, + + testDateFmtSimpleShort_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "short", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29-09-11'); + test.done(); + }, + + testDateFmtSimpleMedium_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "medium", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011၊ စက် 29'); + test.done(); + }, + + testDateFmtSimpleLong_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "long", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date),'2011၊ 29 စက်တင်ဘာ'); + test.done(); + }, + + testDateFmtSimpleFull_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011၊ စက်တင်ဘာ 29'); + test.done(); + }, + + testDateFmtSimpleTimeShort_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "short", type: "time", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'B 13:45'); + test.done(); + }, + + testDateFmtSimpleTimeMedium_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "medium", type: "time", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'B 13:45'); + test.done(); + }, + + testDateFmtSimpleTimeLong_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", timelength: "long", type: "time", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'B 13:45'); + test.done(); + }, + + testDateFmtSimpleTimeFull_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full", type: "time", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 1, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'B 1:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleShort_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "short", type: "datetime", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29-09-11 B 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleMedium_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "medium", type: "datetime", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011၊ စက် 29 B 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleLong_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "long", type: "datetime", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011၊ 29 စက်တင်ဘာ B 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleFull_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full", type: "datetime", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011၊ စက်တင်ဘာ 29 B 13:45'); + test.done(); + }, + + testDateFmtTemplateCalendar_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", calendar: "julian", template: "yyyy-MM-dd", useNative: false}); + test.ok(fmt !== null); + + var date = new JulianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011-09-29"); + test.done(); + }, + + testDateFmtTemplateCalendarIncompatibleDateType_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", calendar: "julian", template: "yyyy-MM-dd HH:mm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + // convert automatically to a Julian calendar date + test.equal(fmt.format(date), "2011-09-16 13:45"); + test.done(); + }, + + testDateFmtTemplateClock12SwitchHH_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", clock: "12", template: "HH:mm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateClock12Switchkk_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", clock: "12", template: "kk:mm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateClock24Switchhh_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", clock: "24", template: "hh:mm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateClock24SwitchKK: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", clock: "24", template: "KK:mm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault12hh_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", template: "hh:mm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault12KK: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", template: "KK:mm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault24HH_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", template: "HH:mm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault24kk_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", template: "kk:mm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + + testDateFmtTypeDate_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "date", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29-09-11'); + test.done(); + }, + + testDateFmtTypeTime_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'B 13:45'); + test.done(); + }, + + testDateFmtTypeDateTime_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "datetime", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29-09-11 B 13:45'); + test.done(); + }, + + testDateFmtShortDateComponentsY_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", date: "y", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "11"); + test.done(); + }, + + testDateFmtShortDateComponentsM_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", date: "m", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '09'); + test.done(); + }, + + testDateFmtShortDateComponentsN_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", date: "n", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'စ'); + test.done(); + }, + + testDateFmtShortDateComponentsD_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", date: "d", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29"); + test.done(); + }, + + testDateFmtShortDateComponentsDM_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", date: "dm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29-09'); + test.done(); + }, + + testDateFmtShortDateComponentsMY_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", date: "my", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '09-11'); + test.done(); + }, + + testDateFmtShortDateComponentsDMY_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", date: "dmy", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29-09-11'); + test.done(); + }, + + testDateFmtShortDateComponentsWDM_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", date: "wdm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29-09၊ က'); + test.done(); + }, + + testDateFmtShortDateComponentsWDMY_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", date: "wdmy", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29-09-11၊ က'); + test.done(); + }, + + testDateFmtLongDateComponentsWDM_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", date: "wdm", length: "long", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 စက်တင်ဘာ၊ ကြာသပတေး'); + test.done(); + }, + + testDateFmtFullDateComponentsY_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full", date: "y", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011"); + test.done(); + }, + + testDateFmtFullDateComponentsM_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full", date: "m", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'စက်တင်ဘာ'); + test.done(); + }, + + testDateFmtFullDateComponentsD_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full", date: "d", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29"); + test.done(); + }, + + testDateFmtFullDateComponentsDM_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full", date: "dm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'စက်တင်ဘာ 29'); + test.done(); + }, + + testDateFmtFullDateComponentsMY_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full", date: "my", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011၊ စက်တင်ဘာ'); + test.done(); + }, + + testDateFmtFullDateComponentsDMY_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full", date: "dmy", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011၊ စက်တင်ဘာ 29'); + test.done(); + }, + + testDateFmtFullDateComponentsWDM_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full", date: "wdm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'စက်တင်ဘာ 29၊ ကြာသပတေး'); + test.done(); + }, + + testDateFmtFullDateComponentsWDMY_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full", date: "wdmy", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '2011၊ စက်တင်ဘာ 29၊ ကြာသပတေး'); + test.done(); + }, + + testDateFmtShortTimeComponentsS_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", time: "s", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "37"); + test.done(); + }, + + testDateFmtShortTimeComponentsM_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", time: "m", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45"); + test.done(); + }, + + testDateFmtShortTimeComponentsH_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", time: "h", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13"); + test.done(); + }, + + testDateFmtShortTimeComponentsMS_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", time: "ms", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHM_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", time: "hm",useNative:false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "B 13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMS_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", time: "hms", useNative:false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "B 13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMA_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", time: "hma", useNative:false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "B 13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMZ_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "my-MM", + type: "time", + time: "hmz", + timezone: "Asia/Rangoon", + useNative: false + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "UTC B 13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMAZ_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "my-MM", + type: "time", + time: "hmaz", + timezone: "Asia/Rangoon", + useNative: false + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "UTC B 13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSA_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", time: "hmsa", useNative:false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "B 13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSZ_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "my-MM", + type: "time", + time: "hmsz", + timezone: "Asia/Rangoon", + useNative: false + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "UTC B 13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSAZ_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "my-MM", + type: "time", + time: "hmsaz", + timezone: "Asia/Rangoon", + useNative: false + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "UTC B 13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsS_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", length: "full", time: "s", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "37"); + test.done(); + }, + + testDateFmtFullTimeComponentsM_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", length: "full", time: "m", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45"); + test.done(); + }, + + testDateFmtFullTimeComponentsH_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", length: "full", time: "h", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13"); + test.done(); + }, + + testDateFmtFullTimeComponentsMS_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", length: "full", time: "ms",useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHM_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", length: "full", time: "hm", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "B 13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMS_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", length: "full", time: "hms", useNative:false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "B 13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMA_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "my-MM", + type: "time", + length: "full", + time: "hma", + useNative: false + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "B 13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMZ_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "my-MM", + type: "time", + length: "full", + time: "hmz", + timezone: "Asia/Rangoon", + useNative: false + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "UTC B 13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMAZ_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "my-MM", + type: "time", + length: "full", + time: "hmaz", + timezone: "Asia/Rangoon", + useNative: false + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "UTC B 13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSA_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", type: "time", length: "full", time: "hmsa", useNative: false}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "B 13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSZ_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "my-MM", + type: "time", + length: "full", + time: "hmsz", + timezone: "Asia/Rangoon", + useNative: false + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "UTC B 13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSAZ_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "my-MM", + type: "time", + length: "full", + time: "hmsaz", + timezone: "Asia/Rangoon", + useNative: false + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "UTC B 13:45:37"); + test.done(); + }, + + testDateFmtWithTimeZoneAndNoDST_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "my-MM", + type: "time", + length: "full", + time: "hmsz", + timezone: "Asia/Rangoon", + useNative: false + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 12, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "UTC B 13:45:37"); + test.done(); + }, + + testDateFmtFormatRelativeWithinMinuteAfter_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 30, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '30 စက္ကန့်အတွင်း'); + test.done(); + }, +testDateFmtFormatRelativeWithinMinuteBefore_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 44, + second: 30, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'ပြီးခဲ့သည့် 30 စက္ကန့်'); + test.done(); + }, +testDateFmtFormatRelativeWithinHourAfter_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '10 မိနစ်အတွင်း'); + test.done(); + }, +testDateFmtFormatRelativeWithinHourBefore_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'ပြီးခဲ့သည့် 10 မိနစ်'); + test.done(); + }, +testDateFmtFormatRelativeWithinDayAfter_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 17, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '4 နာရီအတွင်း'); + test.done(); + }, +testDateFmtFormatRelativeWithinDayBefore_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'ပြီးခဲ့သည့် 4 နာရီ'); + test.done(); + }, + + testDateFmtFormatRelativeWithinFortnightAfter_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '4 ရက်အတွင်း'); + test.done(); + }, +testDateFmtFormatRelativeWithinFortnightBefore_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 16, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'ပြီးခဲ့သည့် 4 ရက်'); + test.done(); + }, + + testDateFmtFormatRelativeWithinQuarterAfter_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 11, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '9 ပတ်အတွင်း'); + test.done(); + }, +testDateFmtFormatRelativeWithinQuarterBefore_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'ပြီးခဲ့သည့် 9 ပတ်'); + test.done(); + }, + + testDateFmtFormatRelativeWithinTwoYearsAfter_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2013, + month: 1, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '16 လအတွင်း'); + test.done(); + }, +testDateFmtFormatRelativeWithinTwoYearsBefore_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2010, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'ပြီးခဲ့သည့် 14 လ'); + test.done(); + }, + + testDateFmtFormatRelativeYearsAfter_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 2025, + month: 10, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '14 နှစ်အတွင်း'); + test.done(); + }, +testDateFmtFormatRelativeYearsBefore_my_MM: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "my-MM", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "my-MM", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "my-MM", + year: 1990, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'ပြီးခဲ့သည့် 21 နှစ်'); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/daterange/testSuite.html b/js/test/daterange/testSuite.html index 21f78f5323..e24e31d670 100644 --- a/js/test/daterange/testSuite.html +++ b/js/test/daterange/testSuite.html @@ -1,7 +1,7 @@ + @@ -126,4 +126,4 @@

date Test Suite

nodeunit.run(module.exports); - \ No newline at end of file + diff --git a/js/test/date/testdatefmt_my_MM.js b/js/test/date/testdatefmt_my_MM.js index e0ef01302b..d786de831d 100644 --- a/js/test/date/testdatefmt_my_MM.js +++ b/js/test/date/testdatefmt_my_MM.js @@ -1,5 +1,5 @@ /* - * testdatefmt_my_MM.js - test the date formatter object in Basque/Spain + * testdatefmt_my_MM.js - test the date formatter object in Burmese-Myanmar * * Copyright © 2020, JEDLSoft * From c15a45644e31b4c6af287220a36b848775784dbe Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Thu, 27 Aug 2020 12:47:19 +0900 Subject: [PATCH 40/48] Add testcase to test native digits --- js/test/number/testnumfmt.js | 93 +++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git a/js/test/number/testnumfmt.js b/js/test/number/testnumfmt.js index 6c46bcf969..05d127bbff 100644 --- a/js/test/number/testnumfmt.js +++ b/js/test/number/testnumfmt.js @@ -1,7 +1,7 @@ /* * testnumfmt.js - test the number formatter object * - * Copyright © 2012-2018 JEDLSoft + * Copyright © 2012-2018 2020 JEDLSoft * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -6870,5 +6870,96 @@ module.exports.testnumfmt = { test.equal(fmt.format(12345678900), "1.23E+10"); test.done(); + }, + + //test cases for my-MM + + testNumFmt_my_MM: function(test) { + test.expect(2); + var fmt = new NumFmt({ + locale: "my-MM", + maxFractionDigits: 2 + }); + test.ok(fmt); + test.equal(fmt.format(12340568.78), "၁၂,၃၄၀,၅၆၈.၇၈"); + test.done(); + }, + testNumFmtNative_my_MM: function(test) { + test.expect(2); + var fmt = new NumFmt({ + locale: "my-MM", + useNative: true, + maxFractionDigits: 2 + }); + test.ok(fmt); + test.equal(fmt.format(-123.57), "-၁၂၃.၅၇"); + test.done(); + }, + testNumFmtCurrencyFormatNativeCurrencyForLocale_my_MM1: function(test) { + test.expect(2); + var fmt = new NumFmt({ + type: "currency", + locale: "my-MM", + useNative: true, + currency: "MMK" + }); + test.ok(fmt); + test.equal(fmt.format(123.57), "၁၂၄ K"); + test.done(); + }, + testNumFmtCurrencyFormatNegativeNativeCurrencyForLocale_my_MM1: function(test) { + test.expect(2); + var fmt = new NumFmt({ + type: "currency", + locale: "my-MM", + useNative: true, + currency: "MMK" + }); + test.ok(fmt); + test.equal(fmt.format(-123.57), "-၁၂၄ K"); + test.done(); + }, + testNumFmtCurrencyFormatCorrectCurrencyForLocale_my_MM: function(test) { + test.expect(2); + var fmt = new NumFmt({ + type: "currency", + locale: "my-MM", + currency: "MMK" + }); + test.ok(fmt); + test.equal(fmt.format(123.57), "၁၂၄ K"); + test.done(); + }, + testNumFmtPercentageFormatRegular_my_MM: function(test) { + test.expect(2); + var fmt = new NumFmt({ + locale: "my-MM", + useNative: true, + type: "percentage" + }); + test.ok(fmt); + test.equal(fmt.format(57.8), "੫੭.੮%"); + test.done(); + }, + testNumFmtPercentageFormatRegular_my_MM: function(test) { + test.expect(2); + var fmt = new NumFmt({ + locale: "my-MM", + useNative: true, + type: "percentage" + }); + test.ok(fmt); + test.equal(fmt.format(-57.8), '-၅၇.၈%'); + test.done(); + }, + testNumFmtPercentageNativeFormatRegular_my_MM: function(test) { + test.expect(2); + var fmt = new NumFmt({ + locale: "my-MM", + type: "percentage" + }); + test.ok(fmt); + test.equal(fmt.format(-57.8), '-၅၇.၈%'); + test.done(); } }; From 5a6a66de481bd1f3ccae678e718417fff9f27675 Mon Sep 17 00:00:00 2001 From: Goun Lee Date: Thu, 27 Aug 2020 17:48:51 +0900 Subject: [PATCH 41/48] Add testcases to verify ne-NP --- js/build.xml | 2 +- js/test/date/testDayOfWeek.js | 10 + js/test/date/testMeridiems.js | 10 + js/test/date/testMonthTranslation.js | 45 + js/test/date/testSuite.html | 3 +- js/test/date/testSuiteFiles.js | 1 + js/test/date/testWeekdayTranslation.js | 71 + js/test/date/testcalendar.js | 4 +- js/test/date/testclock.js | 9 + js/test/date/testdatefmt_ne_NP.js | 1796 +++++++++++++++++ js/test/date/testdatetimefmt.js | 26 + js/test/daterange/testSuite.html | 3 +- js/test/daterange/testSuiteFiles.js | 3 +- .../daterange/testdatefmtrange_fmttemplate.js | 72 + js/test/daterange/testdatefmtrange_ne_NP.js | 692 +++++++ js/test/durfmt/testdurfmt2.js | 41 + js/test/number/testcurrency.js | 11 +- js/test/number/testnumfmt.js | 90 +- js/test/number/testnumfmt2.js | 19 + js/test/root/testcountry.js | 26 + js/test/root/testlocaleinfo.js | 10 + js/test/root/testlocalematch.js | 56 + js/test/root/testscriptinfo.js | 10 + js/test/root/teststrings.js | 40 + js/test/strings-ext/testSuite.html | 3 +- js/test/strings-ext/testSuiteCompiled.html | 3 +- js/test/strings-ext/testSuiteFiles.js | 3 +- js/test/strings-ext/testlistfmt_ne_NP.js | 253 +++ js/test/units/testSuite.html | 3 +- js/test/units/testSuiteFiles.js | 3 +- js/test/units/testunitfmt_ne_NP.js | 327 +++ 31 files changed, 3632 insertions(+), 13 deletions(-) create mode 100644 js/test/date/testdatefmt_ne_NP.js create mode 100644 js/test/daterange/testdatefmtrange_ne_NP.js create mode 100644 js/test/strings-ext/testlistfmt_ne_NP.js create mode 100644 js/test/units/testunitfmt_ne_NP.js diff --git a/js/build.xml b/js/build.xml index 616ffcdb9b..eaf5bf3b8e 100644 --- a/js/build.xml +++ b/js/build.xml @@ -54,7 +54,7 @@ limitations under the License. - + diff --git a/js/test/date/testDayOfWeek.js b/js/test/date/testDayOfWeek.js index 5879a6faa0..ae4dd39cd9 100644 --- a/js/test/date/testDayOfWeek.js +++ b/js/test/date/testDayOfWeek.js @@ -1978,5 +1978,15 @@ module.exports.testweekdata = { test.equal(info.getWeekEndStart(), 6); test.equal(info.getWeekEndEnd(), 0); test.done(); + }, + testWeekData_ne_NP: function(test) { + test.expect(4); + var info = new LocaleInfo("ne-NP"); + test.ok(info !== null); + + test.equal(info.getFirstDayOfWeek(), 0); + test.equal(info.getWeekEndStart(), 6); + test.equal(info.getWeekEndEnd(), 0); + test.done(); } } diff --git a/js/test/date/testMeridiems.js b/js/test/date/testMeridiems.js index 35d6740376..2575b1707b 100644 --- a/js/test/date/testMeridiems.js +++ b/js/test/date/testMeridiems.js @@ -1982,6 +1982,16 @@ module.exports.testmeridiems = { test.equal(fmt[0].name, "AM"); test.equal(fmt[1].name, "PM"); + test.done(); + }, + testMeridiem_ne_NP: function(test) { + test.expect(3); + var fmt = DateFmt.getMeridiemsRange({locale:"ne-NP"}); + test.ok(fmt !== null); + + test.equal(fmt[0].name, "पूर्वाह्न"); + test.equal(fmt[1].name, "अपराह्न"); + test.done(); } } \ No newline at end of file diff --git a/js/test/date/testMonthTranslation.js b/js/test/date/testMonthTranslation.js index a2f0368a44..faf91dc09d 100644 --- a/js/test/date/testMonthTranslation.js +++ b/js/test/date/testMonthTranslation.js @@ -7360,6 +7360,51 @@ module.exports.testmonthtranslation = { test.equal(value[10], "aza."); test.equal(value[11], "abe."); + test.done(); + }, + testMonthTranslate_ne_NP: function(test) { + test.expect(24); + + // full, long: MMMM + // medium: MMM + // short: M + + var value = [], i; + var fmt = new DateFmt({locale:"ne-NP", date:"m", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + test.equal(value[0], "जनवरी"); + test.equal(value[1], "फेब्रुअरी"); + test.equal(value[2], "मार्च"); + test.equal(value[3], "अप्रिल"); + test.equal(value[4], "मे"); + test.equal(value[5], "जुन"); + test.equal(value[6], "जुलाई"); + test.equal(value[7], "अगस्ट"); + test.equal(value[8], "सेप्टेम्बर"); + test.equal(value[9], "अक्टोबर"); + test.equal(value[10], "नोभेम्बर"); + test.equal(value[11], "डिसेम्बर"); + + var fmt = new DateFmt({locale:"ne-NP", date:"m", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + + test.equal(value[0], "जनवरी"); + test.equal(value[1], "फेब्रुअरी"); + test.equal(value[2], "मार्च"); + test.equal(value[3], "अप्रिल"); + test.equal(value[4], "मे"); + test.equal(value[5], "जुन"); + test.equal(value[6], "जुलाई"); + test.equal(value[7], "अगस्ट"); + test.equal(value[8], "सेप्टेम्बर"); + test.equal(value[9], "अक्टोबर"); + test.equal(value[10], "नोभेम्बर"); + test.equal(value[11], "डिसेम्बर"); + test.done(); } } diff --git a/js/test/date/testSuite.html b/js/test/date/testSuite.html index 00c43149e6..c3d1af5024 100644 --- a/js/test/date/testSuite.html +++ b/js/test/date/testSuite.html @@ -1,7 +1,7 @@