| 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 Index</title> |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 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-8"> |
| 64 |
|
| 65 |
<div id="main"> |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
<section class="readme-section"> |
| 89 |
<article><h1>weekstart <a name="start"></a></h1><p><a href="http://badge.fury.io/js/weekstart"><img src="https://badge.fury.io/js/weekstart.png" alt="NPM version"></a></p> |
| 90 |
<p>Library to get first day of week.</p> |
| 91 |
<pre class="prettyprint source lang-js"><code>getWeekStartByRegion('MAC'); // 0 |
| 92 |
|
| 93 |
getWeekStartByLocale('arq'); // 6</code></pre><p>The library is based on the following data from Unicode (especially from Common Locale Data Repository) and from ISO:</p> |
| 94 |
<ul> |
| 95 |
<li><a href="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</a></li> |
| 96 |
<li><a href="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</a></li> |
| 97 |
<li><a href="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</a></li> |
| 98 |
<li><a href="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</a></li> |
| 99 |
<li><a href="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</a></li> |
| 100 |
<li><a href="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</a></li> |
| 101 |
<li><a href="https://www.iso.org/iso-3166-country-codes.html">https://www.iso.org/iso-3166-country-codes.html</a></li> |
| 102 |
</ul> |
| 103 |
<p>There are 2 variants of the library having identical <a href="#api">API</a>:</p> |
| 104 |
<ul> |
| 105 |
<li><code>main</code> - uses base mapping of language code to country code from <a href="https://github.com/gamtiq/weekstart/blob/master/src/langRegionMap.js">langRegionMap</a>.</li> |
| 106 |
<li><code>full</code> - uses full mapping of language code to country code from <a href="https://github.com/gamtiq/weekstart/blob/master/src/fullLangRegionMap.js">fullLangRegionMap</a>.</li> |
| 107 |
</ul> |
| 108 |
<p><a href="https://github.com/gamtiq/weekstart/blob/master/src/langRegionMap.js">langRegionMap</a> contains only main language codes. |
| 109 |
It is data subset from <a href="https://github.com/gamtiq/weekstart/blob/master/src/fullLangRegionMap.js">fullLangRegionMap</a>.</p> |
| 110 |
<h2>Table of contents</h2><ul> |
| 111 |
<li><a href="#install">Installation</a></li> |
| 112 |
<li><a href="#usage">Usage</a></li> |
| 113 |
<li><a href="#examples">Examples</a></li> |
| 114 |
<li><a href="#api">API</a></li> |
| 115 |
<li><a href="#contributing">Contributing</a></li> |
| 116 |
<li><a href="#license">License</a></li> |
| 117 |
</ul> |
| 118 |
<h2>Installation <a name="install"></a> <a href="#start">↑</a></h2><h3>Node</h3><pre class="prettyprint source"><code>npm install weekstart</code></pre><h3><a href="http://bower.io">Bower</a></h3><pre class="prettyprint source"><code>bower install weekstart</code></pre><h3>AMD/UMD, <script></h3><p>Use <code>dist/main.js</code> or <code>dist/min/main.js</code> (minified version). |
| 119 |
Use <code>dist/full.js</code> or <code>dist/min/full.js</code> (minified version) when you need full locale data.</p> |
| 120 |
<h2>Usage <a name="usage"></a> <a href="#start">↑</a></h2><h3>ECMAScript 6</h3><pre class="prettyprint source lang-js"><code>import {getWeekStartByLocale, getWeekStartByRegion} from 'weekstart';</code></pre><p>If you need full data:</p> |
| 121 |
<pre class="prettyprint source lang-js"><code>import {getWeekStartByLocale, getWeekStartByRegion} from 'weekstart/full';</code></pre><h3>Node</h3><pre class="prettyprint source lang-js"><code>const getWeekStartByLocale = require('weekstart').getWeekStartByLocale; |
| 122 |
const getWeekStartByRegion = require('weekstart').getWeekStartByRegion;</code></pre><p>If you need full data:</p> |
| 123 |
<pre class="prettyprint source lang-js"><code>const getWeekStartByLocale = require('weekstart/full').getWeekStartByLocale; |
| 124 |
const getWeekStartByRegion = require('weekstart/full').getWeekStartByRegion;</code></pre><h3>AMD/UMD</h3><pre class="prettyprint source lang-js"><code>define(['path/to/dist/main.js'], function(weekstart) { |
| 125 |
const getWeekStartByLocale = weekstart.getWeekStartByLocale; |
| 126 |
const getWeekStartByRegion = weekstart.getWeekStartByRegion; |
| 127 |
});</code></pre><p>If you need full data:</p> |
| 128 |
<pre class="prettyprint source lang-js"><code>define(['path/to/dist/full.js'], function(weekstart) { |
| 129 |
const getWeekStartByLocale = weekstart.getWeekStartByLocale; |
| 130 |
const getWeekStartByRegion = weekstart.getWeekStartByRegion; |
| 131 |
});</code></pre><h3>Bower, <script></h3><pre class="prettyprint source lang-html"><code><!-- Use bower_components/weekstart/dist/main.js and bower_components/weekstart/dist/full.js if the library was installed by Bower --> |
| 132 |
<script type="text/javascript" src="path/to/dist/main.js"></script> |
| 133 |
<script type="text/javascript"> |
| 134 |
// weekstart is available via weekstart field of window object |
| 135 |
const getWeekStartByLocale = weekstart.getWeekStartByLocale; |
| 136 |
const getWeekStartByRegion = weekstart.getWeekStartByRegion; |
| 137 |
</script></code></pre><p>If you need full data use <code>path/to/dist/full.js</code> instead of <code>path/to/dist/main.js</code>.</p> |
| 138 |
<h2>Examples <a name="examples"></a> <a href="#start">↑</a></h2><pre class="prettyprint source lang-js"><code>getWeekStartByRegion('dj'); // 6 |
| 139 |
getWeekStartByRegion('No'); // 1 |
| 140 |
getWeekStartByRegion('CAN'); // 0 |
| 141 |
getWeekStartByRegion(462); // 5 |
| 142 |
|
| 143 |
getWeekStartByLocale('Jam'); // 0 |
| 144 |
getWeekStartByLocale('Fa'); // 6 |
| 145 |
getWeekStartByLocale('vi'); // 1 |
| 146 |
getWeekStartByLocale('es_MX'); // 0 |
| 147 |
getWeekStartByLocale('az-Arab-IRN'); // 6</code></pre><p>In the following examples results are given for the function from <code>full.js</code>. |
| 148 |
The same calls for the function from <code>main.js</code> will return <code>1</code>.</p> |
| 149 |
<pre class="prettyprint source lang-js"><code>getWeekStartByLocale('CCP'); // 0 |
| 150 |
getWeekStartByLocale('UZ-arab'); // 6</code></pre><h2>API <a name="api"></a> <a href="#start">↑</a></h2><h4>getWeekStartByLocale(locale): number</h4><p>Return first day of week for locale identifier: |
| 151 |
0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.</p> |
| 152 |
<h4>getWeekStartByRegion(regionCode): number</h4><p>Return first day of week for country/region code: |
| 153 |
0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.</p> |
| 154 |
<p>See <a href="https://gamtiq.github.io/weekstart/"><code>docs</code></a> for details.</p> |
| 155 |
<h2>Contributing <a name="contributing"></a> <a href="#start">↑</a></h2><p>In lieu of a formal styleguide, take care to maintain the existing coding style. |
| 156 |
Add unit tests for any new or changed functionality. |
| 157 |
Lint and test your code.</p> |
| 158 |
<h2>License <a name="license"></a> <a href="#start">↑</a></h2><p>Licensed under the <a href="https://github.com/gamtiq/weekstart/blob/master/LICENSE">MIT license</a>.</p></article> |
| 159 |
</section> |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
</div> |
| 168 |
</div> |
| 169 |
|
| 170 |
<div class="clearfix"></div> |
| 171 |
|
| 172 |
|
| 173 |
<div class="col-md-3"> |
| 174 |
<div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div> |
| 175 |
</div> |
| 176 |
|
| 177 |
|
| 178 |
</div> |
| 179 |
</div> |
| 180 |
|
| 181 |
|
| 182 |
<div class="modal fade" id="searchResults"> |
| 183 |
<div class="modal-dialog"> |
| 184 |
<div class="modal-content"> |
| 185 |
<div class="modal-header"> |
| 186 |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
| 187 |
<h4 class="modal-title">Search results</h4> |
| 188 |
</div> |
| 189 |
<div class="modal-body"></div> |
| 190 |
<div class="modal-footer"> |
| 191 |
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
| 192 |
</div> |
| 193 |
</div> |
| 194 |
</div> |
| 195 |
</div> |
| 196 |
|
| 197 |
|
| 198 |
<footer> |
| 199 |
|
| 200 |
|
| 201 |
<span class="copyright"> |
| 202 |
Copyright (c) 2017-present Denis Sikuler |
| 203 |
</span> |
| 204 |
|
| 205 |
<span class="jsdoc-message"> |
| 206 |
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> |
| 207 |
|
| 208 |
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>. |
| 209 |
</span> |
| 210 |
</footer> |
| 211 |
|
| 212 |
<script src="scripts/docstrap.lib.js"></script> |
| 213 |
<script src="scripts/toc.js"></script> |
| 214 |
|
| 215 |
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script> |
| 216 |
|
| 217 |
|
| 218 |
<script> |
| 219 |
$( function () { |
| 220 |
$( "[id*='$']" ).each( function () { |
| 221 |
var $this = $( this ); |
| 222 |
|
| 223 |
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) ); |
| 224 |
} ); |
| 225 |
|
| 226 |
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () { |
| 227 |
var $this = $( this ); |
| 228 |
|
| 229 |
var example = $this.find( "code" ); |
| 230 |
exampleText = example.html(); |
| 231 |
var lang = /{@lang (.*?)}/.exec( exampleText ); |
| 232 |
if ( lang && lang[1] ) { |
| 233 |
exampleText = exampleText.replace( lang[0], "" ); |
| 234 |
example.html( exampleText ); |
| 235 |
lang = lang[1]; |
| 236 |
} else { |
| 237 |
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/); |
| 238 |
lang = langClassMatch ? langClassMatch[1] : "javascript"; |
| 239 |
} |
| 240 |
|
| 241 |
if ( lang ) { |
| 242 |
|
| 243 |
$this |
| 244 |
.addClass( "sunlight-highlight-" + lang ) |
| 245 |
.addClass( "linenums" ) |
| 246 |
.html( example.html() ); |
| 247 |
|
| 248 |
} |
| 249 |
} ); |
| 250 |
|
| 251 |
Sunlight.highlightAll( { |
| 252 |
lineNumbers : true, |
| 253 |
showMenu : true, |
| 254 |
enableDoclinks : true |
| 255 |
} ); |
| 256 |
|
| 257 |
$.catchAnchorLinks( { |
| 258 |
navbarOffset: 10 |
| 259 |
} ); |
| 260 |
$( "#toc" ).toc( { |
| 261 |
anchorName : function ( i, heading, prefix ) { |
| 262 |
return $( heading ).attr( "id" ) || ( prefix + i ); |
| 263 |
}, |
| 264 |
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4", |
| 265 |
showAndHide : false, |
| 266 |
smoothScrolling: true |
| 267 |
} ); |
| 268 |
|
| 269 |
$( "#main span[id^='toc']" ).addClass( "toc-shim" ); |
| 270 |
$( '.dropdown-toggle' ).dropdown(); |
| 271 |
|
| 272 |
$( "table" ).each( function () { |
| 273 |
var $this = $( this ); |
| 274 |
$this.addClass('table'); |
| 275 |
} ); |
| 276 |
|
| 277 |
} ); |
| 278 |
</script> |
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
<script type="text/javascript"> |
| 290 |
$(document).ready(function() { |
| 291 |
SearcherDisplay.init(); |
| 292 |
}); |
| 293 |
</script> |
| 294 |
|
| 295 |
|
| 296 |
</body> |
| 297 |
</html> |