forked from brockpetrie/vue-moment
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vue-moment.min.js
1 lines (1 loc) · 1.34 KB
/
vue-moment.min.js
1
var moment=require("moment-jalaali");module.exports={install:function(b,a){Object.defineProperties(b.prototype,{$moment:{get:function(){return b.moment.bind(this)},},});if(a&&a.moment){moment=a.moment}b.moment=function(c){return moment(c)};b.filter("moment",function(){var e=Array.prototype.slice.call(arguments),c=e.shift(),d;if(Array.isArray(c)&&typeof c[0]==="string"){d=moment(string=c[0],formats=c[1],true)}else{d=moment(c)}if(!d.isValid()){console.warn("Could not build a valid `moment` object from input.");return c}function f(){var l=Array.prototype.slice.call(arguments);method=l.shift();switch(method){case"add":var j=l.shift().split(",").map(Function.prototype.call,String.prototype.trim);obj={};for(var h=0;h<j.length;h++){var i=j[h].split(" ");obj[i[1]]=i[0]}d=d.add(obj);break;case"subtract":var p=l.shift().split(",").map(Function.prototype.call,String.prototype.trim);obj={};for(var h=0;h<p.length;h++){var g=p[h].split(" ");obj[g[1]]=g[0]}d=d.subtract(obj);break;case"from":var o="now";if(l[0]=="now"){l.shift()}if(moment(l[0]).isValid()){o=moment(l.shift())}var q=false;if(l[0]===true){l.shift();var q=true}if(o!="now"){d=d.from(o,q);break}d=d.fromNow(q);break;case"calendar":var k=moment();if(moment(l[0]).isValid()){k=moment(l.shift())}d=d.calendar(k);break;default:var m=method;d=d.format(m)}if(l.length){f.apply(f,l)}}f.apply(f,e);return d})},};