Commit 7f299165dfdb1b8cef96a203cbfce15ae8d51646

Authored by Renato De Donato
2 parents fb05b400 d004e0cb

Merge branch 'master' of http://service.routetopa.eu:7480/WebCompDev/COMPONENTS

Showing 43 changed files with 17694 additions and 406 deletions
bower.json
... ... @@ -18,6 +18,7 @@
18 18 "paper-fab-transitions": "~0.1.0",
19 19 "paper-scroll-header-panel": "PolymerElements/paper-scroll-header-panel#~1.0.14",
20 20 "iron-icon": "PolymerElements/iron-icon#~1.0.7",
21   - "iron-icons": "PolymerElements/iron-icons#~1.1.2"
  21 + "iron-icons": "PolymerElements/iron-icons#~1.1.2",
  22 + "paper-toast": "PolymerElements/paper-toast#~1.2.1"
22 23 }
23 24 }
... ...
bower_components/moment-element/.gitignore 0 → 100644
  1 +bower_components/
... ...
bower_components/moment-element/.travis.yml 0 → 100644
  1 +language: node_js
  2 +sudo: false
  3 +node_js:
  4 + - '5.1'
  5 +before_script:
  6 + - 'export DISPLAY=:99.0'
  7 + - sh -e /etc/init.d/xvfb start
  8 + - sleep 3
  9 + - npm i -g bower
  10 + - bower i
... ...
bower_components/moment-element/README.md 0 → 100644
  1 +[![Build status](https://travis-ci.org/abdonrd/moment-element.svg?branch=master)](https://travis-ci.org/abdonrd/moment-element)
  2 +
  3 +_[Demo and API docs](https://abdonrd.github.io/moment-element/)_
  4 +
  5 +## <moment-element>
  6 +
  7 +Polymer element wrapper for the [moment](https://github.com/moment/moment) library.
  8 +
  9 +### Install
  10 +
  11 +```sh
  12 +bower install moment-element
  13 +```
  14 +
  15 +### Use
  16 +
  17 +```html
  18 +<moment-element></moment-element>
  19 +<moment-element datetime="1991-12-31" output-format="MMM DD[,] YYYY"></moment-element>
  20 +```
... ...
bower_components/moment-element/bower.json 0 → 100644
  1 +{
  2 + "name": "moment-element",
  3 + "version": "0.3.0",
  4 + "authors": [
  5 + "Abdón Rodríguez Davila <a@abdonrd.com>"
  6 + ],
  7 + "description": "Polymer element wrapper for the moment library",
  8 + "keywords": [
  9 + "web-component",
  10 + "polymer",
  11 + "moment",
  12 + "date",
  13 + "time",
  14 + "parse",
  15 + "format"
  16 + ],
  17 + "main": "moment-element.html",
  18 + "repository": {
  19 + "type": "git",
  20 + "url": "git://github.com/abdonrd/moment-element.git"
  21 + },
  22 + "license": "MIT",
  23 + "homepage": "https://github.com/abdonrd/moment-element",
  24 + "ignore": [
  25 + "/.*",
  26 + "/test/"
  27 + ],
  28 + "dependencies": {
  29 + "polymer": "Polymer/polymer#^1.2.0",
  30 + "moment": "~2.11.2"
  31 + },
  32 + "devDependencies": {
  33 + "iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
  34 + "iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
  35 + "web-component-tester": "^3.4.0"
  36 + }
  37 +}
... ...
bower_components/moment-element/demo/index.html 0 → 100644
  1 +<!doctype html>
  2 +<!--
  3 +@license
  4 +Copyright (c) 2015 Abdón Rodríguez Davila (@abdonrd). All rights reserved.
  5 +This code may only be used under the MIT license.
  6 +-->
  7 +<html>
  8 + <head>
  9 + <meta charset="utf-8">
  10 + <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
  11 + <title>momentjs-element demo</title>
  12 +
  13 + <script src="../../webcomponentsjs/webcomponents-lite.min.js"></script>
  14 +
  15 + <link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
  16 + <link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
  17 + <link rel="import" href="../moment-element.html">
  18 +
  19 + <style is="custom-style" include="demo-pages-shared-styles">
  20 + .vertical-section-container {
  21 + max-width: 550px;
  22 + }
  23 +
  24 + moment-element {
  25 + display: block;
  26 + }
  27 + </style>
  28 + </head>
  29 + <body unresolved>
  30 + <div class="vertical-section-container centered">
  31 + <h3>Current date and date from string (ISO 8601 and another)</h3>
  32 + <demo-snippet>
  33 + <template>
  34 + <moment-element></moment-element>
  35 + <moment-element datetime="1991-12-31"></moment-element>
  36 + <moment-element datetime="12-31-1991" input-format="MM-DD-YYYY"></moment-element>
  37 + </template>
  38 + </demo-snippet>
  39 +
  40 + <h3>Date from string + format</h3>
  41 + <demo-snippet>
  42 + <template>
  43 + <moment-element datetime="1991-12-31" output-format="l"></moment-element>
  44 + <moment-element datetime="12-31-1991" input-format="MM-DD-YYYY" output-format="l"></moment-element>
  45 + <moment-element datetime="1991-12-31" output-format="MMM DD[,] YYYY"></moment-element>
  46 + </template>
  47 + </demo-snippet>
  48 +
  49 + <h3>Date from now or from custom date</h3>
  50 + <demo-snippet>
  51 + <template>
  52 + <moment-element datetime="1991-12-31" from="now"></moment-element>
  53 + <moment-element datetime="1991-12-31" from="2003-06-23"></moment-element>
  54 + </template>
  55 + </demo-snippet>
  56 +
  57 + <h3>Date to now or to custom date</h3>
  58 + <demo-snippet>
  59 + <template>
  60 + <moment-element datetime="1991-12-31" to="now"></moment-element>
  61 + <moment-element datetime="1991-12-31" to="2003-06-23"></moment-element>
  62 + </template>
  63 + </demo-snippet>
  64 + </div>
  65 + </body>
  66 +</html>
... ...
bower_components/moment-element/index.html 0 → 100644
  1 +<!doctype html>
  2 +<!--
  3 +@license
  4 +Copyright (c) 2015 Abdón Rodríguez Davila (@abdonrd). All rights reserved.
  5 +This code may only be used under the MIT license.
  6 +-->
  7 +<html>
  8 + <head>
  9 + <meta charset="utf-8">
  10 + <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11 +
  12 + <script src="../webcomponentsjs/webcomponents-lite.js"></script>
  13 +
  14 + <link rel="import" href="../iron-component-page/iron-component-page.html">
  15 + </head>
  16 + <body unresolved>
  17 + <iron-component-page></iron-component-page>
  18 + </body>
  19 +</html>
... ...
bower_components/moment-element/moment-element.html 0 → 100644
  1 +<!--
  2 +@license
  3 +Copyright (c) 2015 Abdón Rodríguez Davila (@abdonrd). All rights reserved.
  4 +This code may only be used under the MIT license.
  5 +-->
  6 +
  7 +<link rel="import" href="../polymer/polymer.html">
  8 +<link rel="import" href="moment-import.html">
  9 +
  10 +<!--
  11 +Polymer element wrapper for the [moment](https://github.com/moment/moment) library.
  12 +
  13 +Examples:
  14 +
  15 + <moment-element></moment-element>
  16 + <moment-element datetime="1991-12-31" output-format="MMM DD[,] YYYY"></moment-element>
  17 +
  18 +@demo demo/index.html
  19 +-->
  20 +
  21 +<dom-module id="moment-element">
  22 + <template>
  23 +
  24 + </template>
  25 +
  26 + <script>
  27 + Polymer({
  28 + is: 'moment-element',
  29 +
  30 + properties: {
  31 + /**
  32 + * The input datetime. If don't set the datetime, the datetime will be now.
  33 + * For consistent results, parsing anything other than ISO 8601 strings
  34 + * with the `inputFormat` property. More information in [moment String](http://momentjs.com/docs/#/parsing/string/).
  35 + */
  36 + datetime: String,
  37 +
  38 + /**
  39 + * The datetime input format. An string using the
  40 + * [moment String + Format](http://momentjs.com/docs/#/parsing/string-format/).
  41 + */
  42 + inputFormat: String,
  43 +
  44 + /**
  45 + * The datetime output format. Options are 'now' or datetime using the
  46 + * [moment Format](http://momentjs.com/docs/#/displaying/format/).
  47 + */
  48 + outputFormat: String,
  49 +
  50 + /**
  51 + * Relative time using [momen time from now](http://momentjs.com/docs/#/displaying/fromnow/)
  52 + * or [momen Time from datetime](http://momentjs.com/docs/#/displaying/from/).
  53 + */
  54 + from: String,
  55 +
  56 + /**
  57 + * Relative time using [momen Time to now](http://momentjs.com/docs/#/displaying/tonow/)
  58 + * or [momen Time to datetime](http://momentjs.com/docs/#/displaying/to/).
  59 + */
  60 + to: String,
  61 +
  62 + /**
  63 + * The output datetime.
  64 + */
  65 + output: String
  66 + },
  67 +
  68 + ready: function() {
  69 + this.output = this._initializeMoment();
  70 +
  71 + if (this.from) {
  72 + this.output = this._getFrom();
  73 + } else if (this.to) {
  74 + this.output = this._getTo();
  75 + }
  76 +
  77 + Polymer.dom(this.root).innerHTML = this.output;
  78 + },
  79 +
  80 + _initializeMoment: function() {
  81 + if (this.datetime && this.inputFormat) {
  82 + var output = moment(this.datetime, this.inputFormat);
  83 + } else if (this.datetime) {
  84 + var output = moment(this.datetime);
  85 + } else {
  86 + var output = moment();
  87 + }
  88 +
  89 + if (this.outputFormat) {
  90 + return output.format(this.outputFormat);
  91 + } else {
  92 + return output;
  93 + }
  94 + },
  95 +
  96 + _getFrom: function() {
  97 + if (this.from === 'now') {
  98 + return this.output.fromNow();
  99 + } else {
  100 + return this.output.from(moment(this.from));
  101 + }
  102 + },
  103 +
  104 + _getTo: function() {
  105 + if (this.to === 'now') {
  106 + return this.output.toNow();
  107 + } else {
  108 + return this.output.to(moment(this.to));
  109 + }
  110 + }
  111 + });
  112 + </script>
  113 +</dom-module>
... ...
bower_components/moment-element/moment-import.html 0 → 100644
  1 +<!--
  2 +@license
  3 +Copyright (c) 2015 Abdón Rodríguez Davila (@abdonrd). All rights reserved.
  4 +This code may only be used under the MIT license.
  5 +-->
  6 +
  7 +<script src="moment/moment.js"></script>
... ...
bower_components/moment-element/moment-with-locales-import.html 0 → 100644
  1 +<script src='moment/moment-with-locales.js'></script>
... ...
bower_components/moment-element/moment/moment-with-locales-import.html 0 → 100644
  1 +<script src='../moment/min/moment-with-locales.min.js'></script>
... ...
bower_components/moment-element/moment/moment-with-locales.js 0 → 100644
Changes suppressed. Click to show
  1 +;(function (global, factory) {
  2 + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  3 + typeof define === 'function' && define.amd ? define(factory) :
  4 + global.moment = factory()
  5 +}(this, function () { 'use strict';
  6 +
  7 + var hookCallback;
  8 +
  9 + function utils_hooks__hooks () {
  10 + return hookCallback.apply(null, arguments);
  11 + }
  12 +
  13 + // This is done to register the method called with moment()
  14 + // without creating circular dependencies.
  15 + function setHookCallback (callback) {
  16 + hookCallback = callback;
  17 + }
  18 +
  19 + function isArray(input) {
  20 + return Object.prototype.toString.call(input) === '[object Array]';
  21 + }
  22 +
  23 + function isDate(input) {
  24 + return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
  25 + }
  26 +
  27 + function map(arr, fn) {
  28 + var res = [], i;
  29 + for (i = 0; i < arr.length; ++i) {
  30 + res.push(fn(arr[i], i));
  31 + }
  32 + return res;
  33 + }
  34 +
  35 + function hasOwnProp(a, b) {
  36 + return Object.prototype.hasOwnProperty.call(a, b);
  37 + }
  38 +
  39 + function extend(a, b) {
  40 + for (var i in b) {
  41 + if (hasOwnProp(b, i)) {
  42 + a[i] = b[i];
  43 + }
  44 + }
  45 +
  46 + if (hasOwnProp(b, 'toString')) {
  47 + a.toString = b.toString;
  48 + }
  49 +
  50 + if (hasOwnProp(b, 'valueOf')) {
  51 + a.valueOf = b.valueOf;
  52 + }
  53 +
  54 + return a;
  55 + }
  56 +
  57 + function create_utc__createUTC (input, format, locale, strict) {
  58 + return createLocalOrUTC(input, format, locale, strict, true).utc();
  59 + }
  60 +
  61 + function defaultParsingFlags() {
  62 + // We need to deep clone this object.
  63 + return {
  64 + empty : false,
  65 + unusedTokens : [],
  66 + unusedInput : [],
  67 + overflow : -2,
  68 + charsLeftOver : 0,
  69 + nullInput : false,
  70 + invalidMonth : null,
  71 + invalidFormat : false,
  72 + userInvalidated : false,
  73 + iso : false
  74 + };
  75 + }
  76 +
  77 + function getParsingFlags(m) {
  78 + if (m._pf == null) {
  79 + m._pf = defaultParsingFlags();
  80 + }
  81 + return m._pf;
  82 + }
  83 +
  84 + function valid__isValid(m) {
  85 + if (m._isValid == null) {
  86 + var flags = getParsingFlags(m);
  87 + m._isValid = !isNaN(m._d.getTime()) &&
  88 + flags.overflow < 0 &&
  89 + !flags.empty &&
  90 + !flags.invalidMonth &&
  91 + !flags.invalidWeekday &&
  92 + !flags.nullInput &&
  93 + !flags.invalidFormat &&
  94 + !flags.userInvalidated;
  95 +
  96 + if (m._strict) {
  97 + m._isValid = m._isValid &&
  98 + flags.charsLeftOver === 0 &&
  99 + flags.unusedTokens.length === 0 &&
  100 + flags.bigHour === undefined;
  101 + }
  102 + }
  103 + return m._isValid;
  104 + }
  105 +
  106 + function valid__createInvalid (flags) {
  107 + var m = create_utc__createUTC(NaN);
  108 + if (flags != null) {
  109 + extend(getParsingFlags(m), flags);
  110 + }
  111 + else {
  112 + getParsingFlags(m).userInvalidated = true;
  113 + }
  114 +
  115 + return m;
  116 + }
  117 +
  118 + function isUndefined(input) {
  119 + return input === void 0;
  120 + }
  121 +
  122 + // Plugins that add properties should also add the key here (null value),
  123 + // so we can properly clone ourselves.
  124 + var momentProperties = utils_hooks__hooks.momentProperties = [];
  125 +
  126 + function copyConfig(to, from) {
  127 + var i, prop, val;
  128 +
  129 + if (!isUndefined(from._isAMomentObject)) {
  130 + to._isAMomentObject = from._isAMomentObject;
  131 + }
  132 + if (!isUndefined(from._i)) {
  133 + to._i = from._i;
  134 + }
  135 + if (!isUndefined(from._f)) {
  136 + to._f = from._f;
  137 + }
  138 + if (!isUndefined(from._l)) {
  139 + to._l = from._l;
  140 + }
  141 + if (!isUndefined(from._strict)) {
  142 + to._strict = from._strict;
  143 + }
  144 + if (!isUndefined(from._tzm)) {
  145 + to._tzm = from._tzm;
  146 + }
  147 + if (!isUndefined(from._isUTC)) {
  148 + to._isUTC = from._isUTC;
  149 + }
  150 + if (!isUndefined(from._offset)) {
  151 + to._offset = from._offset;
  152 + }
  153 + if (!isUndefined(from._pf)) {
  154 + to._pf = getParsingFlags(from);
  155 + }
  156 + if (!isUndefined(from._locale)) {
  157 + to._locale = from._locale;
  158 + }
  159 +
  160 + if (momentProperties.length > 0) {
  161 + for (i in momentProperties) {
  162 + prop = momentProperties[i];
  163 + val = from[prop];
  164 + if (!isUndefined(val)) {
  165 + to[prop] = val;
  166 + }
  167 + }
  168 + }
  169 +
  170 + return to;
  171 + }
  172 +
  173 + var updateInProgress = false;
  174 +
  175 + // Moment prototype object
  176 + function Moment(config) {
  177 + copyConfig(this, config);
  178 + this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  179 + // Prevent infinite loop in case updateOffset creates new moment
  180 + // objects.
  181 + if (updateInProgress === false) {
  182 + updateInProgress = true;
  183 + utils_hooks__hooks.updateOffset(this);
  184 + updateInProgress = false;
  185 + }
  186 + }
  187 +
  188 + function isMoment (obj) {
  189 + return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
  190 + }
  191 +
  192 + function absFloor (number) {
  193 + if (number < 0) {
  194 + return Math.ceil(number);
  195 + } else {
  196 + return Math.floor(number);
  197 + }
  198 + }
  199 +
  200 + function toInt(argumentForCoercion) {
  201 + var coercedNumber = +argumentForCoercion,
  202 + value = 0;
  203 +
  204 + if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  205 + value = absFloor(coercedNumber);
  206 + }
  207 +
  208 + return value;
  209 + }
  210 +
  211 + // compare two arrays, return the number of differences
  212 + function compareArrays(array1, array2, dontConvert) {
  213 + var len = Math.min(array1.length, array2.length),
  214 + lengthDiff = Math.abs(array1.length - array2.length),
  215 + diffs = 0,
  216 + i;
  217 + for (i = 0; i < len; i++) {
  218 + if ((dontConvert && array1[i] !== array2[i]) ||
  219 + (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
  220 + diffs++;
  221 + }
  222 + }
  223 + return diffs + lengthDiff;
  224 + }
  225 +
  226 + function Locale() {
  227 + }
  228 +
  229 + // internal storage for locale config files
  230 + var locales = {};
  231 + var globalLocale;
  232 +
  233 + function normalizeLocale(key) {
  234 + return key ? key.toLowerCase().replace('_', '-') : key;
  235 + }
  236 +
  237 + // pick the locale from the array
  238 + // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  239 + // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  240 + function chooseLocale(names) {
  241 + var i = 0, j, next, locale, split;
  242 +
  243 + while (i < names.length) {
  244 + split = normalizeLocale(names[i]).split('-');
  245 + j = split.length;
  246 + next = normalizeLocale(names[i + 1]);
  247 + next = next ? next.split('-') : null;
  248 + while (j > 0) {
  249 + locale = loadLocale(split.slice(0, j).join('-'));
  250 + if (locale) {
  251 + return locale;
  252 + }
  253 + if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
  254 + //the next array item is better than a shallower substring of this one
  255 + break;
  256 + }
  257 + j--;
  258 + }
  259 + i++;
  260 + }
  261 + return null;
  262 + }
  263 +
  264 + function loadLocale(name) {
  265 + var oldLocale = null;
  266 + // TODO: Find a better way to register and load all the locales in Node
  267 + if (!locales[name] && (typeof module !== 'undefined') &&
  268 + module && module.exports) {
  269 + try {
  270 + oldLocale = globalLocale._abbr;
  271 + require('./locale/' + name);
  272 + // because defineLocale currently also sets the global locale, we
  273 + // want to undo that for lazy loaded locales
  274 + locale_locales__getSetGlobalLocale(oldLocale);
  275 + } catch (e) { }
  276 + }
  277 + return locales[name];
  278 + }
  279 +
  280 + // This function will load locale and then set the global locale. If
  281 + // no arguments are passed in, it will simply return the current global
  282 + // locale key.
  283 + function locale_locales__getSetGlobalLocale (key, values) {
  284 + var data;
  285 + if (key) {
  286 + if (isUndefined(values)) {
  287 + data = locale_locales__getLocale(key);
  288 + }
  289 + else {
  290 + data = defineLocale(key, values);
  291 + }
  292 +
  293 + if (data) {
  294 + // moment.duration._locale = moment._locale = data;
  295 + globalLocale = data;
  296 + }
  297 + }
  298 +
  299 + return globalLocale._abbr;
  300 + }
  301 +
  302 + function defineLocale (name, values) {
  303 + if (values !== null) {
  304 + values.abbr = name;
  305 + locales[name] = locales[name] || new Locale();
  306 + locales[name].set(values);
  307 +
  308 + // backwards compat for now: also set the locale
  309 + locale_locales__getSetGlobalLocale(name);
  310 +
  311 + return locales[name];
  312 + } else {
  313 + // useful for testing
  314 + delete locales[name];
  315 + return null;
  316 + }
  317 + }
  318 +
  319 + // returns locale data
  320 + function locale_locales__getLocale (key) {
  321 + var locale;
  322 +
  323 + if (key && key._locale && key._locale._abbr) {
  324 + key = key._locale._abbr;
  325 + }
  326 +
  327 + if (!key) {
  328 + return globalLocale;
  329 + }
  330 +
  331 + if (!isArray(key)) {
  332 + //short-circuit everything else
  333 + locale = loadLocale(key);
  334 + if (locale) {
  335 + return locale;
  336 + }
  337 + key = [key];
  338 + }
  339 +
  340 + return chooseLocale(key);
  341 + }
  342 +
  343 + var aliases = {};
  344 +
  345 + function addUnitAlias (unit, shorthand) {
  346 + var lowerCase = unit.toLowerCase();
  347 + aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  348 + }
  349 +
  350 + function normalizeUnits(units) {
  351 + return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
  352 + }
  353 +
  354 + function normalizeObjectUnits(inputObject) {
  355 + var normalizedInput = {},
  356 + normalizedProp,
  357 + prop;
  358 +
  359 + for (prop in inputObject) {
  360 + if (hasOwnProp(inputObject, prop)) {
  361 + normalizedProp = normalizeUnits(prop);
  362 + if (normalizedProp) {
  363 + normalizedInput[normalizedProp] = inputObject[prop];
  364 + }
  365 + }
  366 + }
  367 +
  368 + return normalizedInput;
  369 + }
  370 +
  371 + function isFunction(input) {
  372 + return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
  373 + }
  374 +
  375 + function makeGetSet (unit, keepTime) {
  376 + return function (value) {
  377 + if (value != null) {
  378 + get_set__set(this, unit, value);
  379 + utils_hooks__hooks.updateOffset(this, keepTime);
  380 + return this;
  381 + } else {
  382 + return get_set__get(this, unit);
  383 + }
  384 + };
  385 + }
  386 +
  387 + function get_set__get (mom, unit) {
  388 + return mom.isValid() ?
  389 + mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
  390 + }
  391 +
  392 + function get_set__set (mom, unit, value) {
  393 + if (mom.isValid()) {
  394 + mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  395 + }
  396 + }
  397 +
  398 + // MOMENTS
  399 +
  400 + function getSet (units, value) {
  401 + var unit;
  402 + if (typeof units === 'object') {
  403 + for (unit in units) {
  404 + this.set(unit, units[unit]);
  405 + }
  406 + } else {
  407 + units = normalizeUnits(units);
  408 + if (isFunction(this[units])) {
  409 + return this[units](value);
  410 + }
  411 + }
  412 + return this;
  413 + }
  414 +
  415 + function zeroFill(number, targetLength, forceSign) {
  416 + var absNumber = '' + Math.abs(number),
  417 + zerosToFill = targetLength - absNumber.length,
  418 + sign = number >= 0;
  419 + return (sign ? (forceSign ? '+' : '') : '-') +
  420 + Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
  421 + }
  422 +
  423 + var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
  424 +
  425 + var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
  426 +
  427 + var formatFunctions = {};
  428 +
  429 + var formatTokenFunctions = {};
  430 +
  431 + // token: 'M'
  432 + // padded: ['MM', 2]
  433 + // ordinal: 'Mo'
  434 + // callback: function () { this.month() + 1 }
  435 + function addFormatToken (token, padded, ordinal, callback) {
  436 + var func = callback;
  437 + if (typeof callback === 'string') {
  438 + func = function () {
  439 + return this[callback]();
  440 + };
  441 + }
  442 + if (token) {
  443 + formatTokenFunctions[token] = func;
  444 + }
  445 + if (padded) {
  446 + formatTokenFunctions[padded[0]] = function () {
  447 + return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  448 + };
  449 + }
  450 + if (ordinal) {
  451 + formatTokenFunctions[ordinal] = function () {
  452 + return this.localeData().ordinal(func.apply(this, arguments), token);
  453 + };
  454 + }
  455 + }
  456 +
  457 + function removeFormattingTokens(input) {
  458 + if (input.match(/\[[\s\S]/)) {
  459 + return input.replace(/^\[|\]$/g, '');
  460 + }
  461 + return input.replace(/\\/g, '');
  462 + }
  463 +
  464 + function makeFormatFunction(format) {
  465 + var array = format.match(formattingTokens), i, length;
  466 +
  467 + for (i = 0, length = array.length; i < length; i++) {
  468 + if (formatTokenFunctions[array[i]]) {
  469 + array[i] = formatTokenFunctions[array[i]];
  470 + } else {
  471 + array[i] = removeFormattingTokens(array[i]);
  472 + }
  473 + }
  474 +
  475 + return function (mom) {
  476 + var output = '';
  477 + for (i = 0; i < length; i++) {
  478 + output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
  479 + }
  480 + return output;
  481 + };
  482 + }
  483 +
  484 + // format date using native date object
  485 + function formatMoment(m, format) {
  486 + if (!m.isValid()) {
  487 + return m.localeData().invalidDate();
  488 + }
  489 +
  490 + format = expandFormat(format, m.localeData());
  491 + formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
  492 +
  493 + return formatFunctions[format](m);
  494 + }
  495 +
  496 + function expandFormat(format, locale) {
  497 + var i = 5;
  498 +
  499 + function replaceLongDateFormatTokens(input) {
  500 + return locale.longDateFormat(input) || input;
  501 + }
  502 +
  503 + localFormattingTokens.lastIndex = 0;
  504 + while (i >= 0 && localFormattingTokens.test(format)) {
  505 + format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
  506 + localFormattingTokens.lastIndex = 0;
  507 + i -= 1;
  508 + }
  509 +
  510 + return format;
  511 + }
  512 +
  513 + var match1 = /\d/; // 0 - 9
  514 + var match2 = /\d\d/; // 00 - 99
  515 + var match3 = /\d{3}/; // 000 - 999
  516 + var match4 = /\d{4}/; // 0000 - 9999
  517 + var match6 = /[+-]?\d{6}/; // -999999 - 999999
  518 + var match1to2 = /\d\d?/; // 0 - 99
  519 + var match3to4 = /\d\d\d\d?/; // 999 - 9999
  520 + var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999
  521 + var match1to3 = /\d{1,3}/; // 0 - 999
  522 + var match1to4 = /\d{1,4}/; // 0 - 9999
  523 + var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
  524 +
  525 + var matchUnsigned = /\d+/; // 0 - inf
  526 + var matchSigned = /[+-]?\d+/; // -inf - inf
  527 +
  528 + var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
  529 + var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  530 +
  531 + var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
  532 +
  533 + // any word (or two) characters or numbers including two/three word month in arabic.
  534 + // includes scottish gaelic two word and hyphenated months
  535 + var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
  536 +
  537 +
  538 + var regexes = {};
  539 +
  540 + function addRegexToken (token, regex, strictRegex) {
  541 + regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
  542 + return (isStrict && strictRegex) ? strictRegex : regex;
  543 + };
  544 + }
  545 +
  546 + function getParseRegexForToken (token, config) {
  547 + if (!hasOwnProp(regexes, token)) {
  548 + return new RegExp(unescapeFormat(token));
  549 + }
  550 +
  551 + return regexes[token](config._strict, config._locale);
  552 + }
  553 +
  554 + // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  555 + function unescapeFormat(s) {
  556 + return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
  557 + return p1 || p2 || p3 || p4;
  558 + }));
  559 + }
  560 +
  561 + function regexEscape(s) {
  562 + return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  563 + }
  564 +
  565 + var tokens = {};
  566 +
  567 + function addParseToken (token, callback) {
  568 + var i, func = callback;
  569 + if (typeof token === 'string') {
  570 + token = [token];
  571 + }
  572 + if (typeof callback === 'number') {
  573 + func = function (input, array) {
  574 + array[callback] = toInt(input);
  575 + };
  576 + }
  577 + for (i = 0; i < token.length; i++) {
  578 + tokens[token[i]] = func;
  579 + }
  580 + }
  581 +
  582 + function addWeekParseToken (token, callback) {
  583 + addParseToken(token, function (input, array, config, token) {
  584 + config._w = config._w || {};
  585 + callback(input, config._w, config, token);
  586 + });
  587 + }
  588 +
  589 + function addTimeToArrayFromToken(token, input, config) {
  590 + if (input != null && hasOwnProp(tokens, token)) {
  591 + tokens[token](input, config._a, config, token);
  592 + }
  593 + }
  594 +
  595 + var YEAR = 0;
  596 + var MONTH = 1;
  597 + var DATE = 2;
  598 + var HOUR = 3;
  599 + var MINUTE = 4;
  600 + var SECOND = 5;
  601 + var MILLISECOND = 6;
  602 + var WEEK = 7;
  603 + var WEEKDAY = 8;
  604 +
  605 + function daysInMonth(year, month) {
  606 + return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
  607 + }
  608 +
  609 + // FORMATTING
  610 +
  611 + addFormatToken('M', ['MM', 2], 'Mo', function () {
  612 + return this.month() + 1;
  613 + });
  614 +
  615 + addFormatToken('MMM', 0, 0, function (format) {
  616 + return this.localeData().monthsShort(this, format);
  617 + });
  618 +
  619 + addFormatToken('MMMM', 0, 0, function (format) {
  620 + return this.localeData().months(this, format);
  621 + });
  622 +
  623 + // ALIASES
  624 +
  625 + addUnitAlias('month', 'M');
  626 +
  627 + // PARSING
  628 +
  629 + addRegexToken('M', match1to2);
  630 + addRegexToken('MM', match1to2, match2);
  631 + addRegexToken('MMM', function (isStrict, locale) {
  632 + return locale.monthsShortRegex(isStrict);
  633 + });
  634 + addRegexToken('MMMM', function (isStrict, locale) {
  635 + return locale.monthsRegex(isStrict);
  636 + });
  637 +
  638 + addParseToken(['M', 'MM'], function (input, array) {
  639 + array[MONTH] = toInt(input) - 1;
  640 + });
  641 +
  642 + addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  643 + var month = config._locale.monthsParse(input, token, config._strict);
  644 + // if we didn't find a month name, mark the date as invalid.
  645 + if (month != null) {
  646 + array[MONTH] = month;
  647 + } else {
  648 + getParsingFlags(config).invalidMonth = input;
  649 + }
  650 + });
  651 +
  652 + // LOCALES
  653 +
  654 + var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/;
  655 + var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
  656 + function localeMonths (m, format) {
  657 + return isArray(this._months) ? this._months[m.month()] :
  658 + this._months[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
  659 + }
  660 +
  661 + var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
  662 + function localeMonthsShort (m, format) {
  663 + return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
  664 + this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
  665 + }
  666 +
  667 + function localeMonthsParse (monthName, format, strict) {
  668 + var i, mom, regex;
  669 +
  670 + if (!this._monthsParse) {
  671 + this._monthsParse = [];
  672 + this._longMonthsParse = [];
  673 + this._shortMonthsParse = [];
  674 + }
  675 +
  676 + for (i = 0; i < 12; i++) {
  677 + // make the regex if we don't have it already
  678 + mom = create_utc__createUTC([2000, i]);
  679 + if (strict && !this._longMonthsParse[i]) {
  680 + this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
  681 + this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
  682 + }
  683 + if (!strict && !this._monthsParse[i]) {
  684 + regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  685 + this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  686 + }
  687 + // test the regex
  688 + if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
  689 + return i;
  690 + } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
  691 + return i;
  692 + } else if (!strict && this._monthsParse[i].test(monthName)) {
  693 + return i;
  694 + }
  695 + }
  696 + }
  697 +
  698 + // MOMENTS
  699 +
  700 + function setMonth (mom, value) {
  701 + var dayOfMonth;
  702 +
  703 + if (!mom.isValid()) {
  704 + // No op
  705 + return mom;
  706 + }
  707 +
  708 + // TODO: Move this out of here!
  709 + if (typeof value === 'string') {
  710 + value = mom.localeData().monthsParse(value);
  711 + // TODO: Another silent failure?
  712 + if (typeof value !== 'number') {
  713 + return mom;
  714 + }
  715 + }
  716 +
  717 + dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  718 + mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  719 + return mom;
  720 + }
  721 +
  722 + function getSetMonth (value) {
  723 + if (value != null) {
  724 + setMonth(this, value);
  725 + utils_hooks__hooks.updateOffset(this, true);
  726 + return this;
  727 + } else {
  728 + return get_set__get(this, 'Month');
  729 + }
  730 + }
  731 +
  732 + function getDaysInMonth () {
  733 + return daysInMonth(this.year(), this.month());
  734 + }
  735 +
  736 + var defaultMonthsShortRegex = matchWord;
  737 + function monthsShortRegex (isStrict) {
  738 + if (this._monthsParseExact) {
  739 + if (!hasOwnProp(this, '_monthsRegex')) {
  740 + computeMonthsParse.call(this);
  741 + }
  742 + if (isStrict) {
  743 + return this._monthsShortStrictRegex;
  744 + } else {
  745 + return this._monthsShortRegex;
  746 + }
  747 + } else {
  748 + return this._monthsShortStrictRegex && isStrict ?
  749 + this._monthsShortStrictRegex : this._monthsShortRegex;
  750 + }
  751 + }
  752 +
  753 + var defaultMonthsRegex = matchWord;
  754 + function monthsRegex (isStrict) {
  755 + if (this._monthsParseExact) {
  756 + if (!hasOwnProp(this, '_monthsRegex')) {
  757 + computeMonthsParse.call(this);
  758 + }
  759 + if (isStrict) {
  760 + return this._monthsStrictRegex;
  761 + } else {
  762 + return this._monthsRegex;
  763 + }
  764 + } else {
  765 + return this._monthsStrictRegex && isStrict ?
  766 + this._monthsStrictRegex : this._monthsRegex;
  767 + }
  768 + }
  769 +
  770 + function computeMonthsParse () {
  771 + function cmpLenRev(a, b) {
  772 + return b.length - a.length;
  773 + }
  774 +
  775 + var shortPieces = [], longPieces = [], mixedPieces = [],
  776 + i, mom;
  777 + for (i = 0; i < 12; i++) {
  778 + // make the regex if we don't have it already
  779 + mom = create_utc__createUTC([2000, i]);
  780 + shortPieces.push(this.monthsShort(mom, ''));
  781 + longPieces.push(this.months(mom, ''));
  782 + mixedPieces.push(this.months(mom, ''));
  783 + mixedPieces.push(this.monthsShort(mom, ''));
  784 + }
  785 + // Sorting makes sure if one month (or abbr) is a prefix of another it
  786 + // will match the longer piece.
  787 + shortPieces.sort(cmpLenRev);
  788 + longPieces.sort(cmpLenRev);
  789 + mixedPieces.sort(cmpLenRev);
  790 + for (i = 0; i < 12; i++) {
  791 + shortPieces[i] = regexEscape(shortPieces[i]);
  792 + longPieces[i] = regexEscape(longPieces[i]);
  793 + mixedPieces[i] = regexEscape(mixedPieces[i]);
  794 + }
  795 +
  796 + this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  797 + this._monthsShortRegex = this._monthsRegex;
  798 + this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')$', 'i');
  799 + this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')$', 'i');
  800 + }
  801 +
  802 + function checkOverflow (m) {
  803 + var overflow;
  804 + var a = m._a;
  805 +
  806 + if (a && getParsingFlags(m).overflow === -2) {
  807 + overflow =
  808 + a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
  809 + a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
  810 + a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
  811 + a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
  812 + a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
  813 + a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
  814 + -1;
  815 +
  816 + if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
  817 + overflow = DATE;
  818 + }
  819 + if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  820 + overflow = WEEK;
  821 + }
  822 + if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  823 + overflow = WEEKDAY;
  824 + }
  825 +
  826 + getParsingFlags(m).overflow = overflow;
  827 + }
  828 +
  829 + return m;
  830 + }
  831 +
  832 + function warn(msg) {
  833 + if (utils_hooks__hooks.suppressDeprecationWarnings === false &&
  834 + (typeof console !== 'undefined') && console.warn) {
  835 + console.warn('Deprecation warning: ' + msg);
  836 + }
  837 + }
  838 +
  839 + function deprecate(msg, fn) {
  840 + var firstTime = true;
  841 +
  842 + return extend(function () {
  843 + if (firstTime) {
  844 + warn(msg + '\nArguments: ' + Array.prototype.slice.call(arguments).join(', ') + '\n' + (new Error()).stack);
  845 + firstTime = false;
  846 + }
  847 + return fn.apply(this, arguments);
  848 + }, fn);
  849 + }
  850 +
  851 + var deprecations = {};
  852 +
  853 + function deprecateSimple(name, msg) {
  854 + if (!deprecations[name]) {
  855 + warn(msg);
  856 + deprecations[name] = true;
  857 + }
  858 + }
  859 +
  860 + utils_hooks__hooks.suppressDeprecationWarnings = false;
  861 +
  862 + // iso 8601 regex
  863 + // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
  864 + var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?/;
  865 + var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?/;
  866 +
  867 + var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
  868 +
  869 + var isoDates = [
  870 + ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  871 + ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  872 + ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  873 + ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  874 + ['YYYY-DDD', /\d{4}-\d{3}/],
  875 + ['YYYY-MM', /\d{4}-\d\d/, false],
  876 + ['YYYYYYMMDD', /[+-]\d{10}/],
  877 + ['YYYYMMDD', /\d{8}/],
  878 + // YYYYMM is NOT allowed by the standard
  879 + ['GGGG[W]WWE', /\d{4}W\d{3}/],
  880 + ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  881 + ['YYYYDDD', /\d{7}/]
  882 + ];
  883 +
  884 + // iso time formats and regexes
  885 + var isoTimes = [
  886 + ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  887 + ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  888 + ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  889 + ['HH:mm', /\d\d:\d\d/],
  890 + ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  891 + ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  892 + ['HHmmss', /\d\d\d\d\d\d/],
  893 + ['HHmm', /\d\d\d\d/],
  894 + ['HH', /\d\d/]
  895 + ];
  896 +
  897 + var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
  898 +
  899 + // date from iso format
  900 + function configFromISO(config) {
  901 + var i, l,
  902 + string = config._i,
  903 + match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  904 + allowTime, dateFormat, timeFormat, tzFormat;
  905 +
  906 + if (match) {
  907 + getParsingFlags(config).iso = true;
  908 +
  909 + for (i = 0, l = isoDates.length; i < l; i++) {
  910 + if (isoDates[i][1].exec(match[1])) {
  911 + dateFormat = isoDates[i][0];
  912 + allowTime = isoDates[i][2] !== false;
  913 + break;
  914 + }
  915 + }
  916 + if (dateFormat == null) {
  917 + config._isValid = false;
  918 + return;
  919 + }
  920 + if (match[3]) {
  921 + for (i = 0, l = isoTimes.length; i < l; i++) {
  922 + if (isoTimes[i][1].exec(match[3])) {
  923 + // match[2] should be 'T' or space
  924 + timeFormat = (match[2] || ' ') + isoTimes[i][0];
  925 + break;
  926 + }
  927 + }
  928 + if (timeFormat == null) {
  929 + config._isValid = false;
  930 + return;
  931 + }
  932 + }
  933 + if (!allowTime && timeFormat != null) {
  934 + config._isValid = false;
  935 + return;
  936 + }
  937 + if (match[4]) {
  938 + if (tzRegex.exec(match[4])) {
  939 + tzFormat = 'Z';
  940 + } else {
  941 + config._isValid = false;
  942 + return;
  943 + }
  944 + }
  945 + config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  946 + configFromStringAndFormat(config);
  947 + } else {
  948 + config._isValid = false;
  949 + }
  950 + }
  951 +
  952 + // date from iso format or fallback
  953 + function configFromString(config) {
  954 + var matched = aspNetJsonRegex.exec(config._i);
  955 +
  956 + if (matched !== null) {
  957 + config._d = new Date(+matched[1]);
  958 + return;
  959 + }
  960 +
  961 + configFromISO(config);
  962 + if (config._isValid === false) {
  963 + delete config._isValid;
  964 + utils_hooks__hooks.createFromInputFallback(config);
  965 + }
  966 + }
  967 +
  968 + utils_hooks__hooks.createFromInputFallback = deprecate(
  969 + 'moment construction falls back to js Date. This is ' +
  970 + 'discouraged and will be removed in upcoming major ' +
  971 + 'release. Please refer to ' +
  972 + 'https://github.com/moment/moment/issues/1407 for more info.',
  973 + function (config) {
  974 + config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  975 + }
  976 + );
  977 +
  978 + function createDate (y, m, d, h, M, s, ms) {
  979 + //can't just apply() to create a date:
  980 + //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
  981 + var date = new Date(y, m, d, h, M, s, ms);
  982 +
  983 + //the date constructor remaps years 0-99 to 1900-1999
  984 + if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
  985 + date.setFullYear(y);
  986 + }
  987 + return date;
  988 + }
  989 +
  990 + function createUTCDate (y) {
  991 + var date = new Date(Date.UTC.apply(null, arguments));
  992 +
  993 + //the Date.UTC function remaps years 0-99 to 1900-1999
  994 + if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
  995 + date.setUTCFullYear(y);
  996 + }
  997 + return date;
  998 + }
  999 +
  1000 + // FORMATTING
  1001 +
  1002 + addFormatToken('Y', 0, 0, function () {
  1003 + var y = this.year();
  1004 + return y <= 9999 ? '' + y : '+' + y;
  1005 + });
  1006 +
  1007 + addFormatToken(0, ['YY', 2], 0, function () {
  1008 + return this.year() % 100;
  1009 + });
  1010 +
  1011 + addFormatToken(0, ['YYYY', 4], 0, 'year');
  1012 + addFormatToken(0, ['YYYYY', 5], 0, 'year');
  1013 + addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  1014 +
  1015 + // ALIASES
  1016 +
  1017 + addUnitAlias('year', 'y');
  1018 +
  1019 + // PARSING
  1020 +
  1021 + addRegexToken('Y', matchSigned);
  1022 + addRegexToken('YY', match1to2, match2);
  1023 + addRegexToken('YYYY', match1to4, match4);
  1024 + addRegexToken('YYYYY', match1to6, match6);
  1025 + addRegexToken('YYYYYY', match1to6, match6);
  1026 +
  1027 + addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  1028 + addParseToken('YYYY', function (input, array) {
  1029 + array[YEAR] = input.length === 2 ? utils_hooks__hooks.parseTwoDigitYear(input) : toInt(input);
  1030 + });
  1031 + addParseToken('YY', function (input, array) {
  1032 + array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
  1033 + });
  1034 + addParseToken('Y', function (input, array) {
  1035 + array[YEAR] = parseInt(input, 10);
  1036 + });
  1037 +
  1038 + // HELPERS
  1039 +
  1040 + function daysInYear(year) {
  1041 + return isLeapYear(year) ? 366 : 365;
  1042 + }
  1043 +
  1044 + function isLeapYear(year) {
  1045 + return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  1046 + }
  1047 +
  1048 + // HOOKS
  1049 +
  1050 + utils_hooks__hooks.parseTwoDigitYear = function (input) {
  1051 + return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  1052 + };
  1053 +
  1054 + // MOMENTS
  1055 +
  1056 + var getSetYear = makeGetSet('FullYear', false);
  1057 +
  1058 + function getIsLeapYear () {
  1059 + return isLeapYear(this.year());
  1060 + }
  1061 +
  1062 + // start-of-first-week - start-of-year
  1063 + function firstWeekOffset(year, dow, doy) {
  1064 + var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  1065 + fwd = 7 + dow - doy,
  1066 + // first-week day local weekday -- which local weekday is fwd
  1067 + fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  1068 +
  1069 + return -fwdlw + fwd - 1;
  1070 + }
  1071 +
  1072 + //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  1073 + function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  1074 + var localWeekday = (7 + weekday - dow) % 7,
  1075 + weekOffset = firstWeekOffset(year, dow, doy),
  1076 + dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  1077 + resYear, resDayOfYear;
  1078 +
  1079 + if (dayOfYear <= 0) {
  1080 + resYear = year - 1;
  1081 + resDayOfYear = daysInYear(resYear) + dayOfYear;
  1082 + } else if (dayOfYear > daysInYear(year)) {
  1083 + resYear = year + 1;
  1084 + resDayOfYear = dayOfYear - daysInYear(year);
  1085 + } else {
  1086 + resYear = year;
  1087 + resDayOfYear = dayOfYear;
  1088 + }
  1089 +
  1090 + return {
  1091 + year: resYear,
  1092 + dayOfYear: resDayOfYear
  1093 + };
  1094 + }
  1095 +
  1096 + function weekOfYear(mom, dow, doy) {
  1097 + var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  1098 + week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  1099 + resWeek, resYear;
  1100 +
  1101 + if (week < 1) {
  1102 + resYear = mom.year() - 1;
  1103 + resWeek = week + weeksInYear(resYear, dow, doy);
  1104 + } else if (week > weeksInYear(mom.year(), dow, doy)) {
  1105 + resWeek = week - weeksInYear(mom.year(), dow, doy);
  1106 + resYear = mom.year() + 1;
  1107 + } else {
  1108 + resYear = mom.year();
  1109 + resWeek = week;
  1110 + }
  1111 +
  1112 + return {
  1113 + week: resWeek,
  1114 + year: resYear
  1115 + };
  1116 + }
  1117 +
  1118 + function weeksInYear(year, dow, doy) {
  1119 + var weekOffset = firstWeekOffset(year, dow, doy),
  1120 + weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  1121 + return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  1122 + }
  1123 +
  1124 + // Pick the first defined of two or three arguments.
  1125 + function defaults(a, b, c) {
  1126 + if (a != null) {
  1127 + return a;
  1128 + }
  1129 + if (b != null) {
  1130 + return b;
  1131 + }
  1132 + return c;
  1133 + }
  1134 +
  1135 + function currentDateArray(config) {
  1136 + // hooks is actually the exported moment object
  1137 + var nowValue = new Date(utils_hooks__hooks.now());
  1138 + if (config._useUTC) {
  1139 + return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
  1140 + }
  1141 + return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  1142 + }
  1143 +
  1144 + // convert an array to a date.
  1145 + // the array should mirror the parameters below
  1146 + // note: all values past the year are optional and will default to the lowest possible value.
  1147 + // [year, month, day , hour, minute, second, millisecond]
  1148 + function configFromArray (config) {
  1149 + var i, date, input = [], currentDate, yearToUse;
  1150 +
  1151 + if (config._d) {
  1152 + return;
  1153 + }
  1154 +
  1155 + currentDate = currentDateArray(config);
  1156 +
  1157 + //compute day of the year from weeks and weekdays
  1158 + if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  1159 + dayOfYearFromWeekInfo(config);
  1160 + }
  1161 +
  1162 + //if the day of the year is set, figure out what it is
  1163 + if (config._dayOfYear) {
  1164 + yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  1165 +
  1166 + if (config._dayOfYear > daysInYear(yearToUse)) {
  1167 + getParsingFlags(config)._overflowDayOfYear = true;
  1168 + }
  1169 +
  1170 + date = createUTCDate(yearToUse, 0, config._dayOfYear);
  1171 + config._a[MONTH] = date.getUTCMonth();
  1172 + config._a[DATE] = date.getUTCDate();
  1173 + }
  1174 +
  1175 + // Default to current date.
  1176 + // * if no year, month, day of month are given, default to today
  1177 + // * if day of month is given, default month and year
  1178 + // * if month is given, default only year
  1179 + // * if year is given, don't default anything
  1180 + for (i = 0; i < 3 && config._a[i] == null; ++i) {
  1181 + config._a[i] = input[i] = currentDate[i];
  1182 + }
  1183 +
  1184 + // Zero out whatever was not defaulted, including time
  1185 + for (; i < 7; i++) {
  1186 + config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
  1187 + }
  1188 +
  1189 + // Check for 24:00:00.000
  1190 + if (config._a[HOUR] === 24 &&
  1191 + config._a[MINUTE] === 0 &&
  1192 + config._a[SECOND] === 0 &&
  1193 + config._a[MILLISECOND] === 0) {
  1194 + config._nextDay = true;
  1195 + config._a[HOUR] = 0;
  1196 + }
  1197 +
  1198 + config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
  1199 + // Apply timezone offset from input. The actual utcOffset can be changed
  1200 + // with parseZone.
  1201 + if (config._tzm != null) {
  1202 + config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  1203 + }
  1204 +
  1205 + if (config._nextDay) {
  1206 + config._a[HOUR] = 24;
  1207 + }
  1208 + }
  1209 +
  1210 + function dayOfYearFromWeekInfo(config) {
  1211 + var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
  1212 +
  1213 + w = config._w;
  1214 + if (w.GG != null || w.W != null || w.E != null) {
  1215 + dow = 1;
  1216 + doy = 4;
  1217 +
  1218 + // TODO: We need to take the current isoWeekYear, but that depends on
  1219 + // how we interpret now (local, utc, fixed offset). So create
  1220 + // a now version of current config (take local/utc/offset flags, and
  1221 + // create now).
  1222 + weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(local__createLocal(), 1, 4).year);
  1223 + week = defaults(w.W, 1);
  1224 + weekday = defaults(w.E, 1);
  1225 + if (weekday < 1 || weekday > 7) {
  1226 + weekdayOverflow = true;
  1227 + }
  1228 + } else {
  1229 + dow = config._locale._week.dow;
  1230 + doy = config._locale._week.doy;
  1231 +
  1232 + weekYear = defaults(w.gg, config._a[YEAR], weekOfYear(local__createLocal(), dow, doy).year);
  1233 + week = defaults(w.w, 1);
  1234 +
  1235 + if (w.d != null) {
  1236 + // weekday -- low day numbers are considered next week
  1237 + weekday = w.d;
  1238 + if (weekday < 0 || weekday > 6) {
  1239 + weekdayOverflow = true;
  1240 + }
  1241 + } else if (w.e != null) {
  1242 + // local weekday -- counting starts from begining of week
  1243 + weekday = w.e + dow;
  1244 + if (w.e < 0 || w.e > 6) {
  1245 + weekdayOverflow = true;
  1246 + }
  1247 + } else {
  1248 + // default to begining of week
  1249 + weekday = dow;
  1250 + }
  1251 + }
  1252 + if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  1253 + getParsingFlags(config)._overflowWeeks = true;
  1254 + } else if (weekdayOverflow != null) {
  1255 + getParsingFlags(config)._overflowWeekday = true;
  1256 + } else {
  1257 + temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  1258 + config._a[YEAR] = temp.year;
  1259 + config._dayOfYear = temp.dayOfYear;
  1260 + }
  1261 + }
  1262 +
  1263 + // constant that refers to the ISO standard
  1264 + utils_hooks__hooks.ISO_8601 = function () {};
  1265 +
  1266 + // date from string and format string
  1267 + function configFromStringAndFormat(config) {
  1268 + // TODO: Move this to another part of the creation flow to prevent circular deps
  1269 + if (config._f === utils_hooks__hooks.ISO_8601) {
  1270 + configFromISO(config);
  1271 + return;
  1272 + }
  1273 +
  1274 + config._a = [];
  1275 + getParsingFlags(config).empty = true;
  1276 +
  1277 + // This array is used to make a Date, either with `new Date` or `Date.UTC`
  1278 + var string = '' + config._i,
  1279 + i, parsedInput, tokens, token, skipped,
  1280 + stringLength = string.length,
  1281 + totalParsedInputLength = 0;
  1282 +
  1283 + tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
  1284 +
  1285 + for (i = 0; i < tokens.length; i++) {
  1286 + token = tokens[i];
  1287 + parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
  1288 + // console.log('token', token, 'parsedInput', parsedInput,
  1289 + // 'regex', getParseRegexForToken(token, config));
  1290 + if (parsedInput) {
  1291 + skipped = string.substr(0, string.indexOf(parsedInput));
  1292 + if (skipped.length > 0) {
  1293 + getParsingFlags(config).unusedInput.push(skipped);
  1294 + }
  1295 + string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
  1296 + totalParsedInputLength += parsedInput.length;
  1297 + }
  1298 + // don't parse if it's not a known token
  1299 + if (formatTokenFunctions[token]) {
  1300 + if (parsedInput) {
  1301 + getParsingFlags(config).empty = false;
  1302 + }
  1303 + else {
  1304 + getParsingFlags(config).unusedTokens.push(token);
  1305 + }
  1306 + addTimeToArrayFromToken(token, parsedInput, config);
  1307 + }
  1308 + else if (config._strict && !parsedInput) {
  1309 + getParsingFlags(config).unusedTokens.push(token);
  1310 + }
  1311 + }
  1312 +
  1313 + // add remaining unparsed input length to the string
  1314 + getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
  1315 + if (string.length > 0) {
  1316 + getParsingFlags(config).unusedInput.push(string);
  1317 + }
  1318 +
  1319 + // clear _12h flag if hour is <= 12
  1320 + if (getParsingFlags(config).bigHour === true &&
  1321 + config._a[HOUR] <= 12 &&
  1322 + config._a[HOUR] > 0) {
  1323 + getParsingFlags(config).bigHour = undefined;
  1324 + }
  1325 + // handle meridiem
  1326 + config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
  1327 +
  1328 + configFromArray(config);
  1329 + checkOverflow(config);
  1330 + }
  1331 +
  1332 +
  1333 + function meridiemFixWrap (locale, hour, meridiem) {
  1334 + var isPm;
  1335 +
  1336 + if (meridiem == null) {
  1337 + // nothing to do
  1338 + return hour;
  1339 + }
  1340 + if (locale.meridiemHour != null) {
  1341 + return locale.meridiemHour(hour, meridiem);
  1342 + } else if (locale.isPM != null) {
  1343 + // Fallback
  1344 + isPm = locale.isPM(meridiem);
  1345 + if (isPm && hour < 12) {
  1346 + hour += 12;
  1347 + }
  1348 + if (!isPm && hour === 12) {
  1349 + hour = 0;
  1350 + }
  1351 + return hour;
  1352 + } else {
  1353 + // this is not supposed to happen
  1354 + return hour;
  1355 + }
  1356 + }
  1357 +
  1358 + // date from string and array of format strings
  1359 + function configFromStringAndArray(config) {
  1360 + var tempConfig,
  1361 + bestMoment,
  1362 +
  1363 + scoreToBeat,
  1364 + i,
  1365 + currentScore;
  1366 +
  1367 + if (config._f.length === 0) {
  1368 + getParsingFlags(config).invalidFormat = true;
  1369 + config._d = new Date(NaN);
  1370 + return;
  1371 + }
  1372 +
  1373 + for (i = 0; i < config._f.length; i++) {
  1374 + currentScore = 0;
  1375 + tempConfig = copyConfig({}, config);
  1376 + if (config._useUTC != null) {
  1377 + tempConfig._useUTC = config._useUTC;
  1378 + }
  1379 + tempConfig._f = config._f[i];
  1380 + configFromStringAndFormat(tempConfig);
  1381 +
  1382 + if (!valid__isValid(tempConfig)) {
  1383 + continue;
  1384 + }
  1385 +
  1386 + // if there is any input that was not parsed add a penalty for that format
  1387 + currentScore += getParsingFlags(tempConfig).charsLeftOver;
  1388 +
  1389 + //or tokens
  1390 + currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  1391 +
  1392 + getParsingFlags(tempConfig).score = currentScore;
  1393 +
  1394 + if (scoreToBeat == null || currentScore < scoreToBeat) {
  1395 + scoreToBeat = currentScore;
  1396 + bestMoment = tempConfig;
  1397 + }
  1398 + }
  1399 +
  1400 + extend(config, bestMoment || tempConfig);
  1401 + }
  1402 +
  1403 + function configFromObject(config) {
  1404 + if (config._d) {
  1405 + return;
  1406 + }
  1407 +
  1408 + var i = normalizeObjectUnits(config._i);
  1409 + config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
  1410 + return obj && parseInt(obj, 10);
  1411 + });
  1412 +
  1413 + configFromArray(config);
  1414 + }
  1415 +
  1416 + function createFromConfig (config) {
  1417 + var res = new Moment(checkOverflow(prepareConfig(config)));
  1418 + if (res._nextDay) {
  1419 + // Adding is smart enough around DST
  1420 + res.add(1, 'd');
  1421 + res._nextDay = undefined;
  1422 + }
  1423 +
  1424 + return res;
  1425 + }
  1426 +
  1427 + function prepareConfig (config) {
  1428 + var input = config._i,
  1429 + format = config._f;
  1430 +
  1431 + config._locale = config._locale || locale_locales__getLocale(config._l);
  1432 +
  1433 + if (input === null || (format === undefined && input === '')) {
  1434 + return valid__createInvalid({nullInput: true});
  1435 + }
  1436 +
  1437 + if (typeof input === 'string') {
  1438 + config._i = input = config._locale.preparse(input);
  1439 + }