pbs/moment.js

2 lines
48 KiB
JavaScript
Raw Permalink Normal View History

2016-04-14 10:03:36 +02:00
(function(undefined){function dfl(a,b,c){switch(arguments.length){case 2:return null!=a?a:b;case 3:return null!=a?a:null!=b?b:c;default:throw new Error("Implement me")}}function hasOwnProp(a,b){return hasOwnProperty.call(a,b)}function defaultParsingFlags(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function printMsg(msg){moment.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+msg)}function deprecate(msg,fn){var firstTime=!0;return extend(function(){return firstTime&&(printMsg(msg),firstTime=!1),fn.apply(this,arguments)},fn)}function deprecateSimple(name,msg){deprecations[name]||(printMsg(msg),deprecations[name]=!0)}function padToken(func,count){return function(a){return leftZeroFill(func.call(this,a),count)}}function ordinalizeToken(func,period){return function(a){return this.localeData().ordinal(func.call(this,a),period)}}function monthDiff(a,b){var anchor2,adjust,wholeMonthDiff=12*(b.year()-a.year())+(b.month()-a.month()),anchor=a.clone().add(wholeMonthDiff,"months");return 0>b-anchor?(anchor2=a.clone().add(wholeMonthDiff-1,"months"),adjust=(b-anchor)/(anchor-anchor2)):(anchor2=a.clone().add(wholeMonthDiff+1,"months"),adjust=(b-anchor)/(anchor2-anchor)),-(wholeMonthDiff+adjust)}function meridiemFixWrap(locale,hour,meridiem){var isPm;return null==meridiem?hour:null!=locale.meridiemHour?locale.meridiemHour(hour,meridiem):null!=locale.isPM?(isPm=locale.isPM(meridiem),isPm&&12>hour&&(hour+=12),isPm||12!==hour||(hour=0),hour):hour}function Locale(){}function Moment(config,skipOverflow){skipOverflow!==!1&&checkOverflow(config),copyConfig(this,config),this._d=new Date(+config._d),updateInProgress===!1&&(updateInProgress=!0,moment.updateOffset(this),updateInProgress=!1)}function Duration(duration){var normalizedInput=normalizeObjectUnits(duration),years=normalizedInput.year||0,quarters=normalizedInput.quarter||0,months=normalizedInput.month||0,weeks=normalizedInput.week||0,days=normalizedInput.day||0,hours=normalizedInput.hour||0,minutes=normalizedInput.minute||0,seconds=normalizedInput.second||0,milliseconds=normalizedInput.millisecond||0;this._milliseconds=+milliseconds+1e3*seconds+6e4*minutes+36e5*hours,this._days=+days+7*weeks,this._months=+months+3*quarters+12*years,this._data={},this._locale=moment.localeData(),this._bubble()}function extend(a,b){for(var i in b)hasOwnProp(b,i)&&(a[i]=b[i]);return hasOwnProp(b,"toString")&&(a.toString=b.toString),hasOwnProp(b,"valueOf")&&(a.valueOf=b.valueOf),a}function copyConfig(to,from){var i,prop,val;if("undefined"!=typeof from._isAMomentObject&&(to._isAMomentObject=from._isAMomentObject),"undefined"!=typeof from._i&&(to._i=from._i),"undefined"!=typeof from._f&&(to._f=from._f),"undefined"!=typeof from._l&&(to._l=from._l),"undefined"!=typeof from._strict&&(to._strict=from._strict),"undefined"!=typeof from._tzm&&(to._tzm=from._tzm),"undefined"!=typeof from._isUTC&&(to._isUTC=from._isUTC),"undefined"!=typeof from._offset&&(to._offset=from._offset),"undefined"!=typeof from._pf&&(to._pf=from._pf),"undefined"!=typeof from._locale&&(to._locale=from._locale),momentProperties.length>0)for(i in momentProperties)prop=momentProperties[i],val=from[prop],"undefined"!=typeof val&&(to[prop]=val);return to}function absRound(number){return 0>number?Math.ceil(number):Math.floor(number)}function leftZeroFill(number,targetLength,forceSign){for(var output=""+Math.abs(number),sign=number>=0;output.length<targetLength;)output="0"+output;return(sign?forceSign?"+":"":"-")+output}function positiveMomentsDifference(base,other){var res={milliseconds:0,months:0};return res.months=other.month()-base.month()+12*(other.year()-base.year()),base.clone().add(res.months,"M").isAfter(other)&&--res.months,res.milliseconds=+other-+base.clone().add(res.months,"M"),res}function momentsDifference(base,other){var res;return other=makeAs(other,base),base.isBefore(other)?res=positiveMomentsDifference(base,other):(res=positiveMomentsDifference(other,base),res.m
c._pf=defaultParsingFlags(),makeMoment(c)},moment.suppressDeprecationWarnings=!1,moment.createFromInputFallback=deprecate("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(config){config._d=new Date(config._i+(config._useUTC?" UTC":""))}),moment.min=function(){var args=[].slice.call(arguments,0);return pickBy("isBefore",args)},moment.max=function(){var args=[].slice.call(arguments,0);return pickBy("isAfter",args)},moment.utc=function(input,format,locale,strict){var c;return"boolean"==typeof locale&&(strict=locale,locale=undefined),c={},c._isAMomentObject=!0,c._useUTC=!0,c._isUTC=!0,c._l=locale,c._i=input,c._f=format,c._strict=strict,c._pf=defaultParsingFlags(),makeMoment(c).utc()},moment.unix=function(input){return moment(1e3*input)},moment.duration=function(input,key){var sign,ret,parseIso,diffRes,duration=input,match=null;return moment.isDuration(input)?duration={ms:input._milliseconds,d:input._days,M:input._months}:"number"==typeof input?(duration={},key?duration[key]=input:duration.milliseconds=input):(match=aspNetTimeSpanJsonRegex.exec(input))?(sign="-"===match[1]?-1:1,duration={y:0,d:toInt(match[DATE])*sign,h:toInt(match[HOUR])*sign,m:toInt(match[MINUTE])*sign,s:toInt(match[SECOND])*sign,ms:toInt(match[MILLISECOND])*sign}):(match=isoDurationRegex.exec(input))?(sign="-"===match[1]?-1:1,parseIso=function(inp){var res=inp&&parseFloat(inp.replace(",","."));return(isNaN(res)?0:res)*sign},duration={y:parseIso(match[2]),M:parseIso(match[3]),d:parseIso(match[4]),h:parseIso(match[5]),m:parseIso(match[6]),s:parseIso(match[7]),w:parseIso(match[8])}):null==duration?duration={}:"object"==typeof duration&&("from"in duration||"to"in duration)&&(diffRes=momentsDifference(moment(duration.from),moment(duration.to)),duration={},duration.ms=diffRes.milliseconds,duration.M=diffRes.months),ret=new Duration(duration),moment.isDuration(input)&&hasOwnProp(input,"_locale")&&(ret._locale=input._locale),ret},moment.version=VERSION,moment.defaultFormat=isoFormat,moment.ISO_8601=function(){},moment.momentProperties=momentProperties,moment.updateOffset=function(){},moment.relativeTimeThreshold=function(threshold,limit){return relativeTimeThresholds[threshold]===undefined?!1:limit===undefined?relativeTimeThresholds[threshold]:(relativeTimeThresholds[threshold]=limit,!0)},moment.lang=deprecate("moment.lang is deprecated. Use moment.locale instead.",function(key,value){return moment.locale(key,value)}),moment.locale=function(key,values){var data;return key&&(data="undefined"!=typeof values?moment.defineLocale(key,values):moment.localeData(key),data&&(moment.duration._locale=moment._locale=data)),moment._locale._abbr},moment.defineLocale=function(name,values){return null!==values?(values.abbr=name,locales[name]||(locales[name]=new Locale),locales[name].set(values),moment.locale(name),locales[name]):(delete locales[name],null)},moment.langData=deprecate("moment.langData is deprecated. Use moment.localeData instead.",function(key){return moment.localeData(key)}),moment.localeData=function(key){var locale;if(key&&key._locale&&key._locale._abbr&&(key=key._locale._abbr),!key)return moment._locale;if(!isArray(key)){if(locale=loadLocale(key))return locale;key=[key]}return chooseLocale(key)},moment.isMoment=function(obj){return obj instanceof Moment||null!=obj&&hasOwnProp(obj,"_isAMomentObject")},moment.isDuration=function(obj){return obj instanceof Duration};for(i=lists.length-1;i>=0;--i)makeList(lists[i]);moment.normalizeUnits=function(units){return normalizeUnits(units)},moment.invalid=function(flags){var m=moment.utc(NaN);return null!=flags?extend(m._pf,flags):m._pf.userInvalidated=!0,m},moment.parseZone=function(){return moment.apply(null,arguments).parseZone()},moment.parseTwoDigitYear=function(input){return toInt(input)+(toInt(input)>68?1900:2e3)},moment.isDate=isDate,extend(moment.fn=Moment.prototype,{clone:function(){return moment(this)},valueOf:function(){return+this._d-6e4*(this._offset||0)},unix:func