MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / setMonth

Function setMonth

tests/test_code/js/moment/moment.js:1090–1113  ·  view source on GitHub ↗
(mom, value)

Source from the content-addressed store, hash-verified

1088 // MOMENTS
1089
1090 function setMonth(mom, value) {
1091 var dayOfMonth;
1092
1093 if (!mom.isValid()) {
1094 // No op
1095 return mom;
1096 }
1097
1098 if (typeof value === 'string') {
1099 if (/^\d+$/.test(value)) {
1100 value = toInt(value);
1101 } else {
1102 value = mom.localeData().monthsParse(value);
1103 // TODO: Another silent failure?
1104 if (!isNumber(value)) {
1105 return mom;
1106 }
1107 }
1108 }
1109
1110 dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
1111 mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
1112 return mom;
1113 }
1114
1115 function getSetMonth(value) {
1116 if (value != null) {

Callers 2

getSetMonthFunction · 0.85
addSubtractFunction · 0.85

Calls 4

toIntFunction · 0.85
isNumberFunction · 0.85
daysInMonthFunction · 0.85
testMethod · 0.80

Tested by

no test coverage detected