(s, n, goFwd)
| 2961 | }; |
| 2962 | |
| 2963 | const date = function (s, n, goFwd) { |
| 2964 | n = validate(n); |
| 2965 | //avoid setting february 31st |
| 2966 | if (n > 28) { |
| 2967 | const month = s.month(); |
| 2968 | let max = monthLengths[month]; |
| 2969 | // support leap day in february |
| 2970 | if (month === 1 && n === 29 && isLeapYear(s.year())) { |
| 2971 | max = 29; |
| 2972 | } |
| 2973 | if (n > max) { |
| 2974 | n = max; |
| 2975 | } |
| 2976 | } |
| 2977 | //avoid setting < 0 |
| 2978 | if (n <= 0) { |
| 2979 | n = 1; |
| 2980 | } |
| 2981 | const old = s.clone(); |
| 2982 | walkTo(s, { |
| 2983 | date: n |
| 2984 | }); |
| 2985 | s = fwdBkwd(s, old, goFwd, 'month'); // specify direction |
| 2986 | return s.epoch |
| 2987 | }; |
| 2988 | |
| 2989 | const month = function (s, n, goFwd) { |
| 2990 | if (typeof n === 'string') { |
no test coverage detected