MCPcopy
hub / github.com/spencermountain/spacetime / date

Function date

builds/spacetime.cjs:2963–2987  ·  view source on GitHub ↗
(s, n, goFwd)

Source from the content-addressed store, hash-verified

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') {

Callers 1

spacetime.cjsFile · 0.70

Calls 6

monthMethod · 0.80
yearMethod · 0.80
validateFunction · 0.70
isLeapYearFunction · 0.70
walkToFunction · 0.70
fwdBkwdFunction · 0.70

Tested by

no test coverage detected