UNPKG

moment-round

Version:
1 lines 756 B
(function(){var e="undefined"==typeof require||null===require||require.amd?this.moment:require("moment");e.fn.round=function(e,n,t){"undefined"==typeof t&&(t="round");var r=["Hours","Minutes","Seconds","Milliseconds"],o=[24,60,60,1e3];n=n.charAt(0).toUpperCase()+n.slice(1).toLowerCase(),-1===n.indexOf("s",n.length-1)&&(n+="s");var i,u=0,d=!1,s=1;for(var l in r){var f=r[l];f===n?(u=this._d["get"+n](),i=o[l],d=!0):d&&(s*=o[l],u+=this._d["get"+f]()/s,this._d["set"+f](0))}return u=Math[t](u/e)*e,u=Math.min(u,i),this._d["set"+n](u),this},e.fn.ceil=function(e,n){return this.round(e,n,"ceil")},e.fn.floor=function(e,n){return this.round(e,n,"floor")},null!=("undefined"!=typeof module&&null!==module?module.exports:void 0)&&(module.exports=e)}).call(this);