UNPKG

@stdlib/esm

Version:

ES module distribution for Stdlib, a standard library for JavaScript and Node.js.

3 lines 1.67 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import e from"./../assert/is-date-object.js";import r from"./../assert/is-string.js";import t from"./../assert/is-integer.js";import i from"./../string/lowercase.js";import a from"./../assert/is-leap-year.js";var n=31,o=31,s=28,u=28,m=31,g=31,l=30,f=30,v=31,h=30,p=30,d=31,j=31,w=31,b=31,c=30,y=30,E=31,F=31,V=30,D=30,M=31,T=31,Y={1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31,jan:n,january:o,feb:s,february:u,mar:m,march:g,apr:l,april:f,may:v,jun:h,june:p,jul:d,july:j,aug:w,august:b,sep:c,september:y,oct:E,october:F,nov:V,november:D,dec:M,december:T},P=e,S=r.isPrimitive,x=t.isPrimitive,z=i,A=a,R=Y;function k(e,r){var t,i,a,n;if(0===arguments.length)i=(n=new Date).getMonth()+1,a=n.getFullYear();else if(1===arguments.length)if(P(e))i=(n=e).getMonth()+1,a=n.getFullYear();else{if(!S(e)&&!x(e))throw new TypeError("invalid argument. First argument must be either a string, integer, or `Date` object. Value: `"+e+"`.");a=(new Date).getFullYear(),i=e}else{if(!S(e)&&!x(e))throw new TypeError("invalid argument. First argument must be either a string or integer. Value: `"+e+"`.");if(!x(r))throw new TypeError("invalid argument. Second argument must be an integer. Value: `"+r+"`.");i=e,a=r}if(x(i)&&(i<1||i>12))throw new RangeError("invalid argument. An integer month value must be on the interval `[1,12]`. Value: `"+i+"`.");if(i=z(i.toString()),void 0===(t=R[i]))throw new Error("invalid argument. Must provide a recognized month. Value: `"+i+"`.");return 28===t&&A(a)&&(t+=1),t}var q=k;export default q; //# sourceMappingURL=days-in-month.js.map