├── .editorconfig ├── .eslintignore ├── .eslintrc.json ├── .gitignore ├── History.md ├── LICENSE ├── README.md ├── babel.config.js ├── bower.json ├── component.json ├── dist ├── commonjs │ ├── api.js │ ├── api.js.map │ ├── full.js │ ├── full.js.map │ ├── fullLangRegionMap.js │ ├── fullLangRegionMap.js.map │ ├── langRegionMap.js │ ├── langRegionMap.js.map │ ├── main.js │ ├── main.js.map │ ├── regionDayMap.js │ └── regionDayMap.js.map ├── es-module │ ├── api.js │ ├── api.js.map │ ├── full.js │ ├── full.js.map │ ├── fullLangRegionMap.js │ ├── fullLangRegionMap.js.map │ ├── langRegionMap.js │ ├── langRegionMap.js.map │ ├── main.js │ ├── main.js.map │ ├── regionDayMap.js │ └── regionDayMap.js.map ├── full.js ├── full.js.map ├── main.js ├── main.js.map └── min │ ├── full.js │ ├── full.js.map │ ├── main.js │ └── main.js.map ├── docs ├── .nojekyll ├── api.js.html ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── full.js.html ├── fullLangRegionMap.js.html ├── img │ ├── glyphicons-halflings-white.png │ └── glyphicons-halflings.png ├── index.html ├── langRegionMap.js.html ├── main.js.html ├── module-api.html ├── module-full.html ├── module-fullLangRegionMap.html ├── module-langRegionMap.html ├── module-main.html ├── module-regionDayMap.html ├── modules.list.html ├── quicksearch.html ├── regionDayMap.js.html ├── scripts │ ├── docstrap.lib.js │ ├── fulltext-search-ui.js │ ├── fulltext-search.js │ ├── lunr.min.js │ ├── prettify │ │ ├── Apache-License-2.0.txt │ │ ├── jquery.min.js │ │ ├── lang-css.js │ │ └── prettify.js │ ├── sunlight.js │ └── toc.js └── styles │ ├── darkstrap.css │ ├── prettify-tomorrow.css │ ├── site.cerulean.css │ ├── site.cosmo.css │ ├── site.cyborg.css │ ├── site.darkly.css │ ├── site.darkstrap.css │ ├── site.dibs-bootstrap.css │ ├── site.flatly.css │ ├── site.journal.css │ ├── site.lumen.css │ ├── site.paper.css │ ├── site.readable.css │ ├── site.sandstone.css │ ├── site.simplex.css │ ├── site.slate.css │ ├── site.spacelab.css │ ├── site.superhero.css │ ├── site.united.css │ ├── site.yeti.css │ ├── sunlight.dark.css │ └── sunlight.default.css ├── full.d.ts ├── full.js ├── index.d.ts ├── jsdoc-conf.js ├── package-lock.json ├── package.json └── src ├── api.js ├── api.test.js ├── full.js ├── full.test.js ├── fullLangRegionMap.js ├── langRegionMap.js ├── main.js ├── main.test.js └── regionDayMap.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 4 7 | insert_final_newline = true 8 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/* 2 | docs/* 3 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "es6": true 5 | }, 6 | "extends": [ 7 | "guard/optimum-next", 8 | "guard/jsdoc" 9 | ], 10 | "parserOptions": { 11 | "sourceType": "module" 12 | } 13 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .eslintcache 2 | .vscode 3 | node_modules 4 | npm-debug.log* 5 | -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | ### 2.0.0 / 2023-02-24 2 | 3 | * Update data. 4 | 5 | ### 1.1.0 / 2021-03-16 6 | 7 | * Remove `docs` from npm package. 8 | 9 | ### 1.0.1 / 2019-10-19 10 | 11 | * Add types declaration files (`.d.ts`). 12 | * Add license file. 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017-present Denis Sikuler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # weekstart 2 | 3 | [![NPM version](https://badge.fury.io/js/weekstart.png)](http://badge.fury.io/js/weekstart) 4 | 5 | Library to get first day of week. 6 | 7 | ```js 8 | getWeekStartByRegion('MAC'); // 0 9 | 10 | getWeekStartByLocale('arq'); // 6 11 | ``` 12 | 13 | The library is based on the following data from Unicode (especially from Common Locale Data Repository) and from ISO: 14 | * [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html) 15 | * [https://github.com/unicode-org/cldr-json/blob/main/cldr-json/cldr-core/supplemental/weekData.json](https://github.com/unicode-org/cldr-json/blob/main/cldr-json/cldr-core/supplemental/weekData.json) 16 | * [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html) 17 | * [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html) 18 | * [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/scripts_languages_and_territories.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/scripts_languages_and_territories.html) 19 | * [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers) 20 | * [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html) 21 | 22 | There are 2 variants of the library having identical [API](#api): 23 | * `main` - uses base mapping of language code to country code from [langRegionMap](https://github.com/gamtiq/weekstart/blob/master/src/langRegionMap.js). 24 | * `full` - uses full mapping of language code to country code from [fullLangRegionMap](https://github.com/gamtiq/weekstart/blob/master/src/fullLangRegionMap.js). 25 | 26 | [langRegionMap](https://github.com/gamtiq/weekstart/blob/master/src/langRegionMap.js) contains only main language codes. 27 | It is data subset from [fullLangRegionMap](https://github.com/gamtiq/weekstart/blob/master/src/fullLangRegionMap.js). 28 | 29 | ## Table of contents 30 | 31 | * [Installation](#install) 32 | * [Usage](#usage) 33 | * [Examples](#examples) 34 | * [API](#api) 35 | * [Contributing](#contributing) 36 | * [License](#license) 37 | 38 | ## Installation [↑](#start) 39 | 40 | ### Node 41 | 42 | npm install weekstart 43 | 44 | ### [Bower](http://bower.io) 45 | 46 | bower install weekstart 47 | 48 | ### AMD/UMD, <script> 49 | 50 | Use `dist/main.js` or `dist/min/main.js` (minified version). 51 | Use `dist/full.js` or `dist/min/full.js` (minified version) when you need full locale data. 52 | 53 | ## Usage [↑](#start) 54 | 55 | ### ECMAScript 6 56 | 57 | ```js 58 | import {getWeekStartByLocale, getWeekStartByRegion} from 'weekstart'; 59 | ``` 60 | 61 | If you need full data: 62 | 63 | ```js 64 | import {getWeekStartByLocale, getWeekStartByRegion} from 'weekstart/full'; 65 | ``` 66 | 67 | ### Node 68 | 69 | ```js 70 | const getWeekStartByLocale = require('weekstart').getWeekStartByLocale; 71 | const getWeekStartByRegion = require('weekstart').getWeekStartByRegion; 72 | ``` 73 | 74 | If you need full data: 75 | 76 | ```js 77 | const getWeekStartByLocale = require('weekstart/full').getWeekStartByLocale; 78 | const getWeekStartByRegion = require('weekstart/full').getWeekStartByRegion; 79 | ``` 80 | 81 | ### AMD/UMD 82 | 83 | ```js 84 | define(['path/to/dist/main.js'], function(weekstart) { 85 | const getWeekStartByLocale = weekstart.getWeekStartByLocale; 86 | const getWeekStartByRegion = weekstart.getWeekStartByRegion; 87 | }); 88 | ``` 89 | 90 | If you need full data: 91 | 92 | ```js 93 | define(['path/to/dist/full.js'], function(weekstart) { 94 | const getWeekStartByLocale = weekstart.getWeekStartByLocale; 95 | const getWeekStartByRegion = weekstart.getWeekStartByRegion; 96 | }); 97 | ``` 98 | 99 | ### Bower, <script> 100 | 101 | ```html 102 | 103 | 104 | 109 | ``` 110 | 111 | If you need full data use `path/to/dist/full.js` instead of `path/to/dist/main.js`. 112 | 113 | ## Examples [↑](#start) 114 | 115 | ```js 116 | getWeekStartByRegion('dj'); // 6 117 | getWeekStartByRegion('No'); // 1 118 | getWeekStartByRegion('CAN'); // 0 119 | getWeekStartByRegion(462); // 5 120 | 121 | getWeekStartByLocale('Jam'); // 0 122 | getWeekStartByLocale('Fa'); // 6 123 | getWeekStartByLocale('vi'); // 1 124 | getWeekStartByLocale('es_MX'); // 0 125 | getWeekStartByLocale('az-Arab-IRN'); // 6 126 | ``` 127 | 128 | In the following examples results are given for the function from `full.js`. 129 | The same calls for the function from `main.js` will return `1`. 130 | 131 | ```js 132 | getWeekStartByLocale('CCP'); // 0 133 | getWeekStartByLocale('UZ-arab'); // 6 134 | ``` 135 | 136 | ## API [↑](#start) 137 | 138 | #### getWeekStartByLocale(locale): number 139 | 140 | Return first day of week for locale identifier: 141 | 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday. 142 | 143 | #### getWeekStartByRegion(regionCode): number 144 | 145 | Return first day of week for country/region code: 146 | 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday. 147 | 148 | See [`docs`](https://gamtiq.github.io/weekstart/) for details. 149 | 150 | ## Contributing [↑](#start) 151 | In lieu of a formal styleguide, take care to maintain the existing coding style. 152 | Add unit tests for any new or changed functionality. 153 | Lint and test your code. 154 | 155 | ## License [↑](#start) 156 | Licensed under the [MIT license](https://github.com/gamtiq/weekstart/blob/master/LICENSE). 157 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | module.exports = function config(api) { 3 | api.cache(false); 4 | 5 | return { 6 | presets: [ 7 | [ 8 | '@babel/preset-env', 9 | { 10 | useBuiltIns: false 11 | } 12 | ] 13 | ], 14 | 'sourceMaps': true 15 | }; 16 | }; 17 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weekstart", 3 | "main": [ 4 | "dist/main.js" 5 | ], 6 | "version": "2.0.0", 7 | "homepage": "https://github.com/gamtiq/weekstart", 8 | "authors": [ 9 | "Denis Sikuler" 10 | ], 11 | "description": "Library to get first day of week.", 12 | "keywords": [ 13 | "week", 14 | "start", 15 | "first", 16 | "day", 17 | "locale", 18 | "country", 19 | "region" 20 | ], 21 | "license": "MIT", 22 | "ignore": [ 23 | "**/.*", 24 | "node_modules", 25 | "bower_components", 26 | "test", 27 | "tests" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weekstart", 3 | "repository": "gamtiq/weekstart", 4 | "description": "Library to get first day of week.", 5 | "version": "2.0.0", 6 | "keywords": [ 7 | "week", 8 | "start", 9 | "first", 10 | "day", 11 | "locale", 12 | "country", 13 | "region" 14 | ], 15 | "dependencies": {}, 16 | "development": {}, 17 | "license": "MIT", 18 | "main": "dist/main.js", 19 | "scripts": [ 20 | "dist/main.js", 21 | "dist/full.js" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /dist/commonjs/api.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function getWeekStartByRegion(regionCode, regionDayMap) { 4 | var code = regionDayMap[typeof regionCode === 'string' ? regionCode.toUpperCase() : regionCode]; 5 | return typeof code === 'number' ? code : 1; 6 | } 7 | 8 | function getWeekStartByLocale(locale, langRegionMap, regionDayMap) { 9 | if (locale) { 10 | var data = locale.toLowerCase().split(/[-_]/); 11 | var langTag = data[0]; 12 | var language = langTag; 13 | var country; 14 | if (data[1] && data[1].length === 4) { 15 | language += "_" + (data[1]); 16 | country = data[2]; 17 | } else { 18 | country = data[1]; 19 | } 20 | if (!country) { 21 | country = langRegionMap[language] || langRegionMap[langTag]; 22 | } 23 | if (country) { 24 | return getWeekStartByRegion(country.match(/^\d+$/) ? Number(country) : country, regionDayMap); 25 | } 26 | } 27 | return 1; 28 | } 29 | 30 | exports.getWeekStartByRegion = getWeekStartByRegion; 31 | exports.getWeekStartByLocale = getWeekStartByLocale; 32 | //# sourceMappingURL=api.js.map 33 | -------------------------------------------------------------------------------- /dist/commonjs/api.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"api.js","sources":["../../src/api.js"],"sourcesContent":["/**\n * Functions to get first day of week.\n * \n * @module api\n */\n\n\n/**\n * Return first day of week for country/region code.\n *\n * @example\n * getWeekStartByRegion('PNG', {}); // 1\n * getWeekStartByRegion('png', {BR: 0, PNG: 3, EG: 6}); // 3\n * getWeekStartByRegion('qa', {QA: 6}); // 6\n * getWeekStartByRegion(50, {BD: 5, 50: 5, SD: 6}); // 5\n *\n * @param {number | string} regionCode\n * ISO 3166 Alpha-2, Alpha-3 or numeric code.\n * @param {object} regionDayMap\n * Mapping of country/region code to first day of week that should be used to get result.\n * Country codes should be in upper case.\n * @return {number}\n * Code of first day of week for the given country/region code:\n * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.\n * @alias module:api.getWeekStartByRegion\n */\nexport function getWeekStartByRegion(regionCode, regionDayMap) {\n /* eslint-disable indent */\n const code = regionDayMap[typeof regionCode === 'string'\n ? regionCode.toUpperCase()\n : regionCode];\n /* eslint-enable indent */\n\n return typeof code === 'number'\n ? code\n : 1;\n}\n\n/**\n * Return first day of week for locale identifier.\n *\n * @example\n * getWeekStartByLocale('no', {}, {}); // 1\n * getWeekStartByLocale('no', {no: 'abc'}, {ABC: 3}); // 3\n * getWeekStartByLocale('KK_arab', {kk_arab: 'CN'}, {CN: 0}); // 0\n * getWeekStartByLocale('fr-DZ', {fr: 'FR'}, {FR: 1, DZ: 6}); // 6\n *\n * @param {string} locale\n * Locale identifier.\n * @param {object} langRegionMap\n * Mapping of language code to country/region code that should be used to get result.\n * Language codes should be in lower case.\n * @param {object} regionDayMap\n * Mapping of country/region code to first day of week that should be used to get result.\n * Country codes should be in upper case.\n * @return {number}\n * Code of first day of week for the given locale identifier:\n * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.\n * @alias module:api.getWeekStartByLocale\n */\nexport function getWeekStartByLocale(locale, langRegionMap, regionDayMap) {\n if (locale) {\n // Locale form: http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers\n const data = locale.toLowerCase().split(/[-_]/);\n const langTag = data[0];\n let language = langTag;\n let country;\n if (data[1] && data[1].length === 4) {\n language += `_${data[1]}`;\n country = data[2];\n }\n else {\n country = data[1];\n }\n if (! country) {\n country = langRegionMap[language] || langRegionMap[langTag];\n }\n if (country) {\n return getWeekStartByRegion(\n country.match(/^\\d+$/)\n ? Number(country)\n : country,\n regionDayMap\n );\n }\n }\n\n return 1;\n}\n"],"names":["const","let"],"mappings":";;AA0BO,SAAS,qBAAqB,UAAY,EAAA,cAAc;IAE3DA,IAAM,OAAO,YAAA,CAAa,OAAO,UAAP,KAAsB,QAAtB,GACI,UAAA,CAAW,WAAX,KACA;IAG9B,OAAO,OAAO,IAAP,KAAgB,QAAhB,GACD,OACA;;;AAyBV,AAAO,SAAS,qBAAqB,MAAQ,EAAA,aAAe,EAAA,cAAc;IACtE,IAAI,QAAQ;QAERA,IAAM,OAAO,MAAA,CAAO,WAAP,EAAA,CAAqB,KAArB,CAA2B;QACxCA,IAAM,UAAU,IAAA,CAAK;QACrBC,IAAI,WAAW;QACfA,IAAI;QACJ,IAAI,IAAA,CAAK,EAAL,IAAW,IAAA,CAAK,EAAL,CAAQ,MAAR,KAAmB,GAAG;YACjC,QAAA,IAAY,OAAI,IAAA,CAAK;YACrB,OAAA,GAAU,IAAA,CAAK;eAEd;YACD,OAAA,GAAU,IAAA,CAAK;;QAEnB,IAAI,CAAE,SAAS;YACX,OAAA,GAAU,aAAA,CAAc,SAAd,IAA2B,aAAA,CAAc;;QAEvD,IAAI,SAAS;YACT,OAAO,oBAAA,CACH,OAAA,CAAQ,KAAR,CAAc,QAAd,GACM,MAAA,CAAO,WACP,SACN;;;IAKZ,OAAO;;;;;;"} -------------------------------------------------------------------------------- /dist/commonjs/full.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } 4 | 5 | var api = require('./api.js'); 6 | var langRegionMap = _interopDefault(require('./fullLangRegionMap.js')); 7 | var regionDayMap = _interopDefault(require('./regionDayMap.js')); 8 | 9 | function getWeekStartByRegion(regionCode) { 10 | return api.getWeekStartByRegion(regionCode, regionDayMap); 11 | } 12 | 13 | function getWeekStartByLocale(locale) { 14 | return api.getWeekStartByLocale(locale, langRegionMap, regionDayMap); 15 | } 16 | 17 | exports.getWeekStartByRegion = getWeekStartByRegion; 18 | exports.getWeekStartByLocale = getWeekStartByLocale; 19 | //# sourceMappingURL=full.js.map 20 | -------------------------------------------------------------------------------- /dist/commonjs/full.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"full.js","sources":["../../src/full.js"],"sourcesContent":["/*\n * weekstart\n * https://github.com/gamtiq/weekstart\n */\n\n/**\n * Library to get first day of week.\n * \n * Uses data from {@link module:fullLangRegionMap fullLangRegionMap.js} and\n * {@link module:regionDayMap regionDayMap.js}.\n * \n * @module full\n */\n\nimport * as api from './api';\nimport langRegionMap from './fullLangRegionMap';\nimport regionDayMap from './regionDayMap';\n\n/**\n * Return first day of week for country/region code.\n *\n * Based on data from:\n * - [https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json](https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json)\n * - [http://www.unicode.org/cldr/charts/28/supplemental/territory_information.html](http://www.unicode.org/cldr/charts/28/supplemental/territory_information.html)\n * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html)\n *\n * @example\n * getWeekStartByRegion('PNG'); // 1\n * getWeekStartByRegion('qa'); // 6\n * getWeekStartByRegion(462); // 5\n *\n * @param {number | string} regionCode\n * ISO 3166 Alpha-2, Alpha-3 or numeric code.\n * @return {number}\n * Code of first day of week for the given country/region code:\n * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.\n * @alias module:full.getWeekStartByRegion\n * @see module:api.getWeekStartByRegion\n */\nexport function getWeekStartByRegion(regionCode) {\n return api.getWeekStartByRegion(regionCode, regionDayMap);\n}\n\n/**\n * Return first day of week for locale identifier.\n *\n * Based on data from:\n * - [http://www.unicode.org/cldr/charts/28/supplemental/territory_language_information.html](http://www.unicode.org/cldr/charts/28/supplemental/territory_language_information.html)\n * - [http://www.unicode.org/cldr/charts/28/supplemental/language_territory_information.html](http://www.unicode.org/cldr/charts/28/supplemental/language_territory_information.html)\n * - [http://www.unicode.org/cldr/charts/28/supplemental/territory_information.html](http://www.unicode.org/cldr/charts/28/supplemental/territory_information.html)\n * - [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers)\n *\n * @example\n * getWeekStartByLocale('no'); // 1\n * getWeekStartByLocale('PA_arab'); // 0\n * getWeekStartByLocale('fr-DZ'); // 6\n *\n * @param {string} locale\n * Locale identifier.\n * @return {number}\n * Code of first day of week for the given locale identifier:\n * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.\n * @alias module:full.getWeekStartByLocale\n * @see module:api.getWeekStartByLocale\n */\nexport function getWeekStartByLocale(locale) {\n return api.getWeekStartByLocale(locale, langRegionMap, regionDayMap);\n}\n"],"names":["api.getWeekStartByRegion","api.getWeekStartByLocale"],"mappings":";;;;;;;;AAuCO,SAAS,qBAAqB,YAAY;IAC7C,OAAOA,wBAAA,CAAyB,YAAY;;;AAyBhD,AAAO,SAAS,qBAAqB,QAAQ;IACzC,OAAOC,wBAAA,CAAyB,QAAQ,eAAe;;;;;;"} -------------------------------------------------------------------------------- /dist/commonjs/fullLangRegionMap.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var langRegionMap = { 4 | en: 'US', 5 | hi: 'IN', 6 | deva: 'IN', 7 | te: 'IN', 8 | mr: 'IN', 9 | ta: 'IN', 10 | gu: 'IN', 11 | kn: 'IN', 12 | or: 'IN', 13 | ml: 'IN', 14 | pa: 'IN', 15 | bho: 'IN', 16 | awa: 'IN', 17 | as: 'IN', 18 | mwr: 'IN', 19 | mai: 'IN', 20 | mag: 'IN', 21 | bgc: 'IN', 22 | hne: 'IN', 23 | dcc: 'IN', 24 | bjj: 'IN', 25 | sat: 'IN', 26 | wtm: 'IN', 27 | ks: 'IN', 28 | kok: 'IN', 29 | gom: 'IN', 30 | swv: 'IN', 31 | lmn: 'IN', 32 | gbm: 'IN', 33 | gon: 'IN', 34 | kfy: 'IN', 35 | kru: 'IN', 36 | doi: 'IN', 37 | wbq: 'IN', 38 | sck: 'IN', 39 | xnr: 'IN', 40 | wbr: 'IN', 41 | tcy: 'IN', 42 | khn: 'IN', 43 | brx: 'IN', 44 | noe: 'IN', 45 | bhb: 'IN', 46 | mni: 'IN', 47 | raj: 'IN', 48 | hoc: 'IN', 49 | mtr: 'IN', 50 | unr: 'IN', 51 | bhi: 'IN', 52 | hoj: 'IN', 53 | kha: 'IN', 54 | kfr: 'IN', 55 | grt: 'IN', 56 | unx: 'IN', 57 | bfy: 'IN', 58 | srx: 'IN', 59 | saz: 'IN', 60 | sd_deva: 'IN', 61 | ccp: 'IN', 62 | njo: 'IN', 63 | bfq: 'IN', 64 | ria: 'IN', 65 | bpy: 'IN', 66 | bra: 'IN', 67 | lep: 'IN', 68 | sa: 'IN', 69 | kht: 'IN', 70 | bn: 'BD', 71 | beng: 'BD', 72 | rkt: 'BD', 73 | syl: 'BD', 74 | mro: 'BD', 75 | kgp: 'BR', 76 | gub: 'BR', 77 | yrl: 'BR', 78 | xav: 'BR', 79 | dz: 'BT', 80 | tibt: 'BT', 81 | tsj: 'BT', 82 | tn: 'BW', 83 | pdt: 'CA', 84 | crk: 'CA', 85 | cr: 'CA', 86 | iu: 'CA', 87 | oj: 'CA', 88 | ojs: 'CA', 89 | moe: 'CA', 90 | mic: 'CA', 91 | bla: 'CA', 92 | crj: 'CA', 93 | atj: 'CA', 94 | crl: 'CA', 95 | csw: 'CA', 96 | crm: 'CA', 97 | ikt: 'CA', 98 | moh: 'CA', 99 | dgr: 'CA', 100 | den: 'CA', 101 | clc: 'CA', 102 | hur: 'CA', 103 | crg: 'CA', 104 | lil: 'CA', 105 | oka: 'CA', 106 | pqm: 'CA', 107 | kwk: 'CA', 108 | nsk: 'CA', 109 | chp: 'CA', 110 | gwi: 'CA', 111 | guc: 'CO', 112 | am: 'ET', 113 | ethi: 'ET', 114 | om: 'ET', 115 | ti: 'ET', 116 | sid: 'ET', 117 | wal: 'ET', 118 | aa: 'ET', 119 | quc: 'GT', 120 | ch: 'GU', 121 | id: 'ID', 122 | jv: 'ID', 123 | su: 'ID', 124 | mad: 'ID', 125 | ms_arab: 'ID', 126 | min: 'ID', 127 | bew: 'ID', 128 | ban: 'ID', 129 | bug: 'ID', 130 | bjn: 'ID', 131 | ace: 'ID', 132 | sas: 'ID', 133 | bbc: 'ID', 134 | mak: 'ID', 135 | ljp: 'ID', 136 | rej: 'ID', 137 | gor: 'ID', 138 | nij: 'ID', 139 | kge: 'ID', 140 | aoz: 'ID', 141 | kvr: 'ID', 142 | lbw: 'ID', 143 | gay: 'ID', 144 | rob: 'ID', 145 | sxn: 'ID', 146 | mdr: 'ID', 147 | sly: 'ID', 148 | mwv: 'ID', 149 | he: 'IL', 150 | hebr: 'IL', 151 | lad: 'IL', 152 | jam: 'JM', 153 | ja: 'JP', 154 | jpan: 'JP', 155 | ryu: 'JP', 156 | ki: 'KE', 157 | luy: 'KE', 158 | luo: 'KE', 159 | kln: 'KE', 160 | kam: 'KE', 161 | guz: 'KE', 162 | mer: 'KE', 163 | ebu: 'KE', 164 | dav: 'KE', 165 | pko: 'KE', 166 | saq: 'KE', 167 | km: 'KH', 168 | khmr: 'KH', 169 | cja: 'KH', 170 | ko: 'KR', 171 | kore: 'KR', 172 | lo: 'LA', 173 | laoo: 'LA', 174 | kjg: 'LA', 175 | hnj: 'LA', 176 | mh: 'MH', 177 | my: 'MM', 178 | mymr: 'MM', 179 | shn: 'MM', 180 | kac: 'MM', 181 | rhg: 'MM', 182 | mnw: 'MM', 183 | mt: 'MT', 184 | yua: 'MX', 185 | nhe: 'MX', 186 | nhw: 'MX', 187 | maz: 'MX', 188 | nch: 'MX', 189 | sei: 'MX', 190 | vmw: 'MZ', 191 | ndc: 'MZ', 192 | ngl: 'MZ', 193 | seh: 'MZ', 194 | mgh: 'MZ', 195 | rng: 'MZ', 196 | yao: 'MZ', 197 | ne: 'NP', 198 | 'new': 'NP', 199 | jml: 'NP', 200 | dty: 'NP', 201 | taj: 'NP', 202 | thl: 'NP', 203 | bap: 'NP', 204 | tdg: 'NP', 205 | thr: 'NP', 206 | mgp: 'NP', 207 | lif: 'NP', 208 | thq: 'NP', 209 | mrd: 'NP', 210 | xsr: 'NP', 211 | rjs: 'NP', 212 | tsf: 'NP', 213 | ggn: 'NP', 214 | gvr: 'NP', 215 | tkt: 'NP', 216 | tdh: 'NP', 217 | unr_deva: 'NP', 218 | qu: 'PE', 219 | fil: 'PH', 220 | ceb: 'PH', 221 | ilo: 'PH', 222 | hil: 'PH', 223 | bik: 'PH', 224 | war: 'PH', 225 | fbl: 'PH', 226 | pam: 'PH', 227 | pag: 'PH', 228 | mdh: 'PH', 229 | tsg: 'PH', 230 | cps: 'PH', 231 | krj: 'PH', 232 | bto: 'PH', 233 | hnn: 'PH', 234 | tbw: 'PH', 235 | bku: 'PH', 236 | ur: 'PK', 237 | pa_arab: 'PK', 238 | lah: 'PK', 239 | ps: 'PK', 240 | sd: 'PK', 241 | skr: 'PK', 242 | bal: 'PK', 243 | brh: 'PK', 244 | hno: 'PK', 245 | bgn: 'PK', 246 | hnd: 'PK', 247 | tg_arab: 'PK', 248 | gju: 'PK', 249 | bft: 'PK', 250 | kvx: 'PK', 251 | khw: 'PK', 252 | mvy: 'PK', 253 | kxp: 'PK', 254 | gjk: 'PK', 255 | trw: 'PK', 256 | btv: 'PK', 257 | gn: 'PY', 258 | th: 'TH', 259 | thai: 'TH', 260 | tts: 'TH', 261 | nod: 'TH', 262 | sou: 'TH', 263 | mfa: 'TH', 264 | kxm: 'TH', 265 | kdt: 'TH', 266 | lwl: 'TH', 267 | zh_hant: 'TW', 268 | hant: 'TW', 269 | trv: 'TW', 270 | nv: 'US', 271 | pdc: 'US', 272 | haw: 'US', 273 | frc: 'US', 274 | chr: 'US', 275 | esu: 'US', 276 | dak: 'US', 277 | cho: 'US', 278 | lkt: 'US', 279 | ik: 'US', 280 | mus: 'US', 281 | sm: 'WS', 282 | zu: 'ZA', 283 | xh: 'ZA', 284 | af: 'ZA', 285 | nso: 'ZA', 286 | ts: 'ZA', 287 | ve: 'ZA', 288 | nr: 'ZA', 289 | sn: 'ZW', 290 | nd: 'ZW', 291 | mxc: 'ZW', 292 | kck: 'ZW', 293 | haz: 'AF', 294 | uz_arab: 'AF', 295 | prd: 'AF', 296 | arq: 'DZ', 297 | kab: 'DZ', 298 | ar: 'EG', 299 | arab: 'EG', 300 | arz: 'EG', 301 | ckb: 'IQ', 302 | syr: 'IQ', 303 | fa: 'IR', 304 | az_arab: 'IR', 305 | mzn: 'IR', 306 | glk: 'IR', 307 | sdh: 'IR', 308 | lrc: 'IR', 309 | rmt: 'IR', 310 | bqi: 'IR', 311 | luz: 'IR', 312 | lki: 'IR', 313 | gbz: 'IR', 314 | bej: 'SD', 315 | fvr: 'SD', 316 | mls: 'SD', 317 | fia: 'SD', 318 | zag: 'SD', 319 | dv: 'MV', 320 | thaa: 'MV' 321 | }; 322 | 323 | module.exports = langRegionMap; 324 | //# sourceMappingURL=fullLangRegionMap.js.map 325 | -------------------------------------------------------------------------------- /dist/commonjs/langRegionMap.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var langRegionMap = { 4 | en: 'US', 5 | hi: 'IN', 6 | deva: 'IN', 7 | te: 'IN', 8 | mr: 'IN', 9 | ta: 'IN', 10 | gu: 'IN', 11 | kn: 'IN', 12 | or: 'IN', 13 | ml: 'IN', 14 | pa: 'IN', 15 | bho: 'IN', 16 | awa: 'IN', 17 | as: 'IN', 18 | mwr: 'IN', 19 | mai: 'IN', 20 | mag: 'IN', 21 | bgc: 'IN', 22 | hne: 'IN', 23 | dcc: 'IN', 24 | bn: 'BD', 25 | beng: 'BD', 26 | rkt: 'BD', 27 | dz: 'BT', 28 | tibt: 'BT', 29 | tn: 'BW', 30 | am: 'ET', 31 | ethi: 'ET', 32 | om: 'ET', 33 | quc: 'GT', 34 | id: 'ID', 35 | jv: 'ID', 36 | su: 'ID', 37 | mad: 'ID', 38 | ms_arab: 'ID', 39 | he: 'IL', 40 | hebr: 'IL', 41 | jam: 'JM', 42 | ja: 'JP', 43 | jpan: 'JP', 44 | km: 'KH', 45 | khmr: 'KH', 46 | ko: 'KR', 47 | kore: 'KR', 48 | lo: 'LA', 49 | laoo: 'LA', 50 | mh: 'MH', 51 | my: 'MM', 52 | mymr: 'MM', 53 | mt: 'MT', 54 | ne: 'NP', 55 | fil: 'PH', 56 | ceb: 'PH', 57 | ilo: 'PH', 58 | ur: 'PK', 59 | pa_arab: 'PK', 60 | lah: 'PK', 61 | ps: 'PK', 62 | sd: 'PK', 63 | skr: 'PK', 64 | gn: 'PY', 65 | th: 'TH', 66 | thai: 'TH', 67 | tts: 'TH', 68 | zh_hant: 'TW', 69 | hant: 'TW', 70 | sm: 'WS', 71 | zu: 'ZA', 72 | sn: 'ZW', 73 | arq: 'DZ', 74 | ar: 'EG', 75 | arab: 'EG', 76 | arz: 'EG', 77 | fa: 'IR', 78 | az_arab: 'IR', 79 | dv: 'MV', 80 | thaa: 'MV' 81 | }; 82 | 83 | module.exports = langRegionMap; 84 | //# sourceMappingURL=langRegionMap.js.map 85 | -------------------------------------------------------------------------------- /dist/commonjs/langRegionMap.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"langRegionMap.js","sources":["../../src/langRegionMap.js"],"sourcesContent":["/**\n * Contains base mapping of language code to country code.\n * Contains data only for countries which first day of week is not monday,\n * and mainly for languages approximately having more than 10 mln speakers.\n *\n * Based on data from `fullLangRegionMap.js`.\n * \n * @module langRegionMap\n */\n\n\n/* eslint-disable camelcase */\n/**\n * Base mapping of language code to country code.\n * Contains data only for countries which first day of week is not monday,\n * and mainly for languages approximately having more than 10 mln speakers.\n *\n * Based on data from `fullLangRegionMap.js`.\n */\nconst langRegionMap = {\n en: 'US',\n \n hi: 'IN',\n deva: 'IN', // script\n te: 'IN',\n mr: 'IN',\n ta: 'IN',\n gu: 'IN',\n kn: 'IN',\n or: 'IN',\n ml: 'IN',\n pa: 'IN',\n bho: 'IN',\n awa: 'IN',\n as: 'IN',\n mwr: 'IN',\n mai: 'IN',\n mag: 'IN',\n bgc: 'IN',\n hne: 'IN',\n dcc: 'IN',\n\n bn: 'BD',\n beng: 'BD', // script\n rkt: 'BD',\n\n dz: 'BT',\n tibt: 'BT', // script\n\n tn: 'BW',\n\n am: 'ET',\n ethi: 'ET', // script\n om: 'ET',\n\n quc: 'GT',\n\n id: 'ID',\n jv: 'ID',\n su: 'ID',\n mad: 'ID',\n ms_arab: 'ID',\n\n he: 'IL',\n hebr: 'IL', // script\n\n jam: 'JM',\n\n ja: 'JP',\n jpan: 'JP', // script\n\n km: 'KH',\n khmr: 'KH', // script\n\n ko: 'KR',\n kore: 'KR', // script\n\n lo: 'LA',\n laoo: 'LA', // script\n\n mh: 'MH',\n\n my: 'MM',\n mymr: 'MM', // script\n\n mt: 'MT',\n\n ne: 'NP',\n\n fil: 'PH',\n ceb: 'PH',\n ilo: 'PH',\n\n ur: 'PK',\n pa_arab: 'PK',\n lah: 'PK',\n ps: 'PK',\n sd: 'PK',\n skr: 'PK',\n\n gn: 'PY',\n\n th: 'TH',\n thai: 'TH', // script\n tts: 'TH',\n\n zh_hant: 'TW',\n hant: 'TW', // script\n\n sm: 'WS',\n \n zu: 'ZA',\n\n sn: 'ZW',\n\n\n arq: 'DZ',\n\n ar: 'EG',\n arab: 'EG', // script\n arz: 'EG',\n\n fa: 'IR',\n az_arab: 'IR',\n\n\n dv: 'MV',\n thaa: 'MV' // script\n};\n/* eslint-enable camelcase */\n\nexport default langRegionMap;\n"],"names":["const"],"mappings":";;AAmBAA,IAAM,gBAAgB;IAClB,IAAI,IADc;IAGlB,IAAI,IAHc;IAIlB,MAAM,IAJY;IAKlB,IAAI,IALc;IAMlB,IAAI,IANc;IAOlB,IAAI,IAPc;IAQlB,IAAI,IARc;IASlB,IAAI,IATc;IAUlB,IAAI,IAVc;IAWlB,IAAI,IAXc;IAYlB,IAAI,IAZc;IAalB,KAAK,IAba;IAclB,KAAK,IAda;IAelB,IAAI,IAfc;IAgBlB,KAAK,IAhBa;IAiBlB,KAAK,IAjBa;IAkBlB,KAAK,IAlBa;IAmBlB,KAAK,IAnBa;IAoBlB,KAAK,IApBa;IAqBlB,KAAK,IArBa;IAuBlB,IAAI,IAvBc;IAwBlB,MAAM,IAxBY;IAyBlB,KAAK,IAzBa;IA2BlB,IAAI,IA3Bc;IA4BlB,MAAM,IA5BY;IA8BlB,IAAI,IA9Bc;IAgClB,IAAI,IAhCc;IAiClB,MAAM,IAjCY;IAkClB,IAAI,IAlCc;IAoClB,KAAK,IApCa;IAsClB,IAAI,IAtCc;IAuClB,IAAI,IAvCc;IAwClB,IAAI,IAxCc;IAyClB,KAAK,IAzCa;IA0ClB,SAAS,IA1CS;IA4ClB,IAAI,IA5Cc;IA6ClB,MAAM,IA7CY;IA+ClB,KAAK,IA/Ca;IAiDlB,IAAI,IAjDc;IAkDlB,MAAM,IAlDY;IAoDlB,IAAI,IApDc;IAqDlB,MAAM,IArDY;IAuDlB,IAAI,IAvDc;IAwDlB,MAAM,IAxDY;IA0DlB,IAAI,IA1Dc;IA2DlB,MAAM,IA3DY;IA6DlB,IAAI,IA7Dc;IA+DlB,IAAI,IA/Dc;IAgElB,MAAM,IAhEY;IAkElB,IAAI,IAlEc;IAoElB,IAAI,IApEc;IAsElB,KAAK,IAtEa;IAuElB,KAAK,IAvEa;IAwElB,KAAK,IAxEa;IA0ElB,IAAI,IA1Ec;IA2ElB,SAAS,IA3ES;IA4ElB,KAAK,IA5Ea;IA6ElB,IAAI,IA7Ec;IA8ElB,IAAI,IA9Ec;IA+ElB,KAAK,IA/Ea;IAiFlB,IAAI,IAjFc;IAmFlB,IAAI,IAnFc;IAoFlB,MAAM,IApFY;IAqFlB,KAAK,IArFa;IAuFlB,SAAS,IAvFS;IAwFlB,MAAM,IAxFY;IA0FlB,IAAI,IA1Fc;IA4FlB,IAAI,IA5Fc;IA8FlB,IAAI,IA9Fc;IAiGlB,KAAK,IAjGa;IAmGlB,IAAI,IAnGc;IAoGlB,MAAM,IApGY;IAqGlB,KAAK,IArGa;IAuGlB,IAAI,IAvGc;IAwGlB,SAAS,IAxGS;IA2GlB,IAAI,IA3Gc;IA4GlB,MAAM;;;;;"} -------------------------------------------------------------------------------- /dist/commonjs/main.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } 4 | 5 | var api = require('./api.js'); 6 | var langRegionMap = _interopDefault(require('./langRegionMap.js')); 7 | var regionDayMap = _interopDefault(require('./regionDayMap.js')); 8 | 9 | function getWeekStartByRegion(regionCode) { 10 | return api.getWeekStartByRegion(regionCode, regionDayMap); 11 | } 12 | 13 | function getWeekStartByLocale(locale) { 14 | return api.getWeekStartByLocale(locale, langRegionMap, regionDayMap); 15 | } 16 | 17 | exports.getWeekStartByRegion = getWeekStartByRegion; 18 | exports.getWeekStartByLocale = getWeekStartByLocale; 19 | //# sourceMappingURL=main.js.map 20 | -------------------------------------------------------------------------------- /dist/commonjs/main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"main.js","sources":["../../src/main.js"],"sourcesContent":["/*\n * weekstart\n * https://github.com/gamtiq/weekstart\n */\n\n/**\n * Library to get first day of week.\n * \n * Uses data from {@link module:langRegionMap langRegionMap.js} and\n * {@link module:regionDayMap regionDayMap.js}.\n * \n * @module main\n */\n\nimport * as api from './api';\nimport langRegionMap from './langRegionMap';\nimport regionDayMap from './regionDayMap';\n\n/**\n * Return first day of week for country/region code.\n *\n * Based on data from:\n * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)\n * - [https://github.com/unicode-org/cldr-json/blob/main/cldr-json/cldr-core/supplemental/weekData.json](https://github.com/unicode-org/cldr-json/blob/main/cldr-json/cldr-core/supplemental/weekData.json)\n * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html)\n *\n * @example\n * getWeekStartByRegion('PNG'); // 1\n * getWeekStartByRegion('qa'); // 6\n * getWeekStartByRegion(462); // 5\n *\n * @param {number | string} regionCode\n * ISO 3166 Alpha-2, Alpha-3 or numeric code.\n * @return {number}\n * Code of first day of week for the given country/region code:\n * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.\n * @alias module:main.getWeekStartByRegion\n * @see module:api.getWeekStartByRegion\n */\nexport function getWeekStartByRegion(regionCode) {\n return api.getWeekStartByRegion(regionCode, regionDayMap);\n}\n\n/**\n * Return first day of week for locale identifier.\n *\n * Based on data from:\n * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html)\n * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html)\n * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)\n * - [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers)\n *\n * @example\n * getWeekStartByLocale('no'); // 1\n * getWeekStartByLocale('Pa_Guru'); // 0\n * getWeekStartByLocale('fr-DZ'); // 6\n *\n * @param {string} locale\n * Locale identifier.\n * @return {number}\n * Code of first day of week for the given locale identifier:\n * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.\n * @alias module:main.getWeekStartByLocale\n * @see module:api.getWeekStartByLocale\n */\nexport function getWeekStartByLocale(locale) {\n return api.getWeekStartByLocale(locale, langRegionMap, regionDayMap);\n}\n"],"names":["api.getWeekStartByRegion","api.getWeekStartByLocale"],"mappings":";;;;;;;;AAuCO,SAAS,qBAAqB,YAAY;IAC7C,OAAOA,wBAAA,CAAyB,YAAY;;;AAyBhD,AAAO,SAAS,qBAAqB,QAAQ;IACzC,OAAOC,wBAAA,CAAyB,QAAQ,eAAe;;;;;;"} -------------------------------------------------------------------------------- /dist/commonjs/regionDayMap.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var regionDayMap = { 4 | AG: 0, 5 | ATG: 0, 6 | 28: 0, 7 | AS: 0, 8 | ASM: 0, 9 | 16: 0, 10 | BD: 0, 11 | BGD: 0, 12 | 50: 0, 13 | BR: 0, 14 | BRA: 0, 15 | 76: 0, 16 | BS: 0, 17 | BHS: 0, 18 | 44: 0, 19 | BT: 0, 20 | BTN: 0, 21 | 64: 0, 22 | BW: 0, 23 | BWA: 0, 24 | 72: 0, 25 | BZ: 0, 26 | BLZ: 0, 27 | 84: 0, 28 | CA: 0, 29 | CAN: 0, 30 | 124: 0, 31 | CO: 0, 32 | COL: 0, 33 | 170: 0, 34 | DM: 0, 35 | DMA: 0, 36 | 212: 0, 37 | DO: 0, 38 | DOM: 0, 39 | 214: 0, 40 | ET: 0, 41 | ETH: 0, 42 | 231: 0, 43 | GT: 0, 44 | GTM: 0, 45 | 320: 0, 46 | GU: 0, 47 | GUM: 0, 48 | 316: 0, 49 | HK: 0, 50 | HKG: 0, 51 | 344: 0, 52 | HN: 0, 53 | HND: 0, 54 | 340: 0, 55 | ID: 0, 56 | IDN: 0, 57 | 360: 0, 58 | IL: 0, 59 | ISR: 0, 60 | 376: 0, 61 | IN: 0, 62 | IND: 0, 63 | 356: 0, 64 | JM: 0, 65 | JAM: 0, 66 | 388: 0, 67 | JP: 0, 68 | JPN: 0, 69 | 392: 0, 70 | KE: 0, 71 | KEN: 0, 72 | 404: 0, 73 | KH: 0, 74 | KHM: 0, 75 | 116: 0, 76 | KR: 0, 77 | KOR: 0, 78 | 410: 0, 79 | LA: 0, 80 | LA0: 0, 81 | 418: 0, 82 | MH: 0, 83 | MHL: 0, 84 | 584: 0, 85 | MM: 0, 86 | MMR: 0, 87 | 104: 0, 88 | MO: 0, 89 | MAC: 0, 90 | 446: 0, 91 | MT: 0, 92 | MLT: 0, 93 | 470: 0, 94 | MX: 0, 95 | MEX: 0, 96 | 484: 0, 97 | MZ: 0, 98 | MOZ: 0, 99 | 508: 0, 100 | NI: 0, 101 | NIC: 0, 102 | 558: 0, 103 | NP: 0, 104 | NPL: 0, 105 | 524: 0, 106 | PA: 0, 107 | PAN: 0, 108 | 591: 0, 109 | PE: 0, 110 | PER: 0, 111 | 604: 0, 112 | PH: 0, 113 | PHL: 0, 114 | 608: 0, 115 | PK: 0, 116 | PAK: 0, 117 | 586: 0, 118 | PR: 0, 119 | PRI: 0, 120 | 630: 0, 121 | PT: 0, 122 | PRT: 0, 123 | 620: 0, 124 | PY: 0, 125 | PRY: 0, 126 | 600: 0, 127 | SA: 0, 128 | SAU: 0, 129 | 682: 0, 130 | SG: 0, 131 | SGP: 0, 132 | 702: 0, 133 | SV: 0, 134 | SLV: 0, 135 | 222: 0, 136 | TH: 0, 137 | THA: 0, 138 | 764: 0, 139 | TT: 0, 140 | TTO: 0, 141 | 780: 0, 142 | TW: 0, 143 | TWN: 0, 144 | 158: 0, 145 | UM: 0, 146 | UMI: 0, 147 | 581: 0, 148 | US: 0, 149 | USA: 0, 150 | 840: 0, 151 | VE: 0, 152 | VEN: 0, 153 | 862: 0, 154 | VI: 0, 155 | VIR: 0, 156 | 850: 0, 157 | WS: 0, 158 | WSM: 0, 159 | 882: 0, 160 | YE: 0, 161 | YEM: 0, 162 | 887: 0, 163 | ZA: 0, 164 | ZAF: 0, 165 | 710: 0, 166 | ZW: 0, 167 | ZWE: 0, 168 | 716: 0, 169 | AE: 6, 170 | ARE: 6, 171 | 784: 6, 172 | AF: 6, 173 | AFG: 6, 174 | 4: 6, 175 | BH: 6, 176 | BHR: 6, 177 | 48: 6, 178 | DJ: 6, 179 | DJI: 6, 180 | 262: 6, 181 | DZ: 6, 182 | DZA: 6, 183 | 12: 6, 184 | EG: 6, 185 | EGY: 6, 186 | 818: 6, 187 | IQ: 6, 188 | IRQ: 6, 189 | 368: 6, 190 | IR: 6, 191 | IRN: 6, 192 | 364: 6, 193 | JO: 6, 194 | JOR: 6, 195 | 400: 6, 196 | KW: 6, 197 | KWT: 6, 198 | 414: 6, 199 | LY: 6, 200 | LBY: 6, 201 | 434: 6, 202 | OM: 6, 203 | OMN: 6, 204 | 512: 6, 205 | QA: 6, 206 | QAT: 6, 207 | 634: 6, 208 | SD: 6, 209 | SDN: 6, 210 | 729: 6, 211 | SY: 6, 212 | SYR: 6, 213 | 760: 6, 214 | MV: 5, 215 | MDV: 5, 216 | 462: 5 217 | }; 218 | 219 | module.exports = regionDayMap; 220 | //# sourceMappingURL=regionDayMap.js.map 221 | -------------------------------------------------------------------------------- /dist/commonjs/regionDayMap.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"regionDayMap.js","sources":["../../src/regionDayMap.js"],"sourcesContent":["/**\n * Contains data about first day of week depending on country code.\n * \n * @module regionDayMap\n */\n\n\n/* eslint quote-props: ['error', 'as-needed', {'keywords': true, 'numbers': false, 'unnecessary': false}] */\n/**\n * Data about first day of week depending on country code.\n * Based on:\n * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)\n * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html)\n */\nconst regionDayMap = {\n // Sunday\n AG: 0,\n ATG: 0,\n 28: 0,\n AS: 0,\n ASM: 0,\n 16: 0,\n BD: 0,\n BGD: 0,\n 50: 0,\n BR: 0,\n BRA: 0,\n 76: 0,\n BS: 0,\n BHS: 0,\n 44: 0,\n BT: 0,\n BTN: 0,\n 64: 0,\n BW: 0,\n BWA: 0,\n 72: 0,\n BZ: 0,\n BLZ: 0,\n 84: 0,\n CA: 0,\n CAN: 0,\n 124: 0,\n CO: 0,\n COL: 0,\n 170: 0,\n DM: 0,\n DMA: 0,\n 212: 0,\n DO: 0,\n DOM: 0,\n 214: 0,\n ET: 0,\n ETH: 0,\n 231: 0,\n GT: 0,\n GTM: 0,\n 320: 0,\n GU: 0,\n GUM: 0,\n 316: 0,\n HK: 0,\n HKG: 0,\n 344: 0,\n HN: 0,\n HND: 0,\n 340: 0,\n ID: 0,\n IDN: 0,\n 360: 0,\n IL: 0,\n ISR: 0,\n 376: 0,\n IN: 0,\n IND: 0,\n 356: 0,\n JM: 0,\n JAM: 0,\n 388: 0,\n JP: 0,\n JPN: 0,\n 392: 0,\n KE: 0,\n KEN: 0,\n 404: 0,\n KH: 0,\n KHM: 0,\n 116: 0,\n KR: 0,\n KOR: 0,\n 410: 0,\n LA: 0,\n LA0: 0,\n 418: 0,\n MH: 0,\n MHL: 0,\n 584: 0,\n MM: 0,\n MMR: 0,\n 104: 0,\n MO: 0,\n MAC: 0,\n 446: 0,\n MT: 0,\n MLT: 0,\n 470: 0,\n MX: 0,\n MEX: 0,\n 484: 0,\n MZ: 0,\n MOZ: 0,\n 508: 0,\n NI: 0,\n NIC: 0,\n 558: 0,\n NP: 0,\n NPL: 0,\n 524: 0,\n PA: 0,\n PAN: 0,\n 591: 0,\n PE: 0,\n PER: 0,\n 604: 0,\n PH: 0,\n PHL: 0,\n 608: 0,\n PK: 0,\n PAK: 0,\n 586: 0,\n PR: 0,\n PRI: 0,\n 630: 0,\n PT: 0,\n PRT: 0,\n 620: 0,\n PY: 0,\n PRY: 0,\n 600: 0,\n SA: 0,\n SAU: 0,\n 682: 0,\n SG: 0,\n SGP: 0,\n 702: 0,\n SV: 0,\n SLV: 0,\n 222: 0,\n TH: 0,\n THA: 0,\n 764: 0,\n TT: 0,\n TTO: 0,\n 780: 0,\n TW: 0,\n TWN: 0,\n 158: 0,\n UM: 0,\n UMI: 0,\n 581: 0,\n US: 0,\n USA: 0,\n 840: 0,\n VE: 0,\n VEN: 0,\n 862: 0,\n VI: 0,\n VIR: 0,\n 850: 0,\n WS: 0,\n WSM: 0,\n 882: 0,\n YE: 0,\n YEM: 0,\n 887: 0,\n ZA: 0,\n ZAF: 0,\n 710: 0,\n ZW: 0,\n ZWE: 0,\n 716: 0,\n\n // Saturday\n AE: 6,\n ARE: 6,\n 784: 6,\n AF: 6,\n AFG: 6,\n 4: 6,\n BH: 6,\n BHR: 6,\n 48: 6,\n DJ: 6,\n DJI: 6,\n 262: 6,\n DZ: 6,\n DZA: 6,\n 12: 6,\n EG: 6,\n EGY: 6,\n 818: 6,\n IQ: 6,\n IRQ: 6,\n 368: 6,\n IR: 6,\n IRN: 6,\n 364: 6,\n JO: 6,\n JOR: 6,\n 400: 6,\n KW: 6,\n KWT: 6,\n 414: 6,\n LY: 6,\n LBY: 6,\n 434: 6,\n OM: 6,\n OMN: 6,\n 512: 6,\n QA: 6,\n QAT: 6,\n 634: 6,\n SD: 6,\n SDN: 6,\n 729: 6,\n SY: 6,\n SYR: 6,\n 760: 6,\n\n // Friday\n MV: 5,\n MDV: 5,\n 462: 5\n\n // Else - Monday\n};\n\nexport default regionDayMap;\n"],"names":["const"],"mappings":"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"} -------------------------------------------------------------------------------- /dist/es-module/api.js: -------------------------------------------------------------------------------- 1 | function getWeekStartByRegion(regionCode, regionDayMap) { 2 | var code = regionDayMap[typeof regionCode === 'string' ? regionCode.toUpperCase() : regionCode]; 3 | return typeof code === 'number' ? code : 1; 4 | } 5 | 6 | function getWeekStartByLocale(locale, langRegionMap, regionDayMap) { 7 | if (locale) { 8 | var data = locale.toLowerCase().split(/[-_]/); 9 | var langTag = data[0]; 10 | var language = langTag; 11 | var country; 12 | if (data[1] && data[1].length === 4) { 13 | language += "_" + (data[1]); 14 | country = data[2]; 15 | } else { 16 | country = data[1]; 17 | } 18 | if (!country) { 19 | country = langRegionMap[language] || langRegionMap[langTag]; 20 | } 21 | if (country) { 22 | return getWeekStartByRegion(country.match(/^\d+$/) ? Number(country) : country, regionDayMap); 23 | } 24 | } 25 | return 1; 26 | } 27 | 28 | export { getWeekStartByRegion, getWeekStartByLocale }; 29 | //# sourceMappingURL=api.js.map 30 | -------------------------------------------------------------------------------- /dist/es-module/api.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"api.js","sources":["../../src/api.js"],"sourcesContent":["/**\n * Functions to get first day of week.\n * \n * @module api\n */\n\n\n/**\n * Return first day of week for country/region code.\n *\n * @example\n * getWeekStartByRegion('PNG', {}); // 1\n * getWeekStartByRegion('png', {BR: 0, PNG: 3, EG: 6}); // 3\n * getWeekStartByRegion('qa', {QA: 6}); // 6\n * getWeekStartByRegion(50, {BD: 5, 50: 5, SD: 6}); // 5\n *\n * @param {number | string} regionCode\n * ISO 3166 Alpha-2, Alpha-3 or numeric code.\n * @param {object} regionDayMap\n * Mapping of country/region code to first day of week that should be used to get result.\n * Country codes should be in upper case.\n * @return {number}\n * Code of first day of week for the given country/region code:\n * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.\n * @alias module:api.getWeekStartByRegion\n */\nexport function getWeekStartByRegion(regionCode, regionDayMap) {\n /* eslint-disable indent */\n const code = regionDayMap[typeof regionCode === 'string'\n ? regionCode.toUpperCase()\n : regionCode];\n /* eslint-enable indent */\n\n return typeof code === 'number'\n ? code\n : 1;\n}\n\n/**\n * Return first day of week for locale identifier.\n *\n * @example\n * getWeekStartByLocale('no', {}, {}); // 1\n * getWeekStartByLocale('no', {no: 'abc'}, {ABC: 3}); // 3\n * getWeekStartByLocale('KK_arab', {kk_arab: 'CN'}, {CN: 0}); // 0\n * getWeekStartByLocale('fr-DZ', {fr: 'FR'}, {FR: 1, DZ: 6}); // 6\n *\n * @param {string} locale\n * Locale identifier.\n * @param {object} langRegionMap\n * Mapping of language code to country/region code that should be used to get result.\n * Language codes should be in lower case.\n * @param {object} regionDayMap\n * Mapping of country/region code to first day of week that should be used to get result.\n * Country codes should be in upper case.\n * @return {number}\n * Code of first day of week for the given locale identifier:\n * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.\n * @alias module:api.getWeekStartByLocale\n */\nexport function getWeekStartByLocale(locale, langRegionMap, regionDayMap) {\n if (locale) {\n // Locale form: http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers\n const data = locale.toLowerCase().split(/[-_]/);\n const langTag = data[0];\n let language = langTag;\n let country;\n if (data[1] && data[1].length === 4) {\n language += `_${data[1]}`;\n country = data[2];\n }\n else {\n country = data[1];\n }\n if (! country) {\n country = langRegionMap[language] || langRegionMap[langTag];\n }\n if (country) {\n return getWeekStartByRegion(\n country.match(/^\\d+$/)\n ? Number(country)\n : country,\n regionDayMap\n );\n }\n }\n\n return 1;\n}\n"],"names":["const","let"],"mappings":"AA0BO,SAAS,qBAAqB,UAAY,EAAA,cAAc;IAE3DA,IAAM,OAAO,YAAA,CAAa,OAAO,UAAP,KAAsB,QAAtB,GACI,UAAA,CAAW,WAAX,KACA;IAG9B,OAAO,OAAO,IAAP,KAAgB,QAAhB,GACD,OACA;;;AAyBV,AAAO,SAAS,qBAAqB,MAAQ,EAAA,aAAe,EAAA,cAAc;IACtE,IAAI,QAAQ;QAERA,IAAM,OAAO,MAAA,CAAO,WAAP,EAAA,CAAqB,KAArB,CAA2B;QACxCA,IAAM,UAAU,IAAA,CAAK;QACrBC,IAAI,WAAW;QACfA,IAAI;QACJ,IAAI,IAAA,CAAK,EAAL,IAAW,IAAA,CAAK,EAAL,CAAQ,MAAR,KAAmB,GAAG;YACjC,QAAA,IAAY,OAAI,IAAA,CAAK;YACrB,OAAA,GAAU,IAAA,CAAK;eAEd;YACD,OAAA,GAAU,IAAA,CAAK;;QAEnB,IAAI,CAAE,SAAS;YACX,OAAA,GAAU,aAAA,CAAc,SAAd,IAA2B,aAAA,CAAc;;QAEvD,IAAI,SAAS;YACT,OAAO,oBAAA,CACH,OAAA,CAAQ,KAAR,CAAc,QAAd,GACM,MAAA,CAAO,WACP,SACN;;;IAKZ,OAAO;;;;;"} -------------------------------------------------------------------------------- /dist/es-module/full.js: -------------------------------------------------------------------------------- 1 | import { getWeekStartByRegion, getWeekStartByLocale } from './api.js'; 2 | import langRegionMap from './fullLangRegionMap.js'; 3 | import regionDayMap from './regionDayMap.js'; 4 | 5 | function getWeekStartByRegion$1(regionCode) { 6 | return getWeekStartByRegion(regionCode, regionDayMap); 7 | } 8 | 9 | function getWeekStartByLocale$1(locale) { 10 | return getWeekStartByLocale(locale, langRegionMap, regionDayMap); 11 | } 12 | 13 | export { getWeekStartByRegion$1 as getWeekStartByRegion, getWeekStartByLocale$1 as getWeekStartByLocale }; 14 | //# sourceMappingURL=full.js.map 15 | -------------------------------------------------------------------------------- /dist/es-module/full.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"full.js","sources":["../../src/full.js"],"sourcesContent":["/*\n * weekstart\n * https://github.com/gamtiq/weekstart\n */\n\n/**\n * Library to get first day of week.\n * \n * Uses data from {@link module:fullLangRegionMap fullLangRegionMap.js} and\n * {@link module:regionDayMap regionDayMap.js}.\n * \n * @module full\n */\n\nimport * as api from './api';\nimport langRegionMap from './fullLangRegionMap';\nimport regionDayMap from './regionDayMap';\n\n/**\n * Return first day of week for country/region code.\n *\n * Based on data from:\n * - [https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json](https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json)\n * - [http://www.unicode.org/cldr/charts/28/supplemental/territory_information.html](http://www.unicode.org/cldr/charts/28/supplemental/territory_information.html)\n * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html)\n *\n * @example\n * getWeekStartByRegion('PNG'); // 1\n * getWeekStartByRegion('qa'); // 6\n * getWeekStartByRegion(462); // 5\n *\n * @param {number | string} regionCode\n * ISO 3166 Alpha-2, Alpha-3 or numeric code.\n * @return {number}\n * Code of first day of week for the given country/region code:\n * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.\n * @alias module:full.getWeekStartByRegion\n * @see module:api.getWeekStartByRegion\n */\nexport function getWeekStartByRegion(regionCode) {\n return api.getWeekStartByRegion(regionCode, regionDayMap);\n}\n\n/**\n * Return first day of week for locale identifier.\n *\n * Based on data from:\n * - [http://www.unicode.org/cldr/charts/28/supplemental/territory_language_information.html](http://www.unicode.org/cldr/charts/28/supplemental/territory_language_information.html)\n * - [http://www.unicode.org/cldr/charts/28/supplemental/language_territory_information.html](http://www.unicode.org/cldr/charts/28/supplemental/language_territory_information.html)\n * - [http://www.unicode.org/cldr/charts/28/supplemental/territory_information.html](http://www.unicode.org/cldr/charts/28/supplemental/territory_information.html)\n * - [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers)\n *\n * @example\n * getWeekStartByLocale('no'); // 1\n * getWeekStartByLocale('PA_arab'); // 0\n * getWeekStartByLocale('fr-DZ'); // 6\n *\n * @param {string} locale\n * Locale identifier.\n * @return {number}\n * Code of first day of week for the given locale identifier:\n * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.\n * @alias module:full.getWeekStartByLocale\n * @see module:api.getWeekStartByLocale\n */\nexport function getWeekStartByLocale(locale) {\n return api.getWeekStartByLocale(locale, langRegionMap, regionDayMap);\n}\n"],"names":["getWeekStartByRegion","api.getWeekStartByRegion","getWeekStartByLocale","api.getWeekStartByLocale"],"mappings":";;;;AAuCO,SAASA,uBAAqB,YAAY;IAC7C,OAAOC,oBAAA,CAAyB,YAAY;;;AAyBhD,AAAO,SAASC,uBAAqB,QAAQ;IACzC,OAAOC,oBAAA,CAAyB,QAAQ,eAAe;;;;;"} -------------------------------------------------------------------------------- /dist/es-module/fullLangRegionMap.js: -------------------------------------------------------------------------------- 1 | var langRegionMap = { 2 | en: 'US', 3 | hi: 'IN', 4 | deva: 'IN', 5 | te: 'IN', 6 | mr: 'IN', 7 | ta: 'IN', 8 | gu: 'IN', 9 | kn: 'IN', 10 | or: 'IN', 11 | ml: 'IN', 12 | pa: 'IN', 13 | bho: 'IN', 14 | awa: 'IN', 15 | as: 'IN', 16 | mwr: 'IN', 17 | mai: 'IN', 18 | mag: 'IN', 19 | bgc: 'IN', 20 | hne: 'IN', 21 | dcc: 'IN', 22 | bjj: 'IN', 23 | sat: 'IN', 24 | wtm: 'IN', 25 | ks: 'IN', 26 | kok: 'IN', 27 | gom: 'IN', 28 | swv: 'IN', 29 | lmn: 'IN', 30 | gbm: 'IN', 31 | gon: 'IN', 32 | kfy: 'IN', 33 | kru: 'IN', 34 | doi: 'IN', 35 | wbq: 'IN', 36 | sck: 'IN', 37 | xnr: 'IN', 38 | wbr: 'IN', 39 | tcy: 'IN', 40 | khn: 'IN', 41 | brx: 'IN', 42 | noe: 'IN', 43 | bhb: 'IN', 44 | mni: 'IN', 45 | raj: 'IN', 46 | hoc: 'IN', 47 | mtr: 'IN', 48 | unr: 'IN', 49 | bhi: 'IN', 50 | hoj: 'IN', 51 | kha: 'IN', 52 | kfr: 'IN', 53 | grt: 'IN', 54 | unx: 'IN', 55 | bfy: 'IN', 56 | srx: 'IN', 57 | saz: 'IN', 58 | sd_deva: 'IN', 59 | ccp: 'IN', 60 | njo: 'IN', 61 | bfq: 'IN', 62 | ria: 'IN', 63 | bpy: 'IN', 64 | bra: 'IN', 65 | lep: 'IN', 66 | sa: 'IN', 67 | kht: 'IN', 68 | bn: 'BD', 69 | beng: 'BD', 70 | rkt: 'BD', 71 | syl: 'BD', 72 | mro: 'BD', 73 | kgp: 'BR', 74 | gub: 'BR', 75 | yrl: 'BR', 76 | xav: 'BR', 77 | dz: 'BT', 78 | tibt: 'BT', 79 | tsj: 'BT', 80 | tn: 'BW', 81 | pdt: 'CA', 82 | crk: 'CA', 83 | cr: 'CA', 84 | iu: 'CA', 85 | oj: 'CA', 86 | ojs: 'CA', 87 | moe: 'CA', 88 | mic: 'CA', 89 | bla: 'CA', 90 | crj: 'CA', 91 | atj: 'CA', 92 | crl: 'CA', 93 | csw: 'CA', 94 | crm: 'CA', 95 | ikt: 'CA', 96 | moh: 'CA', 97 | dgr: 'CA', 98 | den: 'CA', 99 | clc: 'CA', 100 | hur: 'CA', 101 | crg: 'CA', 102 | lil: 'CA', 103 | oka: 'CA', 104 | pqm: 'CA', 105 | kwk: 'CA', 106 | nsk: 'CA', 107 | chp: 'CA', 108 | gwi: 'CA', 109 | guc: 'CO', 110 | am: 'ET', 111 | ethi: 'ET', 112 | om: 'ET', 113 | ti: 'ET', 114 | sid: 'ET', 115 | wal: 'ET', 116 | aa: 'ET', 117 | quc: 'GT', 118 | ch: 'GU', 119 | id: 'ID', 120 | jv: 'ID', 121 | su: 'ID', 122 | mad: 'ID', 123 | ms_arab: 'ID', 124 | min: 'ID', 125 | bew: 'ID', 126 | ban: 'ID', 127 | bug: 'ID', 128 | bjn: 'ID', 129 | ace: 'ID', 130 | sas: 'ID', 131 | bbc: 'ID', 132 | mak: 'ID', 133 | ljp: 'ID', 134 | rej: 'ID', 135 | gor: 'ID', 136 | nij: 'ID', 137 | kge: 'ID', 138 | aoz: 'ID', 139 | kvr: 'ID', 140 | lbw: 'ID', 141 | gay: 'ID', 142 | rob: 'ID', 143 | sxn: 'ID', 144 | mdr: 'ID', 145 | sly: 'ID', 146 | mwv: 'ID', 147 | he: 'IL', 148 | hebr: 'IL', 149 | lad: 'IL', 150 | jam: 'JM', 151 | ja: 'JP', 152 | jpan: 'JP', 153 | ryu: 'JP', 154 | ki: 'KE', 155 | luy: 'KE', 156 | luo: 'KE', 157 | kln: 'KE', 158 | kam: 'KE', 159 | guz: 'KE', 160 | mer: 'KE', 161 | ebu: 'KE', 162 | dav: 'KE', 163 | pko: 'KE', 164 | saq: 'KE', 165 | km: 'KH', 166 | khmr: 'KH', 167 | cja: 'KH', 168 | ko: 'KR', 169 | kore: 'KR', 170 | lo: 'LA', 171 | laoo: 'LA', 172 | kjg: 'LA', 173 | hnj: 'LA', 174 | mh: 'MH', 175 | my: 'MM', 176 | mymr: 'MM', 177 | shn: 'MM', 178 | kac: 'MM', 179 | rhg: 'MM', 180 | mnw: 'MM', 181 | mt: 'MT', 182 | yua: 'MX', 183 | nhe: 'MX', 184 | nhw: 'MX', 185 | maz: 'MX', 186 | nch: 'MX', 187 | sei: 'MX', 188 | vmw: 'MZ', 189 | ndc: 'MZ', 190 | ngl: 'MZ', 191 | seh: 'MZ', 192 | mgh: 'MZ', 193 | rng: 'MZ', 194 | yao: 'MZ', 195 | ne: 'NP', 196 | 'new': 'NP', 197 | jml: 'NP', 198 | dty: 'NP', 199 | taj: 'NP', 200 | thl: 'NP', 201 | bap: 'NP', 202 | tdg: 'NP', 203 | thr: 'NP', 204 | mgp: 'NP', 205 | lif: 'NP', 206 | thq: 'NP', 207 | mrd: 'NP', 208 | xsr: 'NP', 209 | rjs: 'NP', 210 | tsf: 'NP', 211 | ggn: 'NP', 212 | gvr: 'NP', 213 | tkt: 'NP', 214 | tdh: 'NP', 215 | unr_deva: 'NP', 216 | qu: 'PE', 217 | fil: 'PH', 218 | ceb: 'PH', 219 | ilo: 'PH', 220 | hil: 'PH', 221 | bik: 'PH', 222 | war: 'PH', 223 | fbl: 'PH', 224 | pam: 'PH', 225 | pag: 'PH', 226 | mdh: 'PH', 227 | tsg: 'PH', 228 | cps: 'PH', 229 | krj: 'PH', 230 | bto: 'PH', 231 | hnn: 'PH', 232 | tbw: 'PH', 233 | bku: 'PH', 234 | ur: 'PK', 235 | pa_arab: 'PK', 236 | lah: 'PK', 237 | ps: 'PK', 238 | sd: 'PK', 239 | skr: 'PK', 240 | bal: 'PK', 241 | brh: 'PK', 242 | hno: 'PK', 243 | bgn: 'PK', 244 | hnd: 'PK', 245 | tg_arab: 'PK', 246 | gju: 'PK', 247 | bft: 'PK', 248 | kvx: 'PK', 249 | khw: 'PK', 250 | mvy: 'PK', 251 | kxp: 'PK', 252 | gjk: 'PK', 253 | trw: 'PK', 254 | btv: 'PK', 255 | gn: 'PY', 256 | th: 'TH', 257 | thai: 'TH', 258 | tts: 'TH', 259 | nod: 'TH', 260 | sou: 'TH', 261 | mfa: 'TH', 262 | kxm: 'TH', 263 | kdt: 'TH', 264 | lwl: 'TH', 265 | zh_hant: 'TW', 266 | hant: 'TW', 267 | trv: 'TW', 268 | nv: 'US', 269 | pdc: 'US', 270 | haw: 'US', 271 | frc: 'US', 272 | chr: 'US', 273 | esu: 'US', 274 | dak: 'US', 275 | cho: 'US', 276 | lkt: 'US', 277 | ik: 'US', 278 | mus: 'US', 279 | sm: 'WS', 280 | zu: 'ZA', 281 | xh: 'ZA', 282 | af: 'ZA', 283 | nso: 'ZA', 284 | ts: 'ZA', 285 | ve: 'ZA', 286 | nr: 'ZA', 287 | sn: 'ZW', 288 | nd: 'ZW', 289 | mxc: 'ZW', 290 | kck: 'ZW', 291 | haz: 'AF', 292 | uz_arab: 'AF', 293 | prd: 'AF', 294 | arq: 'DZ', 295 | kab: 'DZ', 296 | ar: 'EG', 297 | arab: 'EG', 298 | arz: 'EG', 299 | ckb: 'IQ', 300 | syr: 'IQ', 301 | fa: 'IR', 302 | az_arab: 'IR', 303 | mzn: 'IR', 304 | glk: 'IR', 305 | sdh: 'IR', 306 | lrc: 'IR', 307 | rmt: 'IR', 308 | bqi: 'IR', 309 | luz: 'IR', 310 | lki: 'IR', 311 | gbz: 'IR', 312 | bej: 'SD', 313 | fvr: 'SD', 314 | mls: 'SD', 315 | fia: 'SD', 316 | zag: 'SD', 317 | dv: 'MV', 318 | thaa: 'MV' 319 | }; 320 | 321 | export default langRegionMap; 322 | //# sourceMappingURL=fullLangRegionMap.js.map 323 | -------------------------------------------------------------------------------- /dist/es-module/langRegionMap.js: -------------------------------------------------------------------------------- 1 | var langRegionMap = { 2 | en: 'US', 3 | hi: 'IN', 4 | deva: 'IN', 5 | te: 'IN', 6 | mr: 'IN', 7 | ta: 'IN', 8 | gu: 'IN', 9 | kn: 'IN', 10 | or: 'IN', 11 | ml: 'IN', 12 | pa: 'IN', 13 | bho: 'IN', 14 | awa: 'IN', 15 | as: 'IN', 16 | mwr: 'IN', 17 | mai: 'IN', 18 | mag: 'IN', 19 | bgc: 'IN', 20 | hne: 'IN', 21 | dcc: 'IN', 22 | bn: 'BD', 23 | beng: 'BD', 24 | rkt: 'BD', 25 | dz: 'BT', 26 | tibt: 'BT', 27 | tn: 'BW', 28 | am: 'ET', 29 | ethi: 'ET', 30 | om: 'ET', 31 | quc: 'GT', 32 | id: 'ID', 33 | jv: 'ID', 34 | su: 'ID', 35 | mad: 'ID', 36 | ms_arab: 'ID', 37 | he: 'IL', 38 | hebr: 'IL', 39 | jam: 'JM', 40 | ja: 'JP', 41 | jpan: 'JP', 42 | km: 'KH', 43 | khmr: 'KH', 44 | ko: 'KR', 45 | kore: 'KR', 46 | lo: 'LA', 47 | laoo: 'LA', 48 | mh: 'MH', 49 | my: 'MM', 50 | mymr: 'MM', 51 | mt: 'MT', 52 | ne: 'NP', 53 | fil: 'PH', 54 | ceb: 'PH', 55 | ilo: 'PH', 56 | ur: 'PK', 57 | pa_arab: 'PK', 58 | lah: 'PK', 59 | ps: 'PK', 60 | sd: 'PK', 61 | skr: 'PK', 62 | gn: 'PY', 63 | th: 'TH', 64 | thai: 'TH', 65 | tts: 'TH', 66 | zh_hant: 'TW', 67 | hant: 'TW', 68 | sm: 'WS', 69 | zu: 'ZA', 70 | sn: 'ZW', 71 | arq: 'DZ', 72 | ar: 'EG', 73 | arab: 'EG', 74 | arz: 'EG', 75 | fa: 'IR', 76 | az_arab: 'IR', 77 | dv: 'MV', 78 | thaa: 'MV' 79 | }; 80 | 81 | export default langRegionMap; 82 | //# sourceMappingURL=langRegionMap.js.map 83 | -------------------------------------------------------------------------------- /dist/es-module/langRegionMap.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"langRegionMap.js","sources":["../../src/langRegionMap.js"],"sourcesContent":["/**\n * Contains base mapping of language code to country code.\n * Contains data only for countries which first day of week is not monday,\n * and mainly for languages approximately having more than 10 mln speakers.\n *\n * Based on data from `fullLangRegionMap.js`.\n * \n * @module langRegionMap\n */\n\n\n/* eslint-disable camelcase */\n/**\n * Base mapping of language code to country code.\n * Contains data only for countries which first day of week is not monday,\n * and mainly for languages approximately having more than 10 mln speakers.\n *\n * Based on data from `fullLangRegionMap.js`.\n */\nconst langRegionMap = {\n en: 'US',\n \n hi: 'IN',\n deva: 'IN', // script\n te: 'IN',\n mr: 'IN',\n ta: 'IN',\n gu: 'IN',\n kn: 'IN',\n or: 'IN',\n ml: 'IN',\n pa: 'IN',\n bho: 'IN',\n awa: 'IN',\n as: 'IN',\n mwr: 'IN',\n mai: 'IN',\n mag: 'IN',\n bgc: 'IN',\n hne: 'IN',\n dcc: 'IN',\n\n bn: 'BD',\n beng: 'BD', // script\n rkt: 'BD',\n\n dz: 'BT',\n tibt: 'BT', // script\n\n tn: 'BW',\n\n am: 'ET',\n ethi: 'ET', // script\n om: 'ET',\n\n quc: 'GT',\n\n id: 'ID',\n jv: 'ID',\n su: 'ID',\n mad: 'ID',\n ms_arab: 'ID',\n\n he: 'IL',\n hebr: 'IL', // script\n\n jam: 'JM',\n\n ja: 'JP',\n jpan: 'JP', // script\n\n km: 'KH',\n khmr: 'KH', // script\n\n ko: 'KR',\n kore: 'KR', // script\n\n lo: 'LA',\n laoo: 'LA', // script\n\n mh: 'MH',\n\n my: 'MM',\n mymr: 'MM', // script\n\n mt: 'MT',\n\n ne: 'NP',\n\n fil: 'PH',\n ceb: 'PH',\n ilo: 'PH',\n\n ur: 'PK',\n pa_arab: 'PK',\n lah: 'PK',\n ps: 'PK',\n sd: 'PK',\n skr: 'PK',\n\n gn: 'PY',\n\n th: 'TH',\n thai: 'TH', // script\n tts: 'TH',\n\n zh_hant: 'TW',\n hant: 'TW', // script\n\n sm: 'WS',\n \n zu: 'ZA',\n\n sn: 'ZW',\n\n\n arq: 'DZ',\n\n ar: 'EG',\n arab: 'EG', // script\n arz: 'EG',\n\n fa: 'IR',\n az_arab: 'IR',\n\n\n dv: 'MV',\n thaa: 'MV' // script\n};\n/* eslint-enable camelcase */\n\nexport default langRegionMap;\n"],"names":["const"],"mappings":"AAmBAA,IAAM,gBAAgB;IAClB,IAAI,IADc;IAGlB,IAAI,IAHc;IAIlB,MAAM,IAJY;IAKlB,IAAI,IALc;IAMlB,IAAI,IANc;IAOlB,IAAI,IAPc;IAQlB,IAAI,IARc;IASlB,IAAI,IATc;IAUlB,IAAI,IAVc;IAWlB,IAAI,IAXc;IAYlB,IAAI,IAZc;IAalB,KAAK,IAba;IAclB,KAAK,IAda;IAelB,IAAI,IAfc;IAgBlB,KAAK,IAhBa;IAiBlB,KAAK,IAjBa;IAkBlB,KAAK,IAlBa;IAmBlB,KAAK,IAnBa;IAoBlB,KAAK,IApBa;IAqBlB,KAAK,IArBa;IAuBlB,IAAI,IAvBc;IAwBlB,MAAM,IAxBY;IAyBlB,KAAK,IAzBa;IA2BlB,IAAI,IA3Bc;IA4BlB,MAAM,IA5BY;IA8BlB,IAAI,IA9Bc;IAgClB,IAAI,IAhCc;IAiClB,MAAM,IAjCY;IAkClB,IAAI,IAlCc;IAoClB,KAAK,IApCa;IAsClB,IAAI,IAtCc;IAuClB,IAAI,IAvCc;IAwClB,IAAI,IAxCc;IAyClB,KAAK,IAzCa;IA0ClB,SAAS,IA1CS;IA4ClB,IAAI,IA5Cc;IA6ClB,MAAM,IA7CY;IA+ClB,KAAK,IA/Ca;IAiDlB,IAAI,IAjDc;IAkDlB,MAAM,IAlDY;IAoDlB,IAAI,IApDc;IAqDlB,MAAM,IArDY;IAuDlB,IAAI,IAvDc;IAwDlB,MAAM,IAxDY;IA0DlB,IAAI,IA1Dc;IA2DlB,MAAM,IA3DY;IA6DlB,IAAI,IA7Dc;IA+DlB,IAAI,IA/Dc;IAgElB,MAAM,IAhEY;IAkElB,IAAI,IAlEc;IAoElB,IAAI,IApEc;IAsElB,KAAK,IAtEa;IAuElB,KAAK,IAvEa;IAwElB,KAAK,IAxEa;IA0ElB,IAAI,IA1Ec;IA2ElB,SAAS,IA3ES;IA4ElB,KAAK,IA5Ea;IA6ElB,IAAI,IA7Ec;IA8ElB,IAAI,IA9Ec;IA+ElB,KAAK,IA/Ea;IAiFlB,IAAI,IAjFc;IAmFlB,IAAI,IAnFc;IAoFlB,MAAM,IApFY;IAqFlB,KAAK,IArFa;IAuFlB,SAAS,IAvFS;IAwFlB,MAAM,IAxFY;IA0FlB,IAAI,IA1Fc;IA4FlB,IAAI,IA5Fc;IA8FlB,IAAI,IA9Fc;IAiGlB,KAAK,IAjGa;IAmGlB,IAAI,IAnGc;IAoGlB,MAAM,IApGY;IAqGlB,KAAK,IArGa;IAuGlB,IAAI,IAvGc;IAwGlB,SAAS,IAxGS;IA2GlB,IAAI,IA3Gc;IA4GlB,MAAM;;;;;"} -------------------------------------------------------------------------------- /dist/es-module/main.js: -------------------------------------------------------------------------------- 1 | import { getWeekStartByRegion, getWeekStartByLocale } from './api.js'; 2 | import langRegionMap from './langRegionMap.js'; 3 | import regionDayMap from './regionDayMap.js'; 4 | 5 | function getWeekStartByRegion$1(regionCode) { 6 | return getWeekStartByRegion(regionCode, regionDayMap); 7 | } 8 | 9 | function getWeekStartByLocale$1(locale) { 10 | return getWeekStartByLocale(locale, langRegionMap, regionDayMap); 11 | } 12 | 13 | export { getWeekStartByRegion$1 as getWeekStartByRegion, getWeekStartByLocale$1 as getWeekStartByLocale }; 14 | //# sourceMappingURL=main.js.map 15 | -------------------------------------------------------------------------------- /dist/es-module/main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"main.js","sources":["../../src/main.js"],"sourcesContent":["/*\n * weekstart\n * https://github.com/gamtiq/weekstart\n */\n\n/**\n * Library to get first day of week.\n * \n * Uses data from {@link module:langRegionMap langRegionMap.js} and\n * {@link module:regionDayMap regionDayMap.js}.\n * \n * @module main\n */\n\nimport * as api from './api';\nimport langRegionMap from './langRegionMap';\nimport regionDayMap from './regionDayMap';\n\n/**\n * Return first day of week for country/region code.\n *\n * Based on data from:\n * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)\n * - [https://github.com/unicode-org/cldr-json/blob/main/cldr-json/cldr-core/supplemental/weekData.json](https://github.com/unicode-org/cldr-json/blob/main/cldr-json/cldr-core/supplemental/weekData.json)\n * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html)\n *\n * @example\n * getWeekStartByRegion('PNG'); // 1\n * getWeekStartByRegion('qa'); // 6\n * getWeekStartByRegion(462); // 5\n *\n * @param {number | string} regionCode\n * ISO 3166 Alpha-2, Alpha-3 or numeric code.\n * @return {number}\n * Code of first day of week for the given country/region code:\n * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.\n * @alias module:main.getWeekStartByRegion\n * @see module:api.getWeekStartByRegion\n */\nexport function getWeekStartByRegion(regionCode) {\n return api.getWeekStartByRegion(regionCode, regionDayMap);\n}\n\n/**\n * Return first day of week for locale identifier.\n *\n * Based on data from:\n * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html)\n * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html)\n * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)\n * - [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers)\n *\n * @example\n * getWeekStartByLocale('no'); // 1\n * getWeekStartByLocale('Pa_Guru'); // 0\n * getWeekStartByLocale('fr-DZ'); // 6\n *\n * @param {string} locale\n * Locale identifier.\n * @return {number}\n * Code of first day of week for the given locale identifier:\n * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.\n * @alias module:main.getWeekStartByLocale\n * @see module:api.getWeekStartByLocale\n */\nexport function getWeekStartByLocale(locale) {\n return api.getWeekStartByLocale(locale, langRegionMap, regionDayMap);\n}\n"],"names":["getWeekStartByRegion","api.getWeekStartByRegion","getWeekStartByLocale","api.getWeekStartByLocale"],"mappings":";;;;AAuCO,SAASA,uBAAqB,YAAY;IAC7C,OAAOC,oBAAA,CAAyB,YAAY;;;AAyBhD,AAAO,SAASC,uBAAqB,QAAQ;IACzC,OAAOC,oBAAA,CAAyB,QAAQ,eAAe;;;;;"} -------------------------------------------------------------------------------- /dist/es-module/regionDayMap.js: -------------------------------------------------------------------------------- 1 | var regionDayMap = { 2 | AG: 0, 3 | ATG: 0, 4 | 28: 0, 5 | AS: 0, 6 | ASM: 0, 7 | 16: 0, 8 | BD: 0, 9 | BGD: 0, 10 | 50: 0, 11 | BR: 0, 12 | BRA: 0, 13 | 76: 0, 14 | BS: 0, 15 | BHS: 0, 16 | 44: 0, 17 | BT: 0, 18 | BTN: 0, 19 | 64: 0, 20 | BW: 0, 21 | BWA: 0, 22 | 72: 0, 23 | BZ: 0, 24 | BLZ: 0, 25 | 84: 0, 26 | CA: 0, 27 | CAN: 0, 28 | 124: 0, 29 | CO: 0, 30 | COL: 0, 31 | 170: 0, 32 | DM: 0, 33 | DMA: 0, 34 | 212: 0, 35 | DO: 0, 36 | DOM: 0, 37 | 214: 0, 38 | ET: 0, 39 | ETH: 0, 40 | 231: 0, 41 | GT: 0, 42 | GTM: 0, 43 | 320: 0, 44 | GU: 0, 45 | GUM: 0, 46 | 316: 0, 47 | HK: 0, 48 | HKG: 0, 49 | 344: 0, 50 | HN: 0, 51 | HND: 0, 52 | 340: 0, 53 | ID: 0, 54 | IDN: 0, 55 | 360: 0, 56 | IL: 0, 57 | ISR: 0, 58 | 376: 0, 59 | IN: 0, 60 | IND: 0, 61 | 356: 0, 62 | JM: 0, 63 | JAM: 0, 64 | 388: 0, 65 | JP: 0, 66 | JPN: 0, 67 | 392: 0, 68 | KE: 0, 69 | KEN: 0, 70 | 404: 0, 71 | KH: 0, 72 | KHM: 0, 73 | 116: 0, 74 | KR: 0, 75 | KOR: 0, 76 | 410: 0, 77 | LA: 0, 78 | LA0: 0, 79 | 418: 0, 80 | MH: 0, 81 | MHL: 0, 82 | 584: 0, 83 | MM: 0, 84 | MMR: 0, 85 | 104: 0, 86 | MO: 0, 87 | MAC: 0, 88 | 446: 0, 89 | MT: 0, 90 | MLT: 0, 91 | 470: 0, 92 | MX: 0, 93 | MEX: 0, 94 | 484: 0, 95 | MZ: 0, 96 | MOZ: 0, 97 | 508: 0, 98 | NI: 0, 99 | NIC: 0, 100 | 558: 0, 101 | NP: 0, 102 | NPL: 0, 103 | 524: 0, 104 | PA: 0, 105 | PAN: 0, 106 | 591: 0, 107 | PE: 0, 108 | PER: 0, 109 | 604: 0, 110 | PH: 0, 111 | PHL: 0, 112 | 608: 0, 113 | PK: 0, 114 | PAK: 0, 115 | 586: 0, 116 | PR: 0, 117 | PRI: 0, 118 | 630: 0, 119 | PT: 0, 120 | PRT: 0, 121 | 620: 0, 122 | PY: 0, 123 | PRY: 0, 124 | 600: 0, 125 | SA: 0, 126 | SAU: 0, 127 | 682: 0, 128 | SG: 0, 129 | SGP: 0, 130 | 702: 0, 131 | SV: 0, 132 | SLV: 0, 133 | 222: 0, 134 | TH: 0, 135 | THA: 0, 136 | 764: 0, 137 | TT: 0, 138 | TTO: 0, 139 | 780: 0, 140 | TW: 0, 141 | TWN: 0, 142 | 158: 0, 143 | UM: 0, 144 | UMI: 0, 145 | 581: 0, 146 | US: 0, 147 | USA: 0, 148 | 840: 0, 149 | VE: 0, 150 | VEN: 0, 151 | 862: 0, 152 | VI: 0, 153 | VIR: 0, 154 | 850: 0, 155 | WS: 0, 156 | WSM: 0, 157 | 882: 0, 158 | YE: 0, 159 | YEM: 0, 160 | 887: 0, 161 | ZA: 0, 162 | ZAF: 0, 163 | 710: 0, 164 | ZW: 0, 165 | ZWE: 0, 166 | 716: 0, 167 | AE: 6, 168 | ARE: 6, 169 | 784: 6, 170 | AF: 6, 171 | AFG: 6, 172 | 4: 6, 173 | BH: 6, 174 | BHR: 6, 175 | 48: 6, 176 | DJ: 6, 177 | DJI: 6, 178 | 262: 6, 179 | DZ: 6, 180 | DZA: 6, 181 | 12: 6, 182 | EG: 6, 183 | EGY: 6, 184 | 818: 6, 185 | IQ: 6, 186 | IRQ: 6, 187 | 368: 6, 188 | IR: 6, 189 | IRN: 6, 190 | 364: 6, 191 | JO: 6, 192 | JOR: 6, 193 | 400: 6, 194 | KW: 6, 195 | KWT: 6, 196 | 414: 6, 197 | LY: 6, 198 | LBY: 6, 199 | 434: 6, 200 | OM: 6, 201 | OMN: 6, 202 | 512: 6, 203 | QA: 6, 204 | QAT: 6, 205 | 634: 6, 206 | SD: 6, 207 | SDN: 6, 208 | 729: 6, 209 | SY: 6, 210 | SYR: 6, 211 | 760: 6, 212 | MV: 5, 213 | MDV: 5, 214 | 462: 5 215 | }; 216 | 217 | export default regionDayMap; 218 | //# sourceMappingURL=regionDayMap.js.map 219 | -------------------------------------------------------------------------------- /dist/es-module/regionDayMap.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"regionDayMap.js","sources":["../../src/regionDayMap.js"],"sourcesContent":["/**\n * Contains data about first day of week depending on country code.\n * \n * @module regionDayMap\n */\n\n\n/* eslint quote-props: ['error', 'as-needed', {'keywords': true, 'numbers': false, 'unnecessary': false}] */\n/**\n * Data about first day of week depending on country code.\n * Based on:\n * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)\n * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html)\n */\nconst regionDayMap = {\n // Sunday\n AG: 0,\n ATG: 0,\n 28: 0,\n AS: 0,\n ASM: 0,\n 16: 0,\n BD: 0,\n BGD: 0,\n 50: 0,\n BR: 0,\n BRA: 0,\n 76: 0,\n BS: 0,\n BHS: 0,\n 44: 0,\n BT: 0,\n BTN: 0,\n 64: 0,\n BW: 0,\n BWA: 0,\n 72: 0,\n BZ: 0,\n BLZ: 0,\n 84: 0,\n CA: 0,\n CAN: 0,\n 124: 0,\n CO: 0,\n COL: 0,\n 170: 0,\n DM: 0,\n DMA: 0,\n 212: 0,\n DO: 0,\n DOM: 0,\n 214: 0,\n ET: 0,\n ETH: 0,\n 231: 0,\n GT: 0,\n GTM: 0,\n 320: 0,\n GU: 0,\n GUM: 0,\n 316: 0,\n HK: 0,\n HKG: 0,\n 344: 0,\n HN: 0,\n HND: 0,\n 340: 0,\n ID: 0,\n IDN: 0,\n 360: 0,\n IL: 0,\n ISR: 0,\n 376: 0,\n IN: 0,\n IND: 0,\n 356: 0,\n JM: 0,\n JAM: 0,\n 388: 0,\n JP: 0,\n JPN: 0,\n 392: 0,\n KE: 0,\n KEN: 0,\n 404: 0,\n KH: 0,\n KHM: 0,\n 116: 0,\n KR: 0,\n KOR: 0,\n 410: 0,\n LA: 0,\n LA0: 0,\n 418: 0,\n MH: 0,\n MHL: 0,\n 584: 0,\n MM: 0,\n MMR: 0,\n 104: 0,\n MO: 0,\n MAC: 0,\n 446: 0,\n MT: 0,\n MLT: 0,\n 470: 0,\n MX: 0,\n MEX: 0,\n 484: 0,\n MZ: 0,\n MOZ: 0,\n 508: 0,\n NI: 0,\n NIC: 0,\n 558: 0,\n NP: 0,\n NPL: 0,\n 524: 0,\n PA: 0,\n PAN: 0,\n 591: 0,\n PE: 0,\n PER: 0,\n 604: 0,\n PH: 0,\n PHL: 0,\n 608: 0,\n PK: 0,\n PAK: 0,\n 586: 0,\n PR: 0,\n PRI: 0,\n 630: 0,\n PT: 0,\n PRT: 0,\n 620: 0,\n PY: 0,\n PRY: 0,\n 600: 0,\n SA: 0,\n SAU: 0,\n 682: 0,\n SG: 0,\n SGP: 0,\n 702: 0,\n SV: 0,\n SLV: 0,\n 222: 0,\n TH: 0,\n THA: 0,\n 764: 0,\n TT: 0,\n TTO: 0,\n 780: 0,\n TW: 0,\n TWN: 0,\n 158: 0,\n UM: 0,\n UMI: 0,\n 581: 0,\n US: 0,\n USA: 0,\n 840: 0,\n VE: 0,\n VEN: 0,\n 862: 0,\n VI: 0,\n VIR: 0,\n 850: 0,\n WS: 0,\n WSM: 0,\n 882: 0,\n YE: 0,\n YEM: 0,\n 887: 0,\n ZA: 0,\n ZAF: 0,\n 710: 0,\n ZW: 0,\n ZWE: 0,\n 716: 0,\n\n // Saturday\n AE: 6,\n ARE: 6,\n 784: 6,\n AF: 6,\n AFG: 6,\n 4: 6,\n BH: 6,\n BHR: 6,\n 48: 6,\n DJ: 6,\n DJI: 6,\n 262: 6,\n DZ: 6,\n DZA: 6,\n 12: 6,\n EG: 6,\n EGY: 6,\n 818: 6,\n IQ: 6,\n IRQ: 6,\n 368: 6,\n IR: 6,\n IRN: 6,\n 364: 6,\n JO: 6,\n JOR: 6,\n 400: 6,\n KW: 6,\n KWT: 6,\n 414: 6,\n LY: 6,\n LBY: 6,\n 434: 6,\n OM: 6,\n OMN: 6,\n 512: 6,\n QA: 6,\n QAT: 6,\n 634: 6,\n SD: 6,\n SDN: 6,\n 729: 6,\n SY: 6,\n SYR: 6,\n 760: 6,\n\n // Friday\n MV: 5,\n MDV: 5,\n 462: 5\n\n // Else - Monday\n};\n\nexport default regionDayMap;\n"],"names":["const"],"mappings":"AAcAA,IAAM,eAAe;IAEjB,IAAI,CAFa;IAGjB,KAAK,CAHY;IAIjB,IAAI,CAJa;IAKjB,IAAI,CALa;IAMjB,KAAK,CANY;IAOjB,IAAI,CAPa;IAQjB,IAAI,CARa;IASjB,KAAK,CATY;IAUjB,IAAI,CAVa;IAWjB,IAAI,CAXa;IAYjB,KAAK,CAZY;IAajB,IAAI,CAba;IAcjB,IAAI,CAda;IAejB,KAAK,CAfY;IAgBjB,IAAI,CAhBa;IAiBjB,IAAI,CAjBa;IAkBjB,KAAK,CAlBY;IAmBjB,IAAI,CAnBa;IAoBjB,IAAI,CApBa;IAqBjB,KAAK,CArBY;IAsBjB,IAAI,CAtBa;IAuBjB,IAAI,CAvBa;IAwBjB,KAAK,CAxBY;IAyBjB,IAAI,CAzBa;IA0BjB,IAAI,CA1Ba;IA2BjB,KAAK,CA3BY;IA4BjB,KAAK,CA5BY;IA6BjB,IAAI,CA7Ba;IA8BjB,KAAK,CA9BY;IA+BjB,KAAK,CA/BY;IAgCjB,IAAI,CAhCa;IAiCjB,KAAK,CAjCY;IAkCjB,KAAK,CAlCY;IAmCjB,IAAI,CAnCa;IAoCjB,KAAK,CApCY;IAqCjB,KAAK,CArCY;IAsCjB,IAAI,CAtCa;IAuCjB,KAAK,CAvCY;IAwCjB,KAAK,CAxCY;IAyCjB,IAAI,CAzCa;IA0CjB,KAAK,CA1CY;IA2CjB,KAAK,CA3CY;IA4CjB,IAAI,CA5Ca;IA6CjB,KAAK,CA7CY;IA8CjB,KAAK,CA9CY;IA+CjB,IAAI,CA/Ca;IAgDjB,KAAK,CAhDY;IAiDjB,KAAK,CAjDY;IAkDjB,IAAI,CAlDa;IAmDjB,KAAK,CAnDY;IAoDjB,KAAK,CApDY;IAqDjB,IAAI,CArDa;IAsDjB,KAAK,CAtDY;IAuDjB,KAAK,CAvDY;IAwDjB,IAAI,CAxDa;IAyDjB,KAAK,CAzDY;IA0DjB,KAAK,CA1DY;IA2DjB,IAAI,CA3Da;IA4DjB,KAAK,CA5DY;IA6DjB,KAAK,CA7DY;IA8DjB,IAAI,CA9Da;IA+DjB,KAAK,CA/DY;IAgEjB,KAAK,CAhEY;IAiEjB,IAAI,CAjEa;IAkEjB,KAAK,CAlEY;IAmEjB,KAAK,CAnEY;IAoEjB,IAAI,CApEa;IAqEjB,KAAK,CArEY;IAsEjB,KAAK,CAtEY;IAuEjB,IAAI,CAvEa;IAwEjB,KAAK,CAxEY;IAyEjB,KAAK,CAzEY;IA0EjB,IAAI,CA1Ea;IA2EjB,KAAK,CA3EY;IA4EjB,KAAK,CA5EY;IA6EjB,IAAI,CA7Ea;IA8EjB,KAAK,CA9EY;IA+EjB,KAAK,CA/EY;IAgFjB,IAAI,CAhFa;IAiFjB,KAAK,CAjFY;IAkFjB,KAAK,CAlFY;IAmFjB,IAAI,CAnFa;IAoFjB,KAAK,CApFY;IAqFjB,KAAK,CArFY;IAsFjB,IAAI,CAtFa;IAuFjB,KAAK,CAvFY;IAwFjB,KAAK,CAxFY;IAyFjB,IAAI,CAzFa;IA0FjB,KAAK,CA1FY;IA2FjB,KAAK,CA3FY;IA4FjB,IAAI,CA5Fa;IA6FjB,KAAK,CA7FY;IA8FjB,KAAK,CA9FY;IA+FjB,IAAI,CA/Fa;IAgGjB,KAAK,CAhGY;IAiGjB,KAAK,CAjGY;IAkGjB,IAAI,CAlGa;IAmGjB,KAAK,CAnGY;IAoGjB,KAAK,CApGY;IAqGjB,IAAI,CArGa;IAsGjB,KAAK,CAtGY;IAuGjB,KAAK,CAvGY;IAwGjB,IAAI,CAxGa;IAyGjB,KAAK,CAzGY;IA0GjB,KAAK,CA1GY;IA2GjB,IAAI,CA3Ga;IA4GjB,KAAK,CA5GY;IA6GjB,KAAK,CA7GY;IA8GjB,IAAI,CA9Ga;IA+GjB,KAAK,CA/GY;IAgHjB,KAAK,CAhHY;IAiHjB,IAAI,CAjHa;IAkHjB,KAAK,CAlHY;IAmHjB,KAAK,CAnHY;IAoHjB,IAAI,CApHa;IAqHjB,KAAK,CArHY;IAsHjB,KAAK,CAtHY;IAuHjB,IAAI,CAvHa;IAwHjB,KAAK,CAxHY;IAyHjB,KAAK,CAzHY;IA0HjB,IAAI,CA1Ha;IA2HjB,KAAK,CA3HY;IA4HjB,KAAK,CA5HY;IA6HjB,IAAI,CA7Ha;IA8HjB,KAAK,CA9HY;IA+HjB,KAAK,CA/HY;IAgIjB,IAAI,CAhIa;IAiIjB,KAAK,CAjIY;IAkIjB,KAAK,CAlIY;IAmIjB,IAAI,CAnIa;IAoIjB,KAAK,CApIY;IAqIjB,KAAK,CArIY;IAsIjB,IAAI,CAtIa;IAuIjB,KAAK,CAvIY;IAwIjB,KAAK,CAxIY;IAyIjB,IAAI,CAzIa;IA0IjB,KAAK,CA1IY;IA2IjB,KAAK,CA3IY;IA4IjB,IAAI,CA5Ia;IA6IjB,KAAK,CA7IY;IA8IjB,KAAK,CA9IY;IA+IjB,IAAI,CA/Ia;IAgJjB,KAAK,CAhJY;IAiJjB,KAAK,CAjJY;IAkJjB,IAAI,CAlJa;IAmJjB,KAAK,CAnJY;IAoJjB,KAAK,CApJY;IAqJjB,IAAI,CArJa;IAsJjB,KAAK,CAtJY;IAuJjB,KAAK,CAvJY;IAwJjB,IAAI,CAxJa;IAyJjB,KAAK,CAzJY;IA0JjB,KAAK,CA1JY;IA2JjB,IAAI,CA3Ja;IA4JjB,KAAK,CA5JY;IA6JjB,KAAK,CA7JY;IA8JjB,IAAI,CA9Ja;IA+JjB,KAAK,CA/JY;IAgKjB,KAAK,CAhKY;IAiKjB,IAAI,CAjKa;IAkKjB,KAAK,CAlKY;IAmKjB,KAAK,CAnKY;IAoKjB,IAAI,CApKa;IAqKjB,KAAK,CArKY;IAsKjB,KAAK,CAtKY;IAyKjB,IAAI,CAzKa;IA0KjB,KAAK,CA1KY;IA2KjB,KAAK,CA3KY;IA4KjB,IAAI,CA5Ka;IA6KjB,KAAK,CA7KY;IA8KjB,GAAG,CA9Kc;IA+KjB,IAAI,CA/Ka;IAgLjB,KAAK,CAhLY;IAiLjB,IAAI,CAjLa;IAkLjB,IAAI,CAlLa;IAmLjB,KAAK,CAnLY;IAoLjB,KAAK,CApLY;IAqLjB,IAAI,CArLa;IAsLjB,KAAK,CAtLY;IAuLjB,IAAI,CAvLa;IAwLjB,IAAI,CAxLa;IAyLjB,KAAK,CAzLY;IA0LjB,KAAK,CA1LY;IA2LjB,IAAI,CA3La;IA4LjB,KAAK,CA5LY;IA6LjB,KAAK,CA7LY;IA8LjB,IAAI,CA9La;IA+LjB,KAAK,CA/LY;IAgMjB,KAAK,CAhMY;IAiMjB,IAAI,CAjMa;IAkMjB,KAAK,CAlMY;IAmMjB,KAAK,CAnMY;IAoMjB,IAAI,CApMa;IAqMjB,KAAK,CArMY;IAsMjB,KAAK,CAtMY;IAuMjB,IAAI,CAvMa;IAwMjB,KAAK,CAxMY;IAyMjB,KAAK,CAzMY;IA0MjB,IAAI,CA1Ma;IA2MjB,KAAK,CA3MY;IA4MjB,KAAK,CA5MY;IA6MjB,IAAI,CA7Ma;IA8MjB,KAAK,CA9MY;IA+MjB,KAAK,CA/MY;IAgNjB,IAAI,CAhNa;IAiNjB,KAAK,CAjNY;IAkNjB,KAAK,CAlNY;IAmNjB,IAAI,CAnNa;IAoNjB,KAAK,CApNY;IAqNjB,KAAK,CArNY;IAwNjB,IAAI,CAxNa;IAyNjB,KAAK,CAzNY;IA0NjB,KAAK;;;;;"} -------------------------------------------------------------------------------- /dist/main.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : 3 | typeof define === 'function' && define.amd ? define(['exports'], factory) : 4 | (factory((global.weekstart = {}))); 5 | }(this, (function (exports) { 'use strict'; 6 | 7 | function getWeekStartByRegion(regionCode, regionDayMap) { 8 | var code = regionDayMap[typeof regionCode === 'string' ? regionCode.toUpperCase() : regionCode]; 9 | return typeof code === 'number' ? code : 1; 10 | } 11 | 12 | function getWeekStartByLocale(locale, langRegionMap, regionDayMap) { 13 | if (locale) { 14 | var data = locale.toLowerCase().split(/[-_]/); 15 | var langTag = data[0]; 16 | var language = langTag; 17 | var country; 18 | if (data[1] && data[1].length === 4) { 19 | language += "_" + (data[1]); 20 | country = data[2]; 21 | } else { 22 | country = data[1]; 23 | } 24 | if (!country) { 25 | country = langRegionMap[language] || langRegionMap[langTag]; 26 | } 27 | if (country) { 28 | return getWeekStartByRegion(country.match(/^\d+$/) ? Number(country) : country, regionDayMap); 29 | } 30 | } 31 | return 1; 32 | } 33 | 34 | var langRegionMap = { 35 | en: 'US', 36 | hi: 'IN', 37 | deva: 'IN', 38 | te: 'IN', 39 | mr: 'IN', 40 | ta: 'IN', 41 | gu: 'IN', 42 | kn: 'IN', 43 | or: 'IN', 44 | ml: 'IN', 45 | pa: 'IN', 46 | bho: 'IN', 47 | awa: 'IN', 48 | as: 'IN', 49 | mwr: 'IN', 50 | mai: 'IN', 51 | mag: 'IN', 52 | bgc: 'IN', 53 | hne: 'IN', 54 | dcc: 'IN', 55 | bn: 'BD', 56 | beng: 'BD', 57 | rkt: 'BD', 58 | dz: 'BT', 59 | tibt: 'BT', 60 | tn: 'BW', 61 | am: 'ET', 62 | ethi: 'ET', 63 | om: 'ET', 64 | quc: 'GT', 65 | id: 'ID', 66 | jv: 'ID', 67 | su: 'ID', 68 | mad: 'ID', 69 | ms_arab: 'ID', 70 | he: 'IL', 71 | hebr: 'IL', 72 | jam: 'JM', 73 | ja: 'JP', 74 | jpan: 'JP', 75 | km: 'KH', 76 | khmr: 'KH', 77 | ko: 'KR', 78 | kore: 'KR', 79 | lo: 'LA', 80 | laoo: 'LA', 81 | mh: 'MH', 82 | my: 'MM', 83 | mymr: 'MM', 84 | mt: 'MT', 85 | ne: 'NP', 86 | fil: 'PH', 87 | ceb: 'PH', 88 | ilo: 'PH', 89 | ur: 'PK', 90 | pa_arab: 'PK', 91 | lah: 'PK', 92 | ps: 'PK', 93 | sd: 'PK', 94 | skr: 'PK', 95 | gn: 'PY', 96 | th: 'TH', 97 | thai: 'TH', 98 | tts: 'TH', 99 | zh_hant: 'TW', 100 | hant: 'TW', 101 | sm: 'WS', 102 | zu: 'ZA', 103 | sn: 'ZW', 104 | arq: 'DZ', 105 | ar: 'EG', 106 | arab: 'EG', 107 | arz: 'EG', 108 | fa: 'IR', 109 | az_arab: 'IR', 110 | dv: 'MV', 111 | thaa: 'MV' 112 | }; 113 | 114 | var regionDayMap = { 115 | AG: 0, 116 | ATG: 0, 117 | 28: 0, 118 | AS: 0, 119 | ASM: 0, 120 | 16: 0, 121 | BD: 0, 122 | BGD: 0, 123 | 50: 0, 124 | BR: 0, 125 | BRA: 0, 126 | 76: 0, 127 | BS: 0, 128 | BHS: 0, 129 | 44: 0, 130 | BT: 0, 131 | BTN: 0, 132 | 64: 0, 133 | BW: 0, 134 | BWA: 0, 135 | 72: 0, 136 | BZ: 0, 137 | BLZ: 0, 138 | 84: 0, 139 | CA: 0, 140 | CAN: 0, 141 | 124: 0, 142 | CO: 0, 143 | COL: 0, 144 | 170: 0, 145 | DM: 0, 146 | DMA: 0, 147 | 212: 0, 148 | DO: 0, 149 | DOM: 0, 150 | 214: 0, 151 | ET: 0, 152 | ETH: 0, 153 | 231: 0, 154 | GT: 0, 155 | GTM: 0, 156 | 320: 0, 157 | GU: 0, 158 | GUM: 0, 159 | 316: 0, 160 | HK: 0, 161 | HKG: 0, 162 | 344: 0, 163 | HN: 0, 164 | HND: 0, 165 | 340: 0, 166 | ID: 0, 167 | IDN: 0, 168 | 360: 0, 169 | IL: 0, 170 | ISR: 0, 171 | 376: 0, 172 | IN: 0, 173 | IND: 0, 174 | 356: 0, 175 | JM: 0, 176 | JAM: 0, 177 | 388: 0, 178 | JP: 0, 179 | JPN: 0, 180 | 392: 0, 181 | KE: 0, 182 | KEN: 0, 183 | 404: 0, 184 | KH: 0, 185 | KHM: 0, 186 | 116: 0, 187 | KR: 0, 188 | KOR: 0, 189 | 410: 0, 190 | LA: 0, 191 | LA0: 0, 192 | 418: 0, 193 | MH: 0, 194 | MHL: 0, 195 | 584: 0, 196 | MM: 0, 197 | MMR: 0, 198 | 104: 0, 199 | MO: 0, 200 | MAC: 0, 201 | 446: 0, 202 | MT: 0, 203 | MLT: 0, 204 | 470: 0, 205 | MX: 0, 206 | MEX: 0, 207 | 484: 0, 208 | MZ: 0, 209 | MOZ: 0, 210 | 508: 0, 211 | NI: 0, 212 | NIC: 0, 213 | 558: 0, 214 | NP: 0, 215 | NPL: 0, 216 | 524: 0, 217 | PA: 0, 218 | PAN: 0, 219 | 591: 0, 220 | PE: 0, 221 | PER: 0, 222 | 604: 0, 223 | PH: 0, 224 | PHL: 0, 225 | 608: 0, 226 | PK: 0, 227 | PAK: 0, 228 | 586: 0, 229 | PR: 0, 230 | PRI: 0, 231 | 630: 0, 232 | PT: 0, 233 | PRT: 0, 234 | 620: 0, 235 | PY: 0, 236 | PRY: 0, 237 | 600: 0, 238 | SA: 0, 239 | SAU: 0, 240 | 682: 0, 241 | SG: 0, 242 | SGP: 0, 243 | 702: 0, 244 | SV: 0, 245 | SLV: 0, 246 | 222: 0, 247 | TH: 0, 248 | THA: 0, 249 | 764: 0, 250 | TT: 0, 251 | TTO: 0, 252 | 780: 0, 253 | TW: 0, 254 | TWN: 0, 255 | 158: 0, 256 | UM: 0, 257 | UMI: 0, 258 | 581: 0, 259 | US: 0, 260 | USA: 0, 261 | 840: 0, 262 | VE: 0, 263 | VEN: 0, 264 | 862: 0, 265 | VI: 0, 266 | VIR: 0, 267 | 850: 0, 268 | WS: 0, 269 | WSM: 0, 270 | 882: 0, 271 | YE: 0, 272 | YEM: 0, 273 | 887: 0, 274 | ZA: 0, 275 | ZAF: 0, 276 | 710: 0, 277 | ZW: 0, 278 | ZWE: 0, 279 | 716: 0, 280 | AE: 6, 281 | ARE: 6, 282 | 784: 6, 283 | AF: 6, 284 | AFG: 6, 285 | 4: 6, 286 | BH: 6, 287 | BHR: 6, 288 | 48: 6, 289 | DJ: 6, 290 | DJI: 6, 291 | 262: 6, 292 | DZ: 6, 293 | DZA: 6, 294 | 12: 6, 295 | EG: 6, 296 | EGY: 6, 297 | 818: 6, 298 | IQ: 6, 299 | IRQ: 6, 300 | 368: 6, 301 | IR: 6, 302 | IRN: 6, 303 | 364: 6, 304 | JO: 6, 305 | JOR: 6, 306 | 400: 6, 307 | KW: 6, 308 | KWT: 6, 309 | 414: 6, 310 | LY: 6, 311 | LBY: 6, 312 | 434: 6, 313 | OM: 6, 314 | OMN: 6, 315 | 512: 6, 316 | QA: 6, 317 | QAT: 6, 318 | 634: 6, 319 | SD: 6, 320 | SDN: 6, 321 | 729: 6, 322 | SY: 6, 323 | SYR: 6, 324 | 760: 6, 325 | MV: 5, 326 | MDV: 5, 327 | 462: 5 328 | }; 329 | 330 | function getWeekStartByRegion$1(regionCode) { 331 | return getWeekStartByRegion(regionCode, regionDayMap); 332 | } 333 | 334 | function getWeekStartByLocale$1(locale) { 335 | return getWeekStartByLocale(locale, langRegionMap, regionDayMap); 336 | } 337 | 338 | exports.getWeekStartByRegion = getWeekStartByRegion$1; 339 | exports.getWeekStartByLocale = getWeekStartByLocale$1; 340 | 341 | }))); 342 | //# sourceMappingURL=main.js.map 343 | -------------------------------------------------------------------------------- /dist/min/full.js: -------------------------------------------------------------------------------- 1 | !function(I,N){"object"==typeof exports&&"undefined"!=typeof module?N(exports):"function"==typeof define&&define.amd?define(["exports"],N):N(I.weekstart={})}(this,function(I){"use strict";function N(I,N){var a=N["string"==typeof I?I.toUpperCase():I];return"number"==typeof a?a:1}var a={en:"US",hi:"IN",deva:"IN",te:"IN",mr:"IN",ta:"IN",gu:"IN",kn:"IN",or:"IN",ml:"IN",pa:"IN",bho:"IN",awa:"IN",as:"IN",mwr:"IN",mai:"IN",mag:"IN",bgc:"IN",hne:"IN",dcc:"IN",bjj:"IN",sat:"IN",wtm:"IN",ks:"IN",kok:"IN",gom:"IN",swv:"IN",lmn:"IN",gbm:"IN",gon:"IN",kfy:"IN",kru:"IN",doi:"IN",wbq:"IN",sck:"IN",xnr:"IN",wbr:"IN",tcy:"IN",khn:"IN",brx:"IN",noe:"IN",bhb:"IN",mni:"IN",raj:"IN",hoc:"IN",mtr:"IN",unr:"IN",bhi:"IN",hoj:"IN",kha:"IN",kfr:"IN",grt:"IN",unx:"IN",bfy:"IN",srx:"IN",saz:"IN",sd_deva:"IN",ccp:"IN",njo:"IN",bfq:"IN",ria:"IN",bpy:"IN",bra:"IN",lep:"IN",sa:"IN",kht:"IN",bn:"BD",beng:"BD",rkt:"BD",syl:"BD",mro:"BD",kgp:"BR",gub:"BR",yrl:"BR",xav:"BR",dz:"BT",tibt:"BT",tsj:"BT",tn:"BW",pdt:"CA",crk:"CA",cr:"CA",iu:"CA",oj:"CA",ojs:"CA",moe:"CA",mic:"CA",bla:"CA",crj:"CA",atj:"CA",crl:"CA",csw:"CA",crm:"CA",ikt:"CA",moh:"CA",dgr:"CA",den:"CA",clc:"CA",hur:"CA",crg:"CA",lil:"CA",oka:"CA",pqm:"CA",kwk:"CA",nsk:"CA",chp:"CA",gwi:"CA",guc:"CO",am:"ET",ethi:"ET",om:"ET",ti:"ET",sid:"ET",wal:"ET",aa:"ET",quc:"GT",ch:"GU",id:"ID",jv:"ID",su:"ID",mad:"ID",ms_arab:"ID",min:"ID",bew:"ID",ban:"ID",bug:"ID",bjn:"ID",ace:"ID",sas:"ID",bbc:"ID",mak:"ID",ljp:"ID",rej:"ID",gor:"ID",nij:"ID",kge:"ID",aoz:"ID",kvr:"ID",lbw:"ID",gay:"ID",rob:"ID",sxn:"ID",mdr:"ID",sly:"ID",mwv:"ID",he:"IL",hebr:"IL",lad:"IL",jam:"JM",ja:"JP",jpan:"JP",ryu:"JP",ki:"KE",luy:"KE",luo:"KE",kln:"KE",kam:"KE",guz:"KE",mer:"KE",ebu:"KE",dav:"KE",pko:"KE",saq:"KE",km:"KH",khmr:"KH",cja:"KH",ko:"KR",kore:"KR",lo:"LA",laoo:"LA",kjg:"LA",hnj:"LA",mh:"MH",my:"MM",mymr:"MM",shn:"MM",kac:"MM",rhg:"MM",mnw:"MM",mt:"MT",yua:"MX",nhe:"MX",nhw:"MX",maz:"MX",nch:"MX",sei:"MX",vmw:"MZ",ndc:"MZ",ngl:"MZ",seh:"MZ",mgh:"MZ",rng:"MZ",yao:"MZ",ne:"NP",new:"NP",jml:"NP",dty:"NP",taj:"NP",thl:"NP",bap:"NP",tdg:"NP",thr:"NP",mgp:"NP",lif:"NP",thq:"NP",mrd:"NP",xsr:"NP",rjs:"NP",tsf:"NP",ggn:"NP",gvr:"NP",tkt:"NP",tdh:"NP",unr_deva:"NP",qu:"PE",fil:"PH",ceb:"PH",ilo:"PH",hil:"PH",bik:"PH",war:"PH",fbl:"PH",pam:"PH",pag:"PH",mdh:"PH",tsg:"PH",cps:"PH",krj:"PH",bto:"PH",hnn:"PH",tbw:"PH",bku:"PH",ur:"PK",pa_arab:"PK",lah:"PK",ps:"PK",sd:"PK",skr:"PK",bal:"PK",brh:"PK",hno:"PK",bgn:"PK",hnd:"PK",tg_arab:"PK",gju:"PK",bft:"PK",kvx:"PK",khw:"PK",mvy:"PK",kxp:"PK",gjk:"PK",trw:"PK",btv:"PK",gn:"PY",th:"TH",thai:"TH",tts:"TH",nod:"TH",sou:"TH",mfa:"TH",kxm:"TH",kdt:"TH",lwl:"TH",zh_hant:"TW",hant:"TW",trv:"TW",nv:"US",pdc:"US",haw:"US",frc:"US",chr:"US",esu:"US",dak:"US",cho:"US",lkt:"US",ik:"US",mus:"US",sm:"WS",zu:"ZA",xh:"ZA",af:"ZA",nso:"ZA",ts:"ZA",ve:"ZA",nr:"ZA",sn:"ZW",nd:"ZW",mxc:"ZW",kck:"ZW",haz:"AF",uz_arab:"AF",prd:"AF",arq:"DZ",kab:"DZ",ar:"EG",arab:"EG",arz:"EG",ckb:"IQ",syr:"IQ",fa:"IR",az_arab:"IR",mzn:"IR",glk:"IR",sdh:"IR",lrc:"IR",rmt:"IR",bqi:"IR",luz:"IR",lki:"IR",gbz:"IR",bej:"SD",fvr:"SD",mls:"SD",fia:"SD",zag:"SD",dv:"MV",thaa:"MV"},r={AG:0,ATG:0,28:0,AS:0,ASM:0,16:0,BD:0,BGD:0,50:0,BR:0,BRA:0,76:0,BS:0,BHS:0,44:0,BT:0,BTN:0,64:0,BW:0,BWA:0,72:0,BZ:0,BLZ:0,84:0,CA:0,CAN:0,124:0,CO:0,COL:0,170:0,DM:0,DMA:0,212:0,DO:0,DOM:0,214:0,ET:0,ETH:0,231:0,GT:0,GTM:0,320:0,GU:0,GUM:0,316:0,HK:0,HKG:0,344:0,HN:0,HND:0,340:0,ID:0,IDN:0,360:0,IL:0,ISR:0,376:0,IN:0,IND:0,356:0,JM:0,JAM:0,388:0,JP:0,JPN:0,392:0,KE:0,KEN:0,404:0,KH:0,KHM:0,116:0,KR:0,KOR:0,410:0,LA:0,LA0:0,418:0,MH:0,MHL:0,584:0,MM:0,MMR:0,104:0,MO:0,MAC:0,446:0,MT:0,MLT:0,470:0,MX:0,MEX:0,484:0,MZ:0,MOZ:0,508:0,NI:0,NIC:0,558:0,NP:0,NPL:0,524:0,PA:0,PAN:0,591:0,PE:0,PER:0,604:0,PH:0,PHL:0,608:0,PK:0,PAK:0,586:0,PR:0,PRI:0,630:0,PT:0,PRT:0,620:0,PY:0,PRY:0,600:0,SA:0,SAU:0,682:0,SG:0,SGP:0,702:0,SV:0,SLV:0,222:0,TH:0,THA:0,764:0,TT:0,TTO:0,780:0,TW:0,TWN:0,158:0,UM:0,UMI:0,581:0,US:0,USA:0,840:0,VE:0,VEN:0,862:0,VI:0,VIR:0,850:0,WS:0,WSM:0,882:0,YE:0,YEM:0,887:0,ZA:0,ZAF:0,710:0,ZW:0,ZWE:0,716:0,AE:6,ARE:6,784:6,AF:6,AFG:6,4:6,BH:6,BHR:6,48:6,DJ:6,DJI:6,262:6,DZ:6,DZA:6,12:6,EG:6,EGY:6,818:6,IQ:6,IRQ:6,368:6,IR:6,IRN:6,364:6,JO:6,JOR:6,400:6,KW:6,KWT:6,414:6,LY:6,LBY:6,434:6,OM:6,OMN:6,512:6,QA:6,QAT:6,634:6,SD:6,SDN:6,729:6,SY:6,SYR:6,760:6,MV:5,MDV:5,462:5};I.getWeekStartByRegion=function(I){return N(I,r)},I.getWeekStartByLocale=function(I){return function(I,a,r){if(I){var t,P=I.toLowerCase().split(/[-_]/),n=P[0],e=n;if(P[1]&&4===P[1].length?(e+="_"+P[1],t=P[2]):t=P[1],t||(t=a[e]||a[n]),t)return N(t.match(/^\d+$/)?Number(t):t,r)}return 1}(I,a,r)}}); 2 | //# sourceMappingURL=full.js.map 3 | -------------------------------------------------------------------------------- /dist/min/main.js: -------------------------------------------------------------------------------- 1 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.weekstart={})}(this,function(t){"use strict";function e(t,e){var a=e["string"==typeof t?t.toUpperCase():t];return"number"==typeof a?a:1}var a={en:"US",hi:"IN",deva:"IN",te:"IN",mr:"IN",ta:"IN",gu:"IN",kn:"IN",or:"IN",ml:"IN",pa:"IN",bho:"IN",awa:"IN",as:"IN",mwr:"IN",mai:"IN",mag:"IN",bgc:"IN",hne:"IN",dcc:"IN",bn:"BD",beng:"BD",rkt:"BD",dz:"BT",tibt:"BT",tn:"BW",am:"ET",ethi:"ET",om:"ET",quc:"GT",id:"ID",jv:"ID",su:"ID",mad:"ID",ms_arab:"ID",he:"IL",hebr:"IL",jam:"JM",ja:"JP",jpan:"JP",km:"KH",khmr:"KH",ko:"KR",kore:"KR",lo:"LA",laoo:"LA",mh:"MH",my:"MM",mymr:"MM",mt:"MT",ne:"NP",fil:"PH",ceb:"PH",ilo:"PH",ur:"PK",pa_arab:"PK",lah:"PK",ps:"PK",sd:"PK",skr:"PK",gn:"PY",th:"TH",thai:"TH",tts:"TH",zh_hant:"TW",hant:"TW",sm:"WS",zu:"ZA",sn:"ZW",arq:"DZ",ar:"EG",arab:"EG",arz:"EG",fa:"IR",az_arab:"IR",dv:"MV",thaa:"MV"},I={AG:0,ATG:0,28:0,AS:0,ASM:0,16:0,BD:0,BGD:0,50:0,BR:0,BRA:0,76:0,BS:0,BHS:0,44:0,BT:0,BTN:0,64:0,BW:0,BWA:0,72:0,BZ:0,BLZ:0,84:0,CA:0,CAN:0,124:0,CO:0,COL:0,170:0,DM:0,DMA:0,212:0,DO:0,DOM:0,214:0,ET:0,ETH:0,231:0,GT:0,GTM:0,320:0,GU:0,GUM:0,316:0,HK:0,HKG:0,344:0,HN:0,HND:0,340:0,ID:0,IDN:0,360:0,IL:0,ISR:0,376:0,IN:0,IND:0,356:0,JM:0,JAM:0,388:0,JP:0,JPN:0,392:0,KE:0,KEN:0,404:0,KH:0,KHM:0,116:0,KR:0,KOR:0,410:0,LA:0,LA0:0,418:0,MH:0,MHL:0,584:0,MM:0,MMR:0,104:0,MO:0,MAC:0,446:0,MT:0,MLT:0,470:0,MX:0,MEX:0,484:0,MZ:0,MOZ:0,508:0,NI:0,NIC:0,558:0,NP:0,NPL:0,524:0,PA:0,PAN:0,591:0,PE:0,PER:0,604:0,PH:0,PHL:0,608:0,PK:0,PAK:0,586:0,PR:0,PRI:0,630:0,PT:0,PRT:0,620:0,PY:0,PRY:0,600:0,SA:0,SAU:0,682:0,SG:0,SGP:0,702:0,SV:0,SLV:0,222:0,TH:0,THA:0,764:0,TT:0,TTO:0,780:0,TW:0,TWN:0,158:0,UM:0,UMI:0,581:0,US:0,USA:0,840:0,VE:0,VEN:0,862:0,VI:0,VIR:0,850:0,WS:0,WSM:0,882:0,YE:0,YEM:0,887:0,ZA:0,ZAF:0,710:0,ZW:0,ZWE:0,716:0,AE:6,ARE:6,784:6,AF:6,AFG:6,4:6,BH:6,BHR:6,48:6,DJ:6,DJI:6,262:6,DZ:6,DZA:6,12:6,EG:6,EGY:6,818:6,IQ:6,IRQ:6,368:6,IR:6,IRN:6,364:6,JO:6,JOR:6,400:6,KW:6,KWT:6,414:6,LY:6,LBY:6,434:6,OM:6,OMN:6,512:6,QA:6,QAT:6,634:6,SD:6,SDN:6,729:6,SY:6,SYR:6,760:6,MV:5,MDV:5,462:5};t.getWeekStartByRegion=function(t){return e(t,I)},t.getWeekStartByLocale=function(t){return function(t,a,I){if(t){var r,n=t.toLowerCase().split(/[-_]/),M=n[0],N=M;if(n[1]&&4===n[1].length?(N+="_"+n[1],r=n[2]):r=n[1],r||(r=a[N]||a[M]),r)return e(r.match(/^\d+$/)?Number(r):r,I)}return 1}(t,a,I)}}); 2 | //# sourceMappingURL=main.js.map 3 | -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamtiq/weekstart/1143307da8edab1901535b1936ea8401af5db3e0/docs/.nojekyll -------------------------------------------------------------------------------- /docs/api.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | weekstart Source: api.js 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 57 | 58 | 59 |
60 |
61 | 62 | 63 |
64 | 65 |
66 | 67 | 68 |

Source: api.js

69 | 70 |
71 |
72 |
/**
 74 |  * Functions to get first day of week.
 75 |  * 
 76 |  * @module api
 77 |  */
 78 | 
 79 | 
 80 | /**
 81 |  * Return first day of week for country/region code.
 82 |  *
 83 |  * @example
 84 |  * getWeekStartByRegion('PNG', {});   // 1
 85 |  * getWeekStartByRegion('png', {BR: 0, PNG: 3, EG: 6});   // 3
 86 |  * getWeekStartByRegion('qa', {QA: 6});   // 6
 87 |  * getWeekStartByRegion(50, {BD: 5, 50: 5, SD: 6});   // 5
 88 |  *
 89 |  * @param {number | string} regionCode
 90 |  *      ISO 3166 Alpha-2, Alpha-3 or numeric code.
 91 |  * @param {object} regionDayMap
 92 |  *      Mapping of country/region code to first day of week that should be used to get result.
 93 |  *      Country codes should be in upper case.
 94 |  * @return {number}
 95 |  *      Code of first day of week for the given country/region code:
 96 |  *      0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.
 97 |  * @alias module:api.getWeekStartByRegion
 98 |  */
 99 | export function getWeekStartByRegion(regionCode, regionDayMap) {
100 |     /* eslint-disable indent */
101 |     const code = regionDayMap[typeof regionCode === 'string'
102 |                                 ? regionCode.toUpperCase()
103 |                                 : regionCode];
104 |     /* eslint-enable indent */
105 | 
106 |     return typeof code === 'number'
107 |         ? code
108 |         : 1;
109 | }
110 | 
111 | /**
112 |  * Return first day of week for locale identifier.
113 |  *
114 |  * @example
115 |  * getWeekStartByLocale('no', {}, {});   // 1
116 |  * getWeekStartByLocale('no', {no: 'abc'}, {ABC: 3});   // 3
117 |  * getWeekStartByLocale('KK_arab', {kk_arab: 'CN'}, {CN: 0});   // 0
118 |  * getWeekStartByLocale('fr-DZ', {fr: 'FR'}, {FR: 1, DZ: 6});   // 6
119 |  *
120 |  * @param {string} locale
121 |  *      Locale identifier.
122 |  * @param {object} langRegionMap
123 |  *      Mapping of language code to country/region code that should be used to get result.
124 |  *      Language codes should be in lower case.
125 |  * @param {object} regionDayMap
126 |  *      Mapping of country/region code to first day of week that should be used to get result.
127 |  *      Country codes should be in upper case.
128 |  * @return {number}
129 |  *      Code of first day of week for the given locale identifier:
130 |  *      0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.
131 |  * @alias module:api.getWeekStartByLocale
132 |  */
133 | export function getWeekStartByLocale(locale, langRegionMap, regionDayMap) {
134 |     if (locale) {
135 |         // Locale form: http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers
136 |         const data = locale.toLowerCase().split(/[-_]/);
137 |         const langTag = data[0];
138 |         let language = langTag;
139 |         let country;
140 |         if (data[1] && data[1].length === 4) {
141 |             language += `_${data[1]}`;
142 |             country = data[2];
143 |         }
144 |         else {
145 |             country = data[1];
146 |         }
147 |         if (! country) {
148 |             country = langRegionMap[language] || langRegionMap[langTag];
149 |         }
150 |         if (country) {
151 |             return getWeekStartByRegion(
152 |                 country.match(/^\d+$/)
153 |                     ? Number(country)
154 |                     : country,
155 |                 regionDayMap
156 |             );
157 |         }
158 |     }
159 | 
160 |     return 1;
161 | }
162 | 
163 |
164 |
165 | 166 | 167 | 168 | 169 | 170 |
171 |
172 | 173 |
174 | 175 | 176 | 177 |
178 |
179 | 180 | 181 | 195 | 196 | 197 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 293 | 294 | 295 | 296 | 297 | -------------------------------------------------------------------------------- /docs/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamtiq/weekstart/1143307da8edab1901535b1936ea8401af5db3e0/docs/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /docs/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamtiq/weekstart/1143307da8edab1901535b1936ea8401af5db3e0/docs/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /docs/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamtiq/weekstart/1143307da8edab1901535b1936ea8401af5db3e0/docs/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /docs/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamtiq/weekstart/1143307da8edab1901535b1936ea8401af5db3e0/docs/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /docs/full.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | weekstart Source: full.js 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 57 | 58 | 59 |
60 |
61 | 62 | 63 |
64 | 65 |
66 | 67 | 68 |

Source: full.js

69 | 70 |
71 |
72 |
/*
 74 |  * weekstart
 75 |  * https://github.com/gamtiq/weekstart
 76 |  */
 77 | 
 78 | /**
 79 |  * Library to get first day of week.
 80 |  * 
 81 |  * Uses data from {@link module:fullLangRegionMap fullLangRegionMap.js} and
 82 |  * {@link module:regionDayMap regionDayMap.js}.
 83 |  * 
 84 |  * @module full
 85 |  */
 86 | 
 87 | import * as api from './api';
 88 | import langRegionMap from './fullLangRegionMap';
 89 | import regionDayMap from './regionDayMap';
 90 | 
 91 | /**
 92 |  * Return first day of week for country/region code.
 93 |  *
 94 |  * Based on data from:
 95 |  * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)
 96 |  * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html)
 97 |  *
 98 |  * @example
 99 |  * getWeekStartByRegion('PNG');   // 1
100 |  * getWeekStartByRegion('qa');   // 6
101 |  * getWeekStartByRegion(462);   // 5
102 |  *
103 |  * @param {number | string} regionCode
104 |  *      ISO 3166 Alpha-2, Alpha-3 or numeric code.
105 |  * @return {number}
106 |  *      Code of first day of week for the given country/region code:
107 |  *      0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.
108 |  * @alias module:full.getWeekStartByRegion
109 |  * @see module:api.getWeekStartByRegion
110 |  */
111 | export function getWeekStartByRegion(regionCode) {
112 |     return api.getWeekStartByRegion(regionCode, regionDayMap);
113 | }
114 | 
115 | /**
116 |  * Return first day of week for locale identifier.
117 |  *
118 |  * Based on data from:
119 |  * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html)
120 |  * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html)
121 |  * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)
122 |  * - [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers)
123 |  *
124 |  * @example
125 |  * getWeekStartByLocale('no');   // 1
126 |  * getWeekStartByLocale('PA_arab');   // 0
127 |  * getWeekStartByLocale('fr-DZ');   // 6
128 |  *
129 |  * @param {string} locale
130 |  *      Locale identifier.
131 |  * @return {number}
132 |  *      Code of first day of week for the given locale identifier:
133 |  *      0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.
134 |  * @alias module:full.getWeekStartByLocale
135 |  * @see module:api.getWeekStartByLocale
136 |  */
137 | export function getWeekStartByLocale(locale) {
138 |     return api.getWeekStartByLocale(locale, langRegionMap, regionDayMap);
139 | }
140 | 
141 |
142 |
143 | 144 | 145 | 146 | 147 | 148 |
149 |
150 | 151 |
152 | 153 | 154 | 155 |
156 |
157 | 158 | 159 | 173 | 174 | 175 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 271 | 272 | 273 | 274 | 275 | -------------------------------------------------------------------------------- /docs/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamtiq/weekstart/1143307da8edab1901535b1936ea8401af5db3e0/docs/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /docs/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamtiq/weekstart/1143307da8edab1901535b1936ea8401af5db3e0/docs/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /docs/langRegionMap.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | weekstart Source: langRegionMap.js 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 57 | 58 | 59 |
60 |
61 | 62 | 63 |
64 | 65 |
66 | 67 | 68 |

Source: langRegionMap.js

69 | 70 |
71 |
72 |
/**
 74 |  * Contains base mapping of language code to country code.
 75 |  * Contains data only for countries which first day of week is not monday,
 76 |  * and mainly for languages approximately having more than 10 mln speakers.
 77 |  *
 78 |  * Based on data from `fullLangRegionMap.js`.
 79 |  * 
 80 |  * @module langRegionMap
 81 |  */
 82 | 
 83 | 
 84 | /* eslint-disable camelcase */
 85 | /**
 86 |  * Base mapping of language code to country code.
 87 |  * Contains data only for countries which first day of week is not monday,
 88 |  * and mainly for languages approximately having more than 10 mln speakers.
 89 |  *
 90 |  * Based on data from `fullLangRegionMap.js`.
 91 |  */
 92 | const langRegionMap = {
 93 |     en: 'US',
 94 |     
 95 |     hi: 'IN',
 96 |     deva: 'IN',   // script
 97 |     te: 'IN',
 98 |     mr: 'IN',
 99 |     ta: 'IN',
100 |     gu: 'IN',
101 |     kn: 'IN',
102 |     or: 'IN',
103 |     ml: 'IN',
104 |     pa: 'IN',
105 |     bho: 'IN',
106 |     awa: 'IN',
107 |     as: 'IN',
108 |     mwr: 'IN',
109 |     mai: 'IN',
110 |     mag: 'IN',
111 |     bgc: 'IN',
112 |     hne: 'IN',
113 |     dcc: 'IN',
114 | 
115 |     bn: 'BD',
116 |     beng: 'BD',   // script
117 |     rkt: 'BD',
118 | 
119 |     dz: 'BT',
120 |     tibt: 'BT',   // script
121 | 
122 |     tn: 'BW',
123 | 
124 |     am: 'ET',
125 |     ethi: 'ET',   // script
126 |     om: 'ET',
127 | 
128 |     quc: 'GT',
129 | 
130 |     id: 'ID',
131 |     jv: 'ID',
132 |     su: 'ID',
133 |     mad: 'ID',
134 |     ms_arab: 'ID',
135 | 
136 |     he: 'IL',
137 |     hebr: 'IL',   // script
138 | 
139 |     jam: 'JM',
140 | 
141 |     ja: 'JP',
142 |     jpan: 'JP',   // script
143 | 
144 |     km: 'KH',
145 |     khmr: 'KH',   // script
146 | 
147 |     ko: 'KR',
148 |     kore: 'KR',   // script
149 | 
150 |     lo: 'LA',
151 |     laoo: 'LA',   // script
152 | 
153 |     mh: 'MH',
154 | 
155 |     my: 'MM',
156 |     mymr: 'MM',   // script
157 | 
158 |     mt: 'MT',
159 | 
160 |     ne: 'NP',
161 | 
162 |     fil: 'PH',
163 |     ceb: 'PH',
164 |     ilo: 'PH',
165 | 
166 |     ur: 'PK',
167 |     pa_arab: 'PK',
168 |     lah: 'PK',
169 |     ps: 'PK',
170 |     sd: 'PK',
171 |     skr: 'PK',
172 | 
173 |     gn: 'PY',
174 | 
175 |     th: 'TH',
176 |     thai: 'TH',   // script
177 |     tts: 'TH',
178 | 
179 |     zh_hant: 'TW',
180 |     hant: 'TW',   // script
181 | 
182 |     sm: 'WS',
183 |     
184 |     zu: 'ZA',
185 | 
186 |     sn: 'ZW',
187 | 
188 | 
189 |     arq: 'DZ',
190 | 
191 |     ar: 'EG',
192 |     arab: 'EG',   // script
193 |     arz: 'EG',
194 | 
195 |     fa: 'IR',
196 |     az_arab: 'IR',
197 | 
198 | 
199 |     dv: 'MV',
200 |     thaa: 'MV'   // script
201 | };
202 | /* eslint-enable camelcase */
203 | 
204 | export default langRegionMap;
205 | 
206 |
207 |
208 | 209 | 210 | 211 | 212 | 213 |
214 |
215 | 216 |
217 | 218 | 219 | 220 |
221 |
222 | 223 | 224 | 238 | 239 | 240 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 336 | 337 | 338 | 339 | 340 | -------------------------------------------------------------------------------- /docs/main.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | weekstart Source: main.js 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 57 | 58 | 59 |
60 |
61 | 62 | 63 |
64 | 65 |
66 | 67 | 68 |

Source: main.js

69 | 70 |
71 |
72 |
/*
 74 |  * weekstart
 75 |  * https://github.com/gamtiq/weekstart
 76 |  */
 77 | 
 78 | /**
 79 |  * Library to get first day of week.
 80 |  * 
 81 |  * Uses data from {@link module:langRegionMap langRegionMap.js} and
 82 |  * {@link module:regionDayMap regionDayMap.js}.
 83 |  * 
 84 |  * @module main
 85 |  */
 86 | 
 87 | import * as api from './api';
 88 | import langRegionMap from './langRegionMap';
 89 | import regionDayMap from './regionDayMap';
 90 | 
 91 | /**
 92 |  * Return first day of week for country/region code.
 93 |  *
 94 |  * Based on data from:
 95 |  * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)
 96 |  * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html)
 97 |  *
 98 |  * @example
 99 |  * getWeekStartByRegion('PNG');   // 1
100 |  * getWeekStartByRegion('qa');   // 6
101 |  * getWeekStartByRegion(462);   // 5
102 |  *
103 |  * @param {number | string} regionCode
104 |  *      ISO 3166 Alpha-2, Alpha-3 or numeric code.
105 |  * @return {number}
106 |  *      Code of first day of week for the given country/region code:
107 |  *      0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.
108 |  * @alias module:main.getWeekStartByRegion
109 |  * @see module:api.getWeekStartByRegion
110 |  */
111 | export function getWeekStartByRegion(regionCode) {
112 |     return api.getWeekStartByRegion(regionCode, regionDayMap);
113 | }
114 | 
115 | /**
116 |  * Return first day of week for locale identifier.
117 |  *
118 |  * Based on data from:
119 |  * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html)
120 |  * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html)
121 |  * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html)
122 |  * - [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers)
123 |  *
124 |  * @example
125 |  * getWeekStartByLocale('no');   // 1
126 |  * getWeekStartByLocale('Pa_Guru');   // 0
127 |  * getWeekStartByLocale('fr-DZ');   // 6
128 |  *
129 |  * @param {string} locale
130 |  *      Locale identifier.
131 |  * @return {number}
132 |  *      Code of first day of week for the given locale identifier:
133 |  *      0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.
134 |  * @alias module:main.getWeekStartByLocale
135 |  * @see module:api.getWeekStartByLocale
136 |  */
137 | export function getWeekStartByLocale(locale) {
138 |     return api.getWeekStartByLocale(locale, langRegionMap, regionDayMap);
139 | }
140 | 
141 |
142 |
143 | 144 | 145 | 146 | 147 | 148 |
149 |
150 | 151 |
152 | 153 | 154 | 155 |
156 |
157 | 158 | 159 | 173 | 174 | 175 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 271 | 272 | 273 | 274 | 275 | -------------------------------------------------------------------------------- /docs/module-fullLangRegionMap.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | weekstart Module: fullLangRegionMap 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 57 | 58 | 59 |
60 |
61 | 62 | 63 |
64 | 65 |
66 | 67 | 68 |

Module: fullLangRegionMap

69 |
70 | 71 |
72 | 73 |
74 | 75 | 76 |
77 |
78 | 79 | 80 |

Contains full mapping of language code to country code. 81 | Data only for countries which first day of week is not monday.

82 | 83 | 84 | 85 |
86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |
Source:
116 |
117 | 123 |
124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 |
132 | 133 | 134 | 135 | 136 |
137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 |

Members

150 | 151 |
152 | 153 |
154 |
155 |

<inner, constant> langRegionMap

156 | 157 | 158 |
159 |
160 | 161 | 171 | 172 | 173 | 174 | 175 | 176 |
177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 |
Source:
207 |
208 | 214 |
215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 |
223 | 224 | 225 | 226 |
227 | 228 |
229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 |
237 | 238 |
239 | 240 | 241 | 242 | 243 |
244 |
245 | 246 |
247 | 248 | 249 |
250 | 251 |
252 | 253 | 254 |
255 |
256 | 257 | 258 | 272 | 273 | 274 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 370 | 371 | 372 | 373 | -------------------------------------------------------------------------------- /docs/module-langRegionMap.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | weekstart Module: langRegionMap 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 57 | 58 | 59 |
60 |
61 | 62 | 63 |
64 | 65 |
66 | 67 | 68 |

Module: langRegionMap

69 |
70 | 71 |
72 | 73 |
74 | 75 | 76 |
77 |
78 | 79 | 80 |

Contains base mapping of language code to country code. 81 | Contains data only for countries which first day of week is not monday, 82 | and mainly for languages approximately having more than 10 mln speakers.

83 |

Based on data from fullLangRegionMap.js.

84 | 85 | 86 | 87 |
88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 |
Source:
118 |
119 | 125 |
126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 |
134 | 135 | 136 | 137 | 138 |
139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 |

Members

152 | 153 |
154 | 155 |
156 |
157 |

<inner, constant> langRegionMap

158 | 159 | 160 |
161 |
162 | 163 |
164 |

Base mapping of language code to country code. 165 | Contains data only for countries which first day of week is not monday, 166 | and mainly for languages approximately having more than 10 mln speakers.

167 |

Based on data from fullLangRegionMap.js.

168 |
169 | 170 | 171 | 172 | 173 | 174 |
175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 |
Source:
205 |
206 | 212 |
213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 |
221 | 222 | 223 | 224 |
225 | 226 |
227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 |
235 | 236 |
237 | 238 | 239 | 240 | 241 |
242 |
243 | 244 |
245 | 246 | 247 |
248 | 249 |
250 | 251 | 252 |
253 |
254 | 255 | 256 | 270 | 271 | 272 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 368 | 369 | 370 | 371 | -------------------------------------------------------------------------------- /docs/module-regionDayMap.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | weekstart Module: regionDayMap 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 57 | 58 | 59 |
60 |
61 | 62 | 63 |
64 | 65 |
66 | 67 | 68 |

Module: regionDayMap

69 |
70 | 71 |
72 | 73 |
74 | 75 | 76 |
77 |
78 | 79 | 80 |

Contains data about first day of week depending on country code.

81 | 82 | 83 | 84 |
85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 |
Source:
115 |
116 | 122 |
123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 |
131 | 132 | 133 | 134 | 135 |
136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 |

Members

149 | 150 |
151 | 152 |
153 |
154 |

<inner, constant> regionDayMap

155 | 156 | 157 |
158 |
159 | 160 |
161 |

Data about first day of week depending on country code. 162 | Based on:

163 | 167 |
168 | 169 | 170 | 171 | 172 | 173 |
174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 |
Source:
204 |
205 | 211 |
212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 |
220 | 221 | 222 | 223 |
224 | 225 |
226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 |
234 | 235 |
236 | 237 | 238 | 239 | 240 |
241 |
242 | 243 |
244 | 245 | 246 |
247 | 248 |
249 | 250 | 251 |
252 |
253 | 254 | 255 | 269 | 270 | 271 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 367 | 368 | 369 | 370 | -------------------------------------------------------------------------------- /docs/modules.list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | weekstart Modules 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 57 | 58 | 59 |
60 |
61 | 62 | 63 |
64 | 65 |
66 | 67 | 68 |

Modules

69 |
70 | 71 |
72 | 73 |

74 | 75 |

76 | 77 | 78 |
79 | 80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 |
124 | 125 | 126 | 127 | 128 |
129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 |
148 | 149 |
150 | 151 | 152 | 153 | 154 |
155 |
156 | 157 |
158 | 159 | 160 |
161 | 162 |
163 | 164 | 165 |
166 |
167 | 168 | 169 | 183 | 184 | 185 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 281 | 282 | 283 | 284 | -------------------------------------------------------------------------------- /docs/scripts/fulltext-search-ui.js: -------------------------------------------------------------------------------- 1 | window.SearcherDisplay = (function($) { 2 | /** 3 | * This class provides support for displaying quick search text results to users. 4 | */ 5 | function SearcherDisplay() { } 6 | 7 | SearcherDisplay.prototype.init = function() { 8 | this._displayQuickSearch(); 9 | }; 10 | 11 | /** 12 | * This method creates the quick text search entry in navigation menu and wires all required events. 13 | */ 14 | SearcherDisplay.prototype._displayQuickSearch = function() { 15 | var quickSearch = $(document.createElement("iframe")), 16 | body = $("body"), 17 | self = this; 18 | 19 | quickSearch.attr("src", "quicksearch.html"); 20 | quickSearch.css("width", "0px"); 21 | quickSearch.css("height", "0px"); 22 | 23 | body.append(quickSearch); 24 | 25 | $(window).on("message", function(msg) { 26 | var msgData = msg.originalEvent.data; 27 | 28 | if (msgData.msgid != "docstrap.quicksearch.done") { 29 | return; 30 | } 31 | 32 | var results = msgData.results || []; 33 | 34 | self._displaySearchResults(results); 35 | }); 36 | 37 | function startSearch() { 38 | var searchTerms = $('#search-input').prop("value"); 39 | if (searchTerms) { 40 | quickSearch[0].contentWindow.postMessage({ 41 | "searchTerms": searchTerms, 42 | "msgid": "docstrap.quicksearch.start" 43 | }, "*"); 44 | } 45 | } 46 | 47 | $('#search-input').on('keyup', function(evt) { 48 | if (evt.keyCode != 13) { 49 | return; 50 | } 51 | startSearch(); 52 | return false; 53 | }); 54 | $('#search-submit').on('click', function() { 55 | startSearch(); 56 | return false; 57 | }); 58 | }; 59 | 60 | /** 61 | * This method displays the quick text search results in a modal dialog. 62 | */ 63 | SearcherDisplay.prototype._displaySearchResults = function(results) { 64 | var resultsHolder = $($("#searchResults").find(".modal-body")), 65 | fragment = document.createDocumentFragment(), 66 | resultsList = document.createElement("ul"); 67 | 68 | resultsHolder.empty(); 69 | 70 | for (var idx = 0; idx < results.length; idx++) { 71 | var result = results[idx], 72 | item = document.createElement("li"), 73 | link = document.createElement("a"); 74 | 75 | link.href = result.id; 76 | link.innerHTML = result.title; 77 | 78 | item.appendChild(link) 79 | resultsList.appendChild(item); 80 | } 81 | 82 | fragment.appendChild(resultsList); 83 | resultsHolder.append(fragment); 84 | 85 | $("#searchResults").modal({"show": true}); 86 | }; 87 | 88 | return new SearcherDisplay(); 89 | })($); 90 | -------------------------------------------------------------------------------- /docs/scripts/fulltext-search.js: -------------------------------------------------------------------------------- 1 | window.Searcher = (function() { 2 | function Searcher() { 3 | this._index = lunr(function () { 4 | this.field('title', {boost: 10}) 5 | this.field('body') 6 | this.ref('id') 7 | }) ; 8 | 9 | this._indexContent = undefined; 10 | } 11 | 12 | Searcher.prototype.init = function() { 13 | var self = this; 14 | 15 | $("script[type='text/x-docstrap-searchdb']").each(function(idx, item) { 16 | self._indexContent = JSON.parse(item.innerHTML); 17 | 18 | for (var entryId in self._indexContent) { 19 | self._index.add(self._indexContent[entryId]); 20 | } 21 | }); 22 | }; 23 | 24 | Searcher.prototype.search = function(searchTerm) { 25 | var results = [], 26 | searchResults = this._index.search(searchTerm); 27 | 28 | for (var idx = 0; idx < searchResults.length; idx++) { 29 | results.push(this._indexContent[searchResults[idx].ref]) 30 | } 31 | 32 | return results; 33 | }; 34 | 35 | return new Searcher(); 36 | })(); -------------------------------------------------------------------------------- /docs/scripts/prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([ 2 | ["pln", /^[\t\n\f\r ]+/, null, " \t\r\n "] 3 | ], [ 4 | ["str", /^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/, null], 5 | ["str", /^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/, null], 6 | ["lang-css-str", /^url\(([^"')]*)\)/i], 7 | ["kwd", /^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i, null], 8 | ["lang-css-kw", /^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i], 9 | ["com", /^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//], 10 | ["com", /^(?:<\!--|--\>)/], 11 | ["lit", /^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i], 12 | ["lit", /^#[\da-f]{3,6}/i], 13 | ["pln", /^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i], 14 | ["pun", /^[^\s\w"']+/] 15 | ]), ["css"]); 16 | PR.registerLangHandler(PR.createSimpleLexer([], [ 17 | ["kwd", /^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i] 18 | ]), ["css-kw"]); 19 | PR.registerLangHandler(PR.createSimpleLexer([], [ 20 | ["str", /^[^"')]+/] 21 | ]), ["css-str"]); -------------------------------------------------------------------------------- /docs/scripts/toc.js: -------------------------------------------------------------------------------- 1 | (function($) { 2 | var navbarHeight; 3 | var initialised = false; 4 | var navbarOffset; 5 | 6 | function elOffset($el) { 7 | return $el.offset().top - (navbarHeight + navbarOffset); 8 | } 9 | 10 | function scrollToHash(duringPageLoad) { 11 | var elScrollToId = location.hash.replace(/^#/, ''); 12 | var $el; 13 | 14 | function doScroll() { 15 | var offsetTop = elOffset($el); 16 | window.scrollTo(window.pageXOffset || window.scrollX, offsetTop); 17 | } 18 | 19 | if (elScrollToId) { 20 | $el = $(document.getElementById(elScrollToId)); 21 | 22 | if (!$el.length) { 23 | $el = $(document.getElementsByName(elScrollToId)); 24 | } 25 | 26 | if ($el.length) { 27 | if (duringPageLoad) { 28 | $(window).one('scroll', function() { 29 | setTimeout(doScroll, 100); 30 | }); 31 | } else { 32 | setTimeout(doScroll, 0); 33 | } 34 | } 35 | } 36 | } 37 | 38 | function init(opts) { 39 | if (initialised) { 40 | return; 41 | } 42 | initialised = true; 43 | navbarHeight = $('.navbar').height(); 44 | navbarOffset = opts.navbarOffset; 45 | 46 | // some browsers move the offset after changing location. 47 | // also catch external links coming in 48 | $(window).on("hashchange", scrollToHash.bind(null, false)); 49 | $(scrollToHash.bind(null, true)); 50 | } 51 | 52 | $.catchAnchorLinks = function(options) { 53 | var opts = $.extend({}, jQuery.fn.toc.defaults, options); 54 | init(opts); 55 | }; 56 | 57 | $.fn.toc = function(options) { 58 | var self = this; 59 | var opts = $.extend({}, jQuery.fn.toc.defaults, options); 60 | 61 | var container = $(opts.container); 62 | var tocs = []; 63 | var headings = $(opts.selectors, container); 64 | var headingOffsets = []; 65 | var activeClassName = 'active'; 66 | var ANCHOR_PREFIX = "__anchor"; 67 | var maxScrollTo; 68 | var visibleHeight; 69 | var headerHeight = 10; // so if the header is readable, its counted as shown 70 | init(); 71 | 72 | var scrollTo = function(e) { 73 | e.preventDefault(); 74 | var target = $(e.target); 75 | if (target.prop('tagName').toLowerCase() !== "a") { 76 | target = target.parent(); 77 | } 78 | var elScrollToId = target.attr('href').replace(/^#/, '') + ANCHOR_PREFIX; 79 | var $el = $(document.getElementById(elScrollToId)); 80 | 81 | var offsetTop = Math.min(maxScrollTo, elOffset($el)); 82 | 83 | $('body,html').animate({ scrollTop: offsetTop }, 400, 'swing', function() { 84 | location.hash = '#' + elScrollToId; 85 | }); 86 | 87 | $('a', self).removeClass(activeClassName); 88 | target.addClass(activeClassName); 89 | }; 90 | 91 | var calcHadingOffsets = function() { 92 | maxScrollTo = $("body").height() - $(window).height(); 93 | visibleHeight = $(window).height() - navbarHeight; 94 | headingOffsets = []; 95 | headings.each(function(i, heading) { 96 | var anchorSpan = $(heading).prev("span"); 97 | var top = 0; 98 | if (anchorSpan.length) { 99 | top = elOffset(anchorSpan); 100 | } 101 | headingOffsets.push(top > 0 ? top : 0); 102 | }); 103 | } 104 | 105 | //highlight on scroll 106 | var timeout; 107 | var highlightOnScroll = function(e) { 108 | if (!tocs.length) { 109 | return; 110 | } 111 | if (timeout) { 112 | clearTimeout(timeout); 113 | } 114 | timeout = setTimeout(function() { 115 | var top = $(window).scrollTop(), 116 | highlighted; 117 | for (var i = headingOffsets.length - 1; i >= 0; i--) { 118 | var isActive = tocs[i].hasClass(activeClassName); 119 | // at the end of the page, allow any shown header 120 | if (isActive && headingOffsets[i] >= maxScrollTo && top >= maxScrollTo) { 121 | return; 122 | } 123 | // if we have got to the first heading or the heading is the first one visible 124 | if (i === 0 || (headingOffsets[i] + headerHeight >= top && (headingOffsets[i - 1] + headerHeight <= top))) { 125 | // in the case that a heading takes up more than the visible height e.g. we are showing 126 | // only the one above, highlight the one above 127 | if (i > 0 && headingOffsets[i] - visibleHeight >= top) { 128 | i--; 129 | } 130 | $('a', self).removeClass(activeClassName); 131 | if (i >= 0) { 132 | highlighted = tocs[i].addClass(activeClassName); 133 | opts.onHighlight(highlighted); 134 | } 135 | break; 136 | } 137 | } 138 | }, 50); 139 | }; 140 | if (opts.highlightOnScroll) { 141 | $(window).bind('scroll', highlightOnScroll); 142 | $(window).bind('load resize', function() { 143 | calcHadingOffsets(); 144 | highlightOnScroll(); 145 | }); 146 | } 147 | 148 | return this.each(function() { 149 | //build TOC 150 | var el = $(this); 151 | var ul = $('
'); 152 | 153 | headings.each(function(i, heading) { 154 | var $h = $(heading); 155 | 156 | var anchor = $('').attr('id', opts.anchorName(i, heading, opts.prefix) + ANCHOR_PREFIX).insertBefore($h); 157 | 158 | var span = $('') 159 | .text(opts.headerText(i, heading, $h)); 160 | 161 | //build TOC item 162 | var a = $('') 163 | .append(span) 164 | .attr('href', '#' + opts.anchorName(i, heading, opts.prefix)) 165 | .bind('click', function(e) { 166 | scrollTo(e); 167 | el.trigger('selected', $(this).attr('href')); 168 | }); 169 | 170 | span.addClass(opts.itemClass(i, heading, $h, opts.prefix)); 171 | 172 | tocs.push(a); 173 | 174 | ul.append(a); 175 | }); 176 | el.html(ul); 177 | 178 | calcHadingOffsets(); 179 | }); 180 | }; 181 | 182 | 183 | jQuery.fn.toc.defaults = { 184 | container: 'body', 185 | selectors: 'h1,h2,h3', 186 | smoothScrolling: true, 187 | prefix: 'toc', 188 | onHighlight: function() {}, 189 | highlightOnScroll: true, 190 | navbarOffset: 0, 191 | anchorName: function(i, heading, prefix) { 192 | return prefix+i; 193 | }, 194 | headerText: function(i, heading, $heading) { 195 | return $heading.text(); 196 | }, 197 | itemClass: function(i, heading, $heading, prefix) { 198 | return prefix + '-' + $heading[0].tagName.toLowerCase(); 199 | } 200 | 201 | }; 202 | 203 | })(jQuery); 204 | -------------------------------------------------------------------------------- /docs/styles/prettify-tomorrow.css: -------------------------------------------------------------------------------- 1 | /* Tomorrow Theme */ 2 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */ 3 | /* Pretty printing styles. Used with prettify.js. */ 4 | /* SPAN elements with the classes below are added by prettyprint. */ 5 | /* plain text */ 6 | .pln { 7 | color: #4d4d4c; } 8 | 9 | @media screen { 10 | /* string content */ 11 | .str { 12 | color: #718c00; } 13 | 14 | /* a keyword */ 15 | .kwd { 16 | color: #8959a8; } 17 | 18 | /* a comment */ 19 | .com { 20 | color: #8e908c; } 21 | 22 | /* a type name */ 23 | .typ { 24 | color: #4271ae; } 25 | 26 | /* a literal value */ 27 | .lit { 28 | color: #f5871f; } 29 | 30 | /* punctuation */ 31 | .pun { 32 | color: #4d4d4c; } 33 | 34 | /* lisp open bracket */ 35 | .opn { 36 | color: #4d4d4c; } 37 | 38 | /* lisp close bracket */ 39 | .clo { 40 | color: #4d4d4c; } 41 | 42 | /* a markup tag name */ 43 | .tag { 44 | color: #c82829; } 45 | 46 | /* a markup attribute name */ 47 | .atn { 48 | color: #f5871f; } 49 | 50 | /* a markup attribute value */ 51 | .atv { 52 | color: #3e999f; } 53 | 54 | /* a declaration */ 55 | .dec { 56 | color: #f5871f; } 57 | 58 | /* a variable name */ 59 | .var { 60 | color: #c82829; } 61 | 62 | /* a function name */ 63 | .fun { 64 | color: #4271ae; } } 65 | /* Use higher contrast and text-weight for printable form. */ 66 | @media print, projection { 67 | .str { 68 | color: #060; } 69 | 70 | .kwd { 71 | color: #006; 72 | font-weight: bold; } 73 | 74 | .com { 75 | color: #600; 76 | font-style: italic; } 77 | 78 | .typ { 79 | color: #404; 80 | font-weight: bold; } 81 | 82 | .lit { 83 | color: #044; } 84 | 85 | .pun, .opn, .clo { 86 | color: #440; } 87 | 88 | .tag { 89 | color: #006; 90 | font-weight: bold; } 91 | 92 | .atn { 93 | color: #404; } 94 | 95 | .atv { 96 | color: #060; } } 97 | /* Style */ 98 | /* 99 | pre.prettyprint { 100 | background: white; 101 | font-family: Menlo, Monaco, Consolas, monospace; 102 | font-size: 12px; 103 | line-height: 1.5; 104 | border: 1px solid #ccc; 105 | padding: 10px; } 106 | */ 107 | 108 | /* Specify class=linenums on a pre to get line numbering */ 109 | ol.linenums { 110 | margin-top: 0; 111 | margin-bottom: 0; } 112 | 113 | /* IE indents via margin-left */ 114 | li.L0, 115 | li.L1, 116 | li.L2, 117 | li.L3, 118 | li.L4, 119 | li.L5, 120 | li.L6, 121 | li.L7, 122 | li.L8, 123 | li.L9 { 124 | /* */ } 125 | 126 | /* Alternate shading for lines */ 127 | li.L1, 128 | li.L3, 129 | li.L5, 130 | li.L7, 131 | li.L9 { 132 | /* */ } 133 | -------------------------------------------------------------------------------- /full.d.ts: -------------------------------------------------------------------------------- 1 | export * from './index'; 2 | -------------------------------------------------------------------------------- /full.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | module.exports = require('./dist/commonjs/full'); 4 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | // Created on the basis of http://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-d-ts.html 2 | 3 | export as namespace weekstart; 4 | 5 | export type DayOfWeek = 0 | 1 | 2 | 3 | 4 | 5 | 6; 6 | 7 | /** 8 | * Return first day of week for country/region code. 9 | * 10 | * Based on data from: 11 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html) 12 | * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html) 13 | * 14 | * @example 15 | * getWeekStartByRegion('PNG'); // 1 16 | * getWeekStartByRegion('qa'); // 6 17 | * getWeekStartByRegion(462); // 5 18 | * 19 | * @param {number | string} regionCode 20 | * ISO 3166 Alpha-2, Alpha-3 or numeric code. 21 | * @return {number} 22 | * Code of first day of week for the given country/region code: 23 | * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday. 24 | */ 25 | export function getWeekStartByRegion( 26 | regionCode: number | string 27 | ): DayOfWeek; 28 | 29 | /** 30 | * Return first day of week for locale identifier. 31 | * 32 | * Based on data from: 33 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html) 34 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html) 35 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html) 36 | * - [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers) 37 | * 38 | * @example 39 | * getWeekStartByLocale('no'); // 1 40 | * getWeekStartByLocale('Pa_Guru'); // 0 41 | * getWeekStartByLocale('fr-DZ'); // 6 42 | * 43 | * @param {string} locale 44 | * Locale identifier. 45 | * @return {number} 46 | * Code of first day of week for the given locale identifier: 47 | * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday. 48 | */ 49 | export function getWeekStartByLocale( 50 | locale: string 51 | ): DayOfWeek; 52 | -------------------------------------------------------------------------------- /jsdoc-conf.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | module.exports = { 4 | 'opts': { 5 | 'destination': 'docs', 6 | 'recurse': true, 7 | 'template': 'node_modules/ink-docstrap/template', 8 | 'fileSet': '.nojekyll' 9 | }, 10 | 11 | 'source': { 12 | 'include': ['src', 'README.md'] 13 | }, 14 | 15 | 'plugins': [ 16 | 'plugins/markdown', 17 | 'jsdoc-file' 18 | ], 19 | 20 | 'markdown': { 21 | 'parser': 'marked' 22 | }, 23 | 24 | 'templates': { 25 | 'outputSourceFiles': true, 26 | 'systemName': 'weekstart', 27 | 'copyright': 'Copyright (c) 2017-present Denis Sikuler', 28 | 'includeDate': false, 29 | 'theme': 'spacelab', 30 | 'linenums': true 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weekstart", 3 | "version": "2.0.0", 4 | "description": "Library to get first day of week.", 5 | "homepage": "https://github.com/gamtiq/weekstart", 6 | "main": "dist/commonjs/main.js", 7 | "module": "dist/es-module/main.js", 8 | "umd:main": "dist/main.js", 9 | "files": [ 10 | "dist", 11 | "full.js", 12 | "full.d.ts", 13 | "index.d.ts", 14 | "src", 15 | "History.md" 16 | ], 17 | "keywords": [ 18 | "week", 19 | "start", 20 | "first", 21 | "day", 22 | "locale", 23 | "country", 24 | "region" 25 | ], 26 | "devDependencies": { 27 | "@babel/preset-env": "^7.20.2", 28 | "eslint": "^8.34.0", 29 | "eslint-config-guard": "^3.0.0", 30 | "ink-docstrap": "1.3.2", 31 | "jest": "^29.4.3", 32 | "jsdoc": "^3.6.11", 33 | "jsdoc-file": "^1.1.0", 34 | "microbundle": "0.4.4", 35 | "version-bump-prompt": "^6.1.0" 36 | }, 37 | "scripts": { 38 | "lint": "eslint --cache --max-warnings 0 \"**/*.js\"", 39 | "lint-error": "eslint --cache \"**/*.js\"", 40 | "lint-all": "eslint --max-warnings 0 \"**/*.js\"", 41 | "lint-all-error": "eslint \"**/*.js\"", 42 | "test": "jest", 43 | "check": "npm run lint && npm test", 44 | "check-all": "npm run lint-all && npm test", 45 | "doc": "jsdoc -c jsdoc-conf.js", 46 | "build-commonjs": "microbundle build \"src/!(*.test).js\" --output dist/commonjs --format cjs --strict --no-compress", 47 | "build-esm": "microbundle build \"src/!(*.test).js\" --output dist/es-module --format es --no-compress", 48 | "build-umd": "microbundle build src/main.js src/full.js --output dist --format umd --strict --no-compress", 49 | "build-umd-min": "microbundle build src/main.js src/full.js --output dist/min --format umd --strict", 50 | "build": "npm run build-umd && npm run build-commonjs && npm run build-esm && npm run build-umd-min", 51 | "all": "npm run check-all && npm run doc && npm run build", 52 | "release": "bump patch --commit --tag --all --push package.json package-lock.json bower.json component.json", 53 | "release-minor": "bump minor --commit --tag --all --push package.json package-lock.json bower.json component.json", 54 | "release-major": "bump major --commit --tag --all --push package.json package-lock.json bower.json component.json" 55 | }, 56 | "author": { 57 | "name": "Denis Sikuler" 58 | }, 59 | "repository": { 60 | "type": "git", 61 | "url": "git://github.com/gamtiq/weekstart.git" 62 | }, 63 | "bugs": { 64 | "url": "https://github.com/gamtiq/weekstart/issues" 65 | }, 66 | "license": "MIT", 67 | "types": "./index.d.ts" 68 | } 69 | -------------------------------------------------------------------------------- /src/api.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Functions to get first day of week. 3 | * 4 | * @module api 5 | */ 6 | 7 | 8 | /** 9 | * Return first day of week for country/region code. 10 | * 11 | * @example 12 | * getWeekStartByRegion('PNG', {}); // 1 13 | * getWeekStartByRegion('png', {BR: 0, PNG: 3, EG: 6}); // 3 14 | * getWeekStartByRegion('qa', {QA: 6}); // 6 15 | * getWeekStartByRegion(50, {BD: 5, 50: 5, SD: 6}); // 5 16 | * 17 | * @param {number | string} regionCode 18 | * ISO 3166 Alpha-2, Alpha-3 or numeric code. 19 | * @param {object} regionDayMap 20 | * Mapping of country/region code to first day of week that should be used to get result. 21 | * Country codes should be in upper case. 22 | * @return {number} 23 | * Code of first day of week for the given country/region code: 24 | * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday. 25 | * @alias module:api.getWeekStartByRegion 26 | */ 27 | export function getWeekStartByRegion(regionCode, regionDayMap) { 28 | /* eslint-disable indent */ 29 | const code = regionDayMap[typeof regionCode === 'string' 30 | ? regionCode.toUpperCase() 31 | : regionCode]; 32 | /* eslint-enable indent */ 33 | 34 | return typeof code === 'number' 35 | ? code 36 | : 1; 37 | } 38 | 39 | /** 40 | * Return first day of week for locale identifier. 41 | * 42 | * @example 43 | * getWeekStartByLocale('no', {}, {}); // 1 44 | * getWeekStartByLocale('no', {no: 'abc'}, {ABC: 3}); // 3 45 | * getWeekStartByLocale('KK_arab', {kk_arab: 'CN'}, {CN: 0}); // 0 46 | * getWeekStartByLocale('fr-DZ', {fr: 'FR'}, {FR: 1, DZ: 6}); // 6 47 | * 48 | * @param {string} locale 49 | * Locale identifier. 50 | * @param {object} langRegionMap 51 | * Mapping of language code to country/region code that should be used to get result. 52 | * Language codes should be in lower case. 53 | * @param {object} regionDayMap 54 | * Mapping of country/region code to first day of week that should be used to get result. 55 | * Country codes should be in upper case. 56 | * @return {number} 57 | * Code of first day of week for the given locale identifier: 58 | * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday. 59 | * @alias module:api.getWeekStartByLocale 60 | */ 61 | export function getWeekStartByLocale(locale, langRegionMap, regionDayMap) { 62 | if (locale) { 63 | // Locale form: http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers 64 | const data = locale.toLowerCase().split(/[-_]/); 65 | const langTag = data[0]; 66 | let language = langTag; 67 | let country; 68 | if (data[1] && data[1].length === 4) { 69 | language += `_${data[1]}`; 70 | country = data[2]; 71 | } 72 | else { 73 | country = data[1]; 74 | } 75 | if (! country) { 76 | country = langRegionMap[language] || langRegionMap[langTag]; 77 | } 78 | if (country) { 79 | return getWeekStartByRegion( 80 | country.match(/^\d+$/) 81 | ? Number(country) 82 | : country, 83 | regionDayMap 84 | ); 85 | } 86 | } 87 | 88 | return 1; 89 | } 90 | -------------------------------------------------------------------------------- /src/api.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-env jest */ 2 | 3 | import * as api from './api'; 4 | 5 | describe('api', function apiTestSuite() { 6 | 7 | /* eslint-disable no-magic-numbers */ 8 | 9 | describe('getWeekStartByRegion(regionCode, regionDayMap)', () => { 10 | // eslint-disable-next-line require-jsdoc 11 | function verify(code, map, expected) { 12 | expect( api.getWeekStartByRegion(code, map) ) 13 | .toBe( expected ); 14 | } 15 | 16 | it('should return result depending on regionDayMap', () => { 17 | verify('png', {BR: 0, PNG: 3, EG: 6}, 3); 18 | verify('Qa', {QA: 6}, 6); 19 | verify(50, {BD: 5, '50': 5, SD: 6}, 5); 20 | verify('PNG', {BR: 0, PNG: 11, EGY: 6}, 11); 21 | }); 22 | 23 | it('should return 1', () => { 24 | verify('Id', {}, 1); 25 | verify('PR', {QA: 3, HK: 0}, 1); 26 | }); 27 | }); 28 | 29 | describe('getWeekStartByLocale(locale, langRegionMap, regionDayMap)', () => { 30 | // eslint-disable-next-line max-params, require-jsdoc 31 | function verify(locale, langRegionMap, regionDayMap, expected) { 32 | expect( api.getWeekStartByLocale(locale, langRegionMap, regionDayMap) ) 33 | .toBe( expected ); 34 | } 35 | 36 | it('should return result depending on langRegionMap and regionDayMap', () => { 37 | verify('no', {no: 'abc'}, {ABC: 3}, 3); 38 | verify('no', {no: 'abc', yes: 'xyz'}, {ABC: 9, XYZ: 10}, 9); 39 | verify('KK_arab', {'kk_arab': 'CN'}, {CN: 0}, 0); 40 | verify('KK_Arab', {'kk_arab': 'CN', kk: 'DJ'}, {CN: 0, DJ: 6}, 0); 41 | verify('kk_ARAB', {'kk_arab': 'CN', 'Arab': 'iq'}, {CN: 0, IQ: 6}, 0); 42 | verify('fr-DZ', {fr: 'FR'}, {FR: 1, DZ: 6}, 6); 43 | verify('fr-DZ', {fr: 'FR', dz: 'FR'}, {FR: 2, CA: 0, DZ: 6}, 6); 44 | }); 45 | 46 | it('should return 1', () => { 47 | verify('no', {}, {}, 1); 48 | verify('no', {en: 'GB', fr: 'DZ'}, {GB: 5, DZ: 6}, 1); 49 | verify('fr-DZ', {fr: 'FR'}, {FR: 3, TT: 0}, 1); 50 | }); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /src/full.js: -------------------------------------------------------------------------------- 1 | /* 2 | * weekstart 3 | * https://github.com/gamtiq/weekstart 4 | */ 5 | 6 | /** 7 | * Library to get first day of week. 8 | * 9 | * Uses data from {@link module:fullLangRegionMap fullLangRegionMap.js} and 10 | * {@link module:regionDayMap regionDayMap.js}. 11 | * 12 | * @module full 13 | */ 14 | 15 | import * as api from './api'; 16 | import langRegionMap from './fullLangRegionMap'; 17 | import regionDayMap from './regionDayMap'; 18 | 19 | /** 20 | * Return first day of week for country/region code. 21 | * 22 | * Based on data from: 23 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html) 24 | * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html) 25 | * 26 | * @example 27 | * getWeekStartByRegion('PNG'); // 1 28 | * getWeekStartByRegion('qa'); // 6 29 | * getWeekStartByRegion(462); // 5 30 | * 31 | * @param {number | string} regionCode 32 | * ISO 3166 Alpha-2, Alpha-3 or numeric code. 33 | * @return {number} 34 | * Code of first day of week for the given country/region code: 35 | * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday. 36 | * @alias module:full.getWeekStartByRegion 37 | * @see module:api.getWeekStartByRegion 38 | */ 39 | export function getWeekStartByRegion(regionCode) { 40 | return api.getWeekStartByRegion(regionCode, regionDayMap); 41 | } 42 | 43 | /** 44 | * Return first day of week for locale identifier. 45 | * 46 | * Based on data from: 47 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html) 48 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html) 49 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html) 50 | * - [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers) 51 | * 52 | * @example 53 | * getWeekStartByLocale('no'); // 1 54 | * getWeekStartByLocale('PA_arab'); // 0 55 | * getWeekStartByLocale('fr-DZ'); // 6 56 | * 57 | * @param {string} locale 58 | * Locale identifier. 59 | * @return {number} 60 | * Code of first day of week for the given locale identifier: 61 | * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday. 62 | * @alias module:full.getWeekStartByLocale 63 | * @see module:api.getWeekStartByLocale 64 | */ 65 | export function getWeekStartByLocale(locale) { 66 | return api.getWeekStartByLocale(locale, langRegionMap, regionDayMap); 67 | } 68 | -------------------------------------------------------------------------------- /src/full.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-env jest */ 2 | 3 | import * as api from './full'; 4 | 5 | describe('full', function fullTestSuite() { 6 | 7 | /* eslint-disable no-magic-numbers */ 8 | 9 | describe('getWeekStartByRegion(regionCode)', () => { 10 | // eslint-disable-next-line require-jsdoc 11 | function verify(code, expected) { 12 | expect( api.getWeekStartByRegion(code) ) 13 | .toBe( expected ); 14 | } 15 | 16 | it('should return correct result for ISO 3166 Alpha-2 code', () => { 17 | verify('Bd', 0); 18 | verify('bs', 0); 19 | verify('PE', 0); 20 | verify('kw', 6); 21 | verify('SD', 6); 22 | verify('mv', 5); 23 | verify('no', 1); 24 | verify('RU', 1); 25 | }); 26 | 27 | it('should return correct result for ISO 3166 Alpha-3 code', () => { 28 | verify('can', 0); 29 | verify('SLV', 0); 30 | verify('dji', 6); 31 | verify('QAT', 6); 32 | verify('MDV', 5); 33 | verify('esp', 1); 34 | verify('MUS', 1); 35 | }); 36 | 37 | it('should return correct result for ISO 3166 numeric code', () => { 38 | verify(446, 0); 39 | verify(710, 0); 40 | verify(400, 6); 41 | verify(729, 6); 42 | verify(462, 5); 43 | verify(246, 1); 44 | verify(686, 1); 45 | }); 46 | 47 | it('should return 1', () => { 48 | verify(null, 1); 49 | verify(0, 1); 50 | verify('moon', 1); 51 | }); 52 | }); 53 | 54 | describe('getWeekStartByLocale(locale)', () => { 55 | // eslint-disable-next-line require-jsdoc 56 | function verify(locale, expected) { 57 | expect( api.getWeekStartByLocale(locale) ) 58 | .toBe( expected ); 59 | } 60 | 61 | it('should return correct result for locale containing only language code', () => { 62 | verify('ccp', 0); 63 | verify('HI', 0); 64 | verify('jam', 0); 65 | verify('FA', 6); 66 | verify('bej', 6); 67 | verify('HR', 1); 68 | verify('vi', 1); 69 | }); 70 | 71 | it('should return correct result for locale containing only language code and script', () => { 72 | verify('TG-Arab', 0); 73 | verify('Tg_Cyrl', 1); 74 | verify('az-arab', 6); 75 | verify('az_Cyrl', 1); 76 | verify('UZ-ARAB', 6); 77 | verify('Uz-latn', 1); 78 | verify('Pa-Arab', 0); 79 | verify('haz_DEVA', 6); 80 | }); 81 | 82 | it('should return correct result for locale containing only script', () => { 83 | verify('Arab', 6); 84 | verify('deva', 0); 85 | verify('cyrl', 1); 86 | verify('Hans', 1); 87 | verify('hant', 0); 88 | verify('LATN', 1); 89 | verify('Tfng', 1); 90 | verify('THAA', 5); 91 | }); 92 | 93 | it('should return correct result for locale containing only language and region code', () => { 94 | verify('ar-sa', 0); 95 | verify('en_NG', 1); 96 | verify('FR-DZ', 6); 97 | verify('es_mx', 0); 98 | verify('BN-in', 0); 99 | }); 100 | 101 | it('should return correct result for locale containing only script and region code', () => { 102 | verify('ARAB_IN', 0); 103 | verify('arab-IR', 6); 104 | verify('Arab_MN', 1); 105 | verify('Hant_MY', 1); 106 | verify('latn_PY', 0); 107 | }); 108 | 109 | it('should return correct result for locale containing language, script and region code', () => { 110 | verify('az-arab-iq', 6); 111 | verify('az_Arab-TR', 1); 112 | verify('Az-Cyrl_Ru', 1); 113 | verify('zh_Hant_tw', 0); 114 | verify('ZH-HANT_VN', 1); 115 | }); 116 | 117 | it('should return correct result for arbitrary locale', () => { 118 | verify('xyz', 1); 119 | verify('az_arab_IRA', 1); 120 | verify('HI-Fij', 1); 121 | verify('MS_SG_u-data', 0); 122 | verify('en-mv-t-true-DE', 5); 123 | }); 124 | 125 | it('should return 1', () => { 126 | verify(false, 1); 127 | verify('', 1); 128 | verify('some-strange-locale', 1); 129 | verify('Summer moved on', 1); 130 | }); 131 | }); 132 | }); 133 | -------------------------------------------------------------------------------- /src/fullLangRegionMap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains full mapping of language code to country code. 3 | * Data only for countries which first day of week is not monday. 4 | * 5 | * @module fullLangRegionMap 6 | */ 7 | 8 | 9 | /* eslint-disable camelcase */ 10 | /** 11 | * Full mapping of language code to country code. 12 | * Contains data only for countries which first day of week is not monday. 13 | * 14 | * Based on: 15 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html) 16 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html) 17 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/scripts_languages_and_territories.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/scripts_languages_and_territories.html) 18 | */ 19 | const langRegionMap = { 20 | en: 'US', 21 | 22 | hi: 'IN', 23 | deva: 'IN', // script 24 | te: 'IN', 25 | mr: 'IN', 26 | ta: 'IN', 27 | gu: 'IN', 28 | kn: 'IN', 29 | or: 'IN', 30 | ml: 'IN', 31 | pa: 'IN', 32 | bho: 'IN', 33 | awa: 'IN', 34 | as: 'IN', 35 | mwr: 'IN', 36 | mai: 'IN', 37 | mag: 'IN', 38 | bgc: 'IN', 39 | hne: 'IN', 40 | dcc: 'IN', 41 | bjj: 'IN', 42 | sat: 'IN', 43 | wtm: 'IN', 44 | ks: 'IN', 45 | kok: 'IN', 46 | gom: 'IN', 47 | swv: 'IN', 48 | lmn: 'IN', 49 | gbm: 'IN', 50 | gon: 'IN', 51 | kfy: 'IN', 52 | kru: 'IN', 53 | doi: 'IN', 54 | wbq: 'IN', 55 | sck: 'IN', 56 | xnr: 'IN', 57 | wbr: 'IN', 58 | tcy: 'IN', 59 | khn: 'IN', 60 | brx: 'IN', 61 | noe: 'IN', 62 | bhb: 'IN', 63 | mni: 'IN', 64 | raj: 'IN', 65 | hoc: 'IN', 66 | mtr: 'IN', 67 | unr: 'IN', 68 | bhi: 'IN', 69 | hoj: 'IN', 70 | kha: 'IN', 71 | kfr: 'IN', 72 | grt: 'IN', 73 | unx: 'IN', 74 | bfy: 'IN', 75 | srx: 'IN', 76 | saz: 'IN', 77 | sd_deva: 'IN', 78 | ccp: 'IN', 79 | njo: 'IN', 80 | bfq: 'IN', 81 | ria: 'IN', 82 | bpy: 'IN', 83 | bra: 'IN', 84 | lep: 'IN', 85 | sa: 'IN', 86 | kht: 'IN', 87 | 88 | bn: 'BD', 89 | beng: 'BD', // script 90 | rkt: 'BD', 91 | syl: 'BD', 92 | mro: 'BD', 93 | 94 | kgp: 'BR', 95 | gub: 'BR', 96 | yrl: 'BR', 97 | xav: 'BR', 98 | 99 | dz: 'BT', 100 | tibt: 'BT', // script 101 | tsj: 'BT', 102 | 103 | tn: 'BW', 104 | 105 | pdt: 'CA', 106 | crk: 'CA', 107 | cr: 'CA', 108 | iu: 'CA', 109 | oj: 'CA', 110 | ojs: 'CA', 111 | moe: 'CA', 112 | mic: 'CA', 113 | bla: 'CA', 114 | crj: 'CA', 115 | atj: 'CA', 116 | crl: 'CA', 117 | csw: 'CA', 118 | crm: 'CA', 119 | ikt: 'CA', 120 | moh: 'CA', 121 | dgr: 'CA', 122 | den: 'CA', 123 | clc: 'CA', 124 | hur: 'CA', 125 | crg: 'CA', 126 | lil: 'CA', 127 | oka: 'CA', 128 | pqm: 'CA', 129 | kwk: 'CA', 130 | nsk: 'CA', 131 | chp: 'CA', 132 | gwi: 'CA', 133 | 134 | guc: 'CO', 135 | 136 | am: 'ET', 137 | ethi: 'ET', // script 138 | om: 'ET', 139 | ti: 'ET', 140 | sid: 'ET', 141 | wal: 'ET', 142 | aa: 'ET', 143 | 144 | quc: 'GT', 145 | 146 | ch: 'GU', 147 | 148 | id: 'ID', 149 | jv: 'ID', 150 | su: 'ID', 151 | mad: 'ID', 152 | ms_arab: 'ID', 153 | min: 'ID', 154 | bew: 'ID', 155 | ban: 'ID', 156 | bug: 'ID', 157 | bjn: 'ID', 158 | ace: 'ID', 159 | sas: 'ID', 160 | bbc: 'ID', 161 | mak: 'ID', 162 | ljp: 'ID', 163 | rej: 'ID', 164 | gor: 'ID', 165 | nij: 'ID', 166 | kge: 'ID', 167 | aoz: 'ID', 168 | kvr: 'ID', 169 | lbw: 'ID', 170 | gay: 'ID', 171 | rob: 'ID', 172 | sxn: 'ID', 173 | mdr: 'ID', 174 | sly: 'ID', 175 | mwv: 'ID', 176 | 177 | he: 'IL', 178 | hebr: 'IL', // script 179 | lad: 'IL', 180 | 181 | jam: 'JM', 182 | 183 | ja: 'JP', 184 | jpan: 'JP', // script 185 | ryu: 'JP', 186 | 187 | ki: 'KE', 188 | luy: 'KE', 189 | luo: 'KE', 190 | kln: 'KE', 191 | kam: 'KE', 192 | guz: 'KE', 193 | mer: 'KE', 194 | ebu: 'KE', 195 | dav: 'KE', 196 | pko: 'KE', 197 | saq: 'KE', 198 | 199 | km: 'KH', 200 | khmr: 'KH', // script 201 | cja: 'KH', 202 | 203 | ko: 'KR', 204 | kore: 'KR', // script 205 | 206 | lo: 'LA', 207 | laoo: 'LA', // script 208 | kjg: 'LA', 209 | hnj: 'LA', 210 | 211 | mh: 'MH', 212 | 213 | my: 'MM', 214 | mymr: 'MM', // script 215 | shn: 'MM', 216 | kac: 'MM', 217 | rhg: 'MM', 218 | mnw: 'MM', 219 | 220 | mt: 'MT', 221 | 222 | yua: 'MX', 223 | nhe: 'MX', 224 | nhw: 'MX', 225 | maz: 'MX', 226 | nch: 'MX', 227 | sei: 'MX', 228 | 229 | vmw: 'MZ', 230 | ndc: 'MZ', 231 | ngl: 'MZ', 232 | seh: 'MZ', 233 | mgh: 'MZ', 234 | rng: 'MZ', 235 | yao: 'MZ', 236 | 237 | ne: 'NP', 238 | 'new': 'NP', 239 | jml: 'NP', 240 | dty: 'NP', 241 | taj: 'NP', 242 | thl: 'NP', 243 | bap: 'NP', 244 | tdg: 'NP', 245 | thr: 'NP', 246 | mgp: 'NP', 247 | lif: 'NP', 248 | thq: 'NP', 249 | mrd: 'NP', 250 | xsr: 'NP', 251 | rjs: 'NP', 252 | tsf: 'NP', 253 | ggn: 'NP', 254 | gvr: 'NP', 255 | tkt: 'NP', 256 | tdh: 'NP', 257 | unr_deva: 'NP', 258 | 259 | qu: 'PE', 260 | 261 | fil: 'PH', 262 | ceb: 'PH', 263 | ilo: 'PH', 264 | hil: 'PH', 265 | bik: 'PH', 266 | war: 'PH', 267 | fbl: 'PH', 268 | pam: 'PH', 269 | pag: 'PH', 270 | mdh: 'PH', 271 | tsg: 'PH', 272 | cps: 'PH', 273 | krj: 'PH', 274 | bto: 'PH', 275 | hnn: 'PH', 276 | tbw: 'PH', 277 | bku: 'PH', 278 | 279 | ur: 'PK', 280 | pa_arab: 'PK', 281 | lah: 'PK', 282 | ps: 'PK', 283 | sd: 'PK', 284 | skr: 'PK', 285 | bal: 'PK', 286 | brh: 'PK', 287 | hno: 'PK', 288 | bgn: 'PK', 289 | hnd: 'PK', 290 | tg_arab: 'PK', 291 | gju: 'PK', 292 | bft: 'PK', 293 | kvx: 'PK', 294 | khw: 'PK', 295 | mvy: 'PK', 296 | kxp: 'PK', 297 | gjk: 'PK', 298 | trw: 'PK', 299 | btv: 'PK', 300 | 301 | gn: 'PY', 302 | 303 | th: 'TH', 304 | thai: 'TH', // script 305 | tts: 'TH', 306 | nod: 'TH', 307 | sou: 'TH', 308 | mfa: 'TH', 309 | kxm: 'TH', 310 | kdt: 'TH', 311 | lwl: 'TH', 312 | 313 | zh_hant: 'TW', 314 | hant: 'TW', // script 315 | trv: 'TW', 316 | 317 | nv: 'US', 318 | pdc: 'US', 319 | haw: 'US', 320 | frc: 'US', 321 | chr: 'US', 322 | esu: 'US', 323 | dak: 'US', 324 | cho: 'US', 325 | lkt: 'US', 326 | ik: 'US', 327 | mus: 'US', 328 | 329 | sm: 'WS', 330 | 331 | zu: 'ZA', 332 | xh: 'ZA', 333 | af: 'ZA', 334 | nso: 'ZA', 335 | ts: 'ZA', 336 | ve: 'ZA', 337 | nr: 'ZA', 338 | 339 | sn: 'ZW', 340 | nd: 'ZW', 341 | mxc: 'ZW', 342 | kck: 'ZW', 343 | 344 | 345 | haz: 'AF', 346 | uz_arab: 'AF', 347 | prd: 'AF', 348 | 349 | arq: 'DZ', 350 | kab: 'DZ', 351 | 352 | ar: 'EG', 353 | arab: 'EG', // script 354 | arz: 'EG', 355 | 356 | ckb: 'IQ', 357 | syr: 'IQ', 358 | 359 | fa: 'IR', 360 | az_arab: 'IR', 361 | mzn: 'IR', 362 | glk: 'IR', 363 | sdh: 'IR', 364 | lrc: 'IR', 365 | rmt: 'IR', 366 | bqi: 'IR', 367 | luz: 'IR', 368 | lki: 'IR', 369 | gbz: 'IR', 370 | 371 | bej: 'SD', 372 | fvr: 'SD', 373 | mls: 'SD', 374 | fia: 'SD', 375 | zag: 'SD', 376 | 377 | 378 | dv: 'MV', 379 | thaa: 'MV' // script 380 | }; 381 | /* eslint-enable camelcase */ 382 | 383 | export default langRegionMap; 384 | -------------------------------------------------------------------------------- /src/langRegionMap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains base mapping of language code to country code. 3 | * Contains data only for countries which first day of week is not monday, 4 | * and mainly for languages approximately having more than 10 mln speakers. 5 | * 6 | * Based on data from `fullLangRegionMap.js`. 7 | * 8 | * @module langRegionMap 9 | */ 10 | 11 | 12 | /* eslint-disable camelcase */ 13 | /** 14 | * Base mapping of language code to country code. 15 | * Contains data only for countries which first day of week is not monday, 16 | * and mainly for languages approximately having more than 10 mln speakers. 17 | * 18 | * Based on data from `fullLangRegionMap.js`. 19 | */ 20 | const langRegionMap = { 21 | en: 'US', 22 | 23 | hi: 'IN', 24 | deva: 'IN', // script 25 | te: 'IN', 26 | mr: 'IN', 27 | ta: 'IN', 28 | gu: 'IN', 29 | kn: 'IN', 30 | or: 'IN', 31 | ml: 'IN', 32 | pa: 'IN', 33 | bho: 'IN', 34 | awa: 'IN', 35 | as: 'IN', 36 | mwr: 'IN', 37 | mai: 'IN', 38 | mag: 'IN', 39 | bgc: 'IN', 40 | hne: 'IN', 41 | dcc: 'IN', 42 | 43 | bn: 'BD', 44 | beng: 'BD', // script 45 | rkt: 'BD', 46 | 47 | dz: 'BT', 48 | tibt: 'BT', // script 49 | 50 | tn: 'BW', 51 | 52 | am: 'ET', 53 | ethi: 'ET', // script 54 | om: 'ET', 55 | 56 | quc: 'GT', 57 | 58 | id: 'ID', 59 | jv: 'ID', 60 | su: 'ID', 61 | mad: 'ID', 62 | ms_arab: 'ID', 63 | 64 | he: 'IL', 65 | hebr: 'IL', // script 66 | 67 | jam: 'JM', 68 | 69 | ja: 'JP', 70 | jpan: 'JP', // script 71 | 72 | km: 'KH', 73 | khmr: 'KH', // script 74 | 75 | ko: 'KR', 76 | kore: 'KR', // script 77 | 78 | lo: 'LA', 79 | laoo: 'LA', // script 80 | 81 | mh: 'MH', 82 | 83 | my: 'MM', 84 | mymr: 'MM', // script 85 | 86 | mt: 'MT', 87 | 88 | ne: 'NP', 89 | 90 | fil: 'PH', 91 | ceb: 'PH', 92 | ilo: 'PH', 93 | 94 | ur: 'PK', 95 | pa_arab: 'PK', 96 | lah: 'PK', 97 | ps: 'PK', 98 | sd: 'PK', 99 | skr: 'PK', 100 | 101 | gn: 'PY', 102 | 103 | th: 'TH', 104 | thai: 'TH', // script 105 | tts: 'TH', 106 | 107 | zh_hant: 'TW', 108 | hant: 'TW', // script 109 | 110 | sm: 'WS', 111 | 112 | zu: 'ZA', 113 | 114 | sn: 'ZW', 115 | 116 | 117 | arq: 'DZ', 118 | 119 | ar: 'EG', 120 | arab: 'EG', // script 121 | arz: 'EG', 122 | 123 | fa: 'IR', 124 | az_arab: 'IR', 125 | 126 | 127 | dv: 'MV', 128 | thaa: 'MV' // script 129 | }; 130 | /* eslint-enable camelcase */ 131 | 132 | export default langRegionMap; 133 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | /* 2 | * weekstart 3 | * https://github.com/gamtiq/weekstart 4 | */ 5 | 6 | /** 7 | * Library to get first day of week. 8 | * 9 | * Uses data from {@link module:langRegionMap langRegionMap.js} and 10 | * {@link module:regionDayMap regionDayMap.js}. 11 | * 12 | * @module main 13 | */ 14 | 15 | import * as api from './api'; 16 | import langRegionMap from './langRegionMap'; 17 | import regionDayMap from './regionDayMap'; 18 | 19 | /** 20 | * Return first day of week for country/region code. 21 | * 22 | * Based on data from: 23 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html) 24 | * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html) 25 | * 26 | * @example 27 | * getWeekStartByRegion('PNG'); // 1 28 | * getWeekStartByRegion('qa'); // 6 29 | * getWeekStartByRegion(462); // 5 30 | * 31 | * @param {number | string} regionCode 32 | * ISO 3166 Alpha-2, Alpha-3 or numeric code. 33 | * @return {number} 34 | * Code of first day of week for the given country/region code: 35 | * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday. 36 | * @alias module:main.getWeekStartByRegion 37 | * @see module:api.getWeekStartByRegion 38 | */ 39 | export function getWeekStartByRegion(regionCode) { 40 | return api.getWeekStartByRegion(regionCode, regionDayMap); 41 | } 42 | 43 | /** 44 | * Return first day of week for locale identifier. 45 | * 46 | * Based on data from: 47 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html) 48 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html) 49 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html) 50 | * - [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers) 51 | * 52 | * @example 53 | * getWeekStartByLocale('no'); // 1 54 | * getWeekStartByLocale('Pa_Guru'); // 0 55 | * getWeekStartByLocale('fr-DZ'); // 6 56 | * 57 | * @param {string} locale 58 | * Locale identifier. 59 | * @return {number} 60 | * Code of first day of week for the given locale identifier: 61 | * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday. 62 | * @alias module:main.getWeekStartByLocale 63 | * @see module:api.getWeekStartByLocale 64 | */ 65 | export function getWeekStartByLocale(locale) { 66 | return api.getWeekStartByLocale(locale, langRegionMap, regionDayMap); 67 | } 68 | -------------------------------------------------------------------------------- /src/main.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-env jest */ 2 | 3 | import * as api from './main'; 4 | 5 | describe('main', function mainTestSuite() { 6 | 7 | /* eslint-disable no-magic-numbers */ 8 | 9 | describe('getWeekStartByRegion(regionCode)', () => { 10 | // eslint-disable-next-line require-jsdoc 11 | function verify(code, expected) { 12 | expect( api.getWeekStartByRegion(code) ) 13 | .toBe( expected ); 14 | } 15 | 16 | it('should return correct result for ISO 3166 Alpha-2 code', () => { 17 | verify('bs', 0); 18 | verify('PE', 0); 19 | verify('kw', 6); 20 | verify('SD', 6); 21 | verify('mv', 5); 22 | verify('no', 1); 23 | verify('RU', 1); 24 | }); 25 | 26 | it('should return correct result for ISO 3166 Alpha-3 code', () => { 27 | verify('can', 0); 28 | verify('SLV', 0); 29 | verify('dji', 6); 30 | verify('QAT', 6); 31 | verify('MDV', 5); 32 | verify('esp', 1); 33 | verify('MUS', 1); 34 | }); 35 | 36 | it('should return correct result for ISO 3166 numeric code', () => { 37 | verify(446, 0); 38 | verify(710, 0); 39 | verify(400, 6); 40 | verify(729, 6); 41 | verify(462, 5); 42 | verify(246, 1); 43 | verify(686, 1); 44 | }); 45 | 46 | it('should return 1', () => { 47 | verify(null, 1); 48 | verify(0, 1); 49 | verify('moon', 1); 50 | }); 51 | }); 52 | 53 | describe('getWeekStartByLocale(locale)', () => { 54 | // eslint-disable-next-line require-jsdoc 55 | function verify(locale, expected) { 56 | expect( api.getWeekStartByLocale(locale) ) 57 | .toBe( expected ); 58 | } 59 | 60 | it('should return correct result for locale containing only language code', () => { 61 | verify('HI', 0); 62 | verify('jam', 0); 63 | verify('FA', 6); 64 | }); 65 | 66 | it('should return correct result for locale containing only language code and script', () => { 67 | verify('Ms-arab', 0); 68 | verify('PA_Arab', 0); 69 | verify('az_arab', 6); 70 | verify('Uz-latn', 1); 71 | verify('Pa-Arab', 0); 72 | verify('fa_DEVA', 6); 73 | }); 74 | 75 | it('should return correct result for locale containing only script', () => { 76 | verify('Arab', 6); 77 | verify('deva', 0); 78 | verify('cyrl', 1); 79 | verify('Hans', 1); 80 | verify('hant', 0); 81 | verify('LATN', 1); 82 | verify('Tfng', 1); 83 | verify('THAA', 5); 84 | }); 85 | 86 | it('should return correct result for locale containing only language and region code', () => { 87 | verify('ar-sa', 0); 88 | verify('en_NG', 1); 89 | verify('FR-DZ', 6); 90 | verify('es_mx', 0); 91 | verify('BN-in', 0); 92 | }); 93 | 94 | it('should return correct result for locale containing only script and region code', () => { 95 | verify('ARAB_IN', 0); 96 | verify('arab-IR', 6); 97 | verify('Arab_MN', 1); 98 | verify('Hant_MY', 1); 99 | verify('latn_PY', 0); 100 | }); 101 | 102 | it('should return correct result for locale containing language, script and region code', () => { 103 | verify('az-arab-iq', 6); 104 | verify('az_Arab-TR', 1); 105 | verify('Az-Cyrl_Ru', 1); 106 | verify('zh_Hant_tw', 0); 107 | verify('ZH-HANT_VN', 1); 108 | }); 109 | 110 | it('should return correct result for arbitrary locale', () => { 111 | verify('xyz', 1); 112 | verify('az_arab_IRA', 1); 113 | verify('HI-Fij', 1); 114 | verify('MS_SG_u-data', 0); 115 | verify('en-mv-t-true-DE', 5); 116 | }); 117 | 118 | it('should return 1 for non-found locale', () => { 119 | verify('bej', 1); 120 | verify('ccp', 1); 121 | verify('HR', 1); 122 | verify('vi', 1); 123 | verify('Tfng', 1); 124 | }); 125 | 126 | it('should return 1', () => { 127 | verify(false, 1); 128 | verify('', 1); 129 | verify('some-strange-locale', 1); 130 | verify('Summer moved on', 1); 131 | }); 132 | }); 133 | }); 134 | -------------------------------------------------------------------------------- /src/regionDayMap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains data about first day of week depending on country code. 3 | * 4 | * @module regionDayMap 5 | */ 6 | 7 | 8 | /* eslint quote-props: ['error', 'as-needed', {'keywords': true, 'numbers': false, 'unnecessary': false}] */ 9 | /** 10 | * Data about first day of week depending on country code. 11 | * Based on: 12 | * - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html) 13 | * - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html) 14 | */ 15 | const regionDayMap = { 16 | // Sunday 17 | AG: 0, 18 | ATG: 0, 19 | 28: 0, 20 | AS: 0, 21 | ASM: 0, 22 | 16: 0, 23 | BD: 0, 24 | BGD: 0, 25 | 50: 0, 26 | BR: 0, 27 | BRA: 0, 28 | 76: 0, 29 | BS: 0, 30 | BHS: 0, 31 | 44: 0, 32 | BT: 0, 33 | BTN: 0, 34 | 64: 0, 35 | BW: 0, 36 | BWA: 0, 37 | 72: 0, 38 | BZ: 0, 39 | BLZ: 0, 40 | 84: 0, 41 | CA: 0, 42 | CAN: 0, 43 | 124: 0, 44 | CO: 0, 45 | COL: 0, 46 | 170: 0, 47 | DM: 0, 48 | DMA: 0, 49 | 212: 0, 50 | DO: 0, 51 | DOM: 0, 52 | 214: 0, 53 | ET: 0, 54 | ETH: 0, 55 | 231: 0, 56 | GT: 0, 57 | GTM: 0, 58 | 320: 0, 59 | GU: 0, 60 | GUM: 0, 61 | 316: 0, 62 | HK: 0, 63 | HKG: 0, 64 | 344: 0, 65 | HN: 0, 66 | HND: 0, 67 | 340: 0, 68 | ID: 0, 69 | IDN: 0, 70 | 360: 0, 71 | IL: 0, 72 | ISR: 0, 73 | 376: 0, 74 | IN: 0, 75 | IND: 0, 76 | 356: 0, 77 | JM: 0, 78 | JAM: 0, 79 | 388: 0, 80 | JP: 0, 81 | JPN: 0, 82 | 392: 0, 83 | KE: 0, 84 | KEN: 0, 85 | 404: 0, 86 | KH: 0, 87 | KHM: 0, 88 | 116: 0, 89 | KR: 0, 90 | KOR: 0, 91 | 410: 0, 92 | LA: 0, 93 | LA0: 0, 94 | 418: 0, 95 | MH: 0, 96 | MHL: 0, 97 | 584: 0, 98 | MM: 0, 99 | MMR: 0, 100 | 104: 0, 101 | MO: 0, 102 | MAC: 0, 103 | 446: 0, 104 | MT: 0, 105 | MLT: 0, 106 | 470: 0, 107 | MX: 0, 108 | MEX: 0, 109 | 484: 0, 110 | MZ: 0, 111 | MOZ: 0, 112 | 508: 0, 113 | NI: 0, 114 | NIC: 0, 115 | 558: 0, 116 | NP: 0, 117 | NPL: 0, 118 | 524: 0, 119 | PA: 0, 120 | PAN: 0, 121 | 591: 0, 122 | PE: 0, 123 | PER: 0, 124 | 604: 0, 125 | PH: 0, 126 | PHL: 0, 127 | 608: 0, 128 | PK: 0, 129 | PAK: 0, 130 | 586: 0, 131 | PR: 0, 132 | PRI: 0, 133 | 630: 0, 134 | PT: 0, 135 | PRT: 0, 136 | 620: 0, 137 | PY: 0, 138 | PRY: 0, 139 | 600: 0, 140 | SA: 0, 141 | SAU: 0, 142 | 682: 0, 143 | SG: 0, 144 | SGP: 0, 145 | 702: 0, 146 | SV: 0, 147 | SLV: 0, 148 | 222: 0, 149 | TH: 0, 150 | THA: 0, 151 | 764: 0, 152 | TT: 0, 153 | TTO: 0, 154 | 780: 0, 155 | TW: 0, 156 | TWN: 0, 157 | 158: 0, 158 | UM: 0, 159 | UMI: 0, 160 | 581: 0, 161 | US: 0, 162 | USA: 0, 163 | 840: 0, 164 | VE: 0, 165 | VEN: 0, 166 | 862: 0, 167 | VI: 0, 168 | VIR: 0, 169 | 850: 0, 170 | WS: 0, 171 | WSM: 0, 172 | 882: 0, 173 | YE: 0, 174 | YEM: 0, 175 | 887: 0, 176 | ZA: 0, 177 | ZAF: 0, 178 | 710: 0, 179 | ZW: 0, 180 | ZWE: 0, 181 | 716: 0, 182 | 183 | // Saturday 184 | AE: 6, 185 | ARE: 6, 186 | 784: 6, 187 | AF: 6, 188 | AFG: 6, 189 | 4: 6, 190 | BH: 6, 191 | BHR: 6, 192 | 48: 6, 193 | DJ: 6, 194 | DJI: 6, 195 | 262: 6, 196 | DZ: 6, 197 | DZA: 6, 198 | 12: 6, 199 | EG: 6, 200 | EGY: 6, 201 | 818: 6, 202 | IQ: 6, 203 | IRQ: 6, 204 | 368: 6, 205 | IR: 6, 206 | IRN: 6, 207 | 364: 6, 208 | JO: 6, 209 | JOR: 6, 210 | 400: 6, 211 | KW: 6, 212 | KWT: 6, 213 | 414: 6, 214 | LY: 6, 215 | LBY: 6, 216 | 434: 6, 217 | OM: 6, 218 | OMN: 6, 219 | 512: 6, 220 | QA: 6, 221 | QAT: 6, 222 | 634: 6, 223 | SD: 6, 224 | SDN: 6, 225 | 729: 6, 226 | SY: 6, 227 | SYR: 6, 228 | 760: 6, 229 | 230 | // Friday 231 | MV: 5, 232 | MDV: 5, 233 | 462: 5 234 | 235 | // Else - Monday 236 | }; 237 | 238 | export default regionDayMap; 239 | --------------------------------------------------------------------------------