Debian Codegraph @

docs/api.js.html

raw symbols SCIP
1 <!DOCTYPE html>
2
3 <html lang="en">
4 <head>
5 <meta charset="utf-8">
6 <meta name="viewport" content="width=device-width">
7 <title>weekstart Source: api.js</title>
8
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
13
14 <link type="text/css" rel="stylesheet" href="styles/site.spacelab.css">
15
16 </head>
17
18 <body>
19
20 <div class="navbar navbar-default navbar-fixed-top ">
21 <div class="container">
22 <div class="navbar-header">
23 <a class="navbar-brand" href="index.html">weekstart</a>
24 <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
25 <span class="icon-bar"></span>
26 <span class="icon-bar"></span>
27 <span class="icon-bar"></span>
28 </button>
29 </div>
30 <div class="navbar-collapse collapse" id="topNavigation">
31 <ul class="nav navbar-nav">
32
33 <li class="dropdown">
34 <a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b class="caret"></b></a>
35 <ul class="dropdown-menu ">
36 <li><a href="module-api.html">api</a></li><li><a href="module-full.html">full</a></li><li><a href="module-fullLangRegionMap.html">fullLangRegionMap</a></li><li><a href="module-langRegionMap.html">langRegionMap</a></li><li><a href="module-main.html">main</a></li><li><a href="module-regionDayMap.html">regionDayMap</a></li>
37 </ul>
38 </li>
39
40 </ul>
41
42 <div class="col-sm-3 col-md-3">
43 <form class="navbar-form" role="search">
44 <div class="input-group">
45 <input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
46 <div class="input-group-btn">
47 <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
48 </div>
49 </div>
50 </form>
51 </div>
52
53 </div>
54
55 </div>
56 </div>
57
58
59 <div class="container" id="toc-content">
60 <div class="row">
61
62
63 <div class="col-md-12">
64
65 <div id="main">
66
67
68 <h1 class="page-title">Source: api.js</h1>
69
70 <section>
71 <article>
72 <pre
73 class="sunlight-highlight-javascript linenums">/**
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] &amp;&amp; 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 </pre>
163 </article>
164 </section>
165
166
167
168
169
170 </div>
171 </div>
172
173 <div class="clearfix"></div>
174
175
176
177 </div>
178 </div>
179
180
181 <div class="modal fade" id="searchResults">
182 <div class="modal-dialog">
183 <div class="modal-content">
184 <div class="modal-header">
185 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
186 <h4 class="modal-title">Search results</h4>
187 </div>
188 <div class="modal-body"></div>
189 <div class="modal-footer">
190 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
191 </div>
192 </div><!-- /.modal-content -->
193 </div><!-- /.modal-dialog -->
194 </div>
195
196
197 <footer>
198
199
200 <span class="copyright">
201 Copyright (c) 2017-present Denis Sikuler
202 </span>
203
204 <span class="jsdoc-message">
205 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
206
207 using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
208 </span>
209 </footer>
210
211 <script src="scripts/docstrap.lib.js"></script>
212 <script src="scripts/toc.js"></script>
213
214 <script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
215
216
217 <script>
218 $( function () {
219 $( "[id*='$']" ).each( function () {
220 var $this = $( this );
221
222 $this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
223 } );
224
225 $( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
226 var $this = $( this );
227
228 var example = $this.find( "code" );
229 exampleText = example.html();
230 var lang = /{@lang (.*?)}/.exec( exampleText );
231 if ( lang && lang[1] ) {
232 exampleText = exampleText.replace( lang[0], "" );
233 example.html( exampleText );
234 lang = lang[1];
235 } else {
236 var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
237 lang = langClassMatch ? langClassMatch[1] : "javascript";
238 }
239
240 if ( lang ) {
241
242 $this
243 .addClass( "sunlight-highlight-" + lang )
244 .addClass( "linenums" )
245 .html( example.html() );
246
247 }
248 } );
249
250 Sunlight.highlightAll( {
251 lineNumbers : true,
252 showMenu : true,
253 enableDoclinks : true
254 } );
255
256 $.catchAnchorLinks( {
257 navbarOffset: 10
258 } );
259 $( "#toc" ).toc( {
260 anchorName : function ( i, heading, prefix ) {
261 return $( heading ).attr( "id" ) || ( prefix + i );
262 },
263 selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
264 showAndHide : false,
265 smoothScrolling: true
266 } );
267
268 $( "#main span[id^='toc']" ).addClass( "toc-shim" );
269 $( '.dropdown-toggle' ).dropdown();
270
271 $( "table" ).each( function () {
272 var $this = $( this );
273 $this.addClass('table');
274 } );
275
276 } );
277 </script>
278
279
280
281 <!--Navigation and Symbol Display-->
282
283
284 <!--Google Analytics-->
285
286
287
288 <script type="text/javascript">
289 $(document).ready(function() {
290 SearcherDisplay.init();
291 });
292 </script>
293
294
295 </body>
296 </html>