Skip to content

Commit

Permalink
now travis file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Manyike committed Jun 7, 2017
1 parent 9589023 commit 2c3fddf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions index.js
Expand Up @@ -30,34 +30,34 @@ function weekNumberOfCurrentMonth(dateOfTheCurrentMonth) {

function weekNumberForGivenDate (fullYear, fullMonth, dateOfTheMonth) {

if(!fullYear || !fullMonth || !dateOfTheMonth) {
if (!fullYear || !fullMonth || !dateOfTheMonth) {
return undefined;
}

if(fullYear.length > 4) {
if (fullYear.length > 4) {
return 'full year should be four digits e.g 2017'
}

if(parseInt(fullMonth) > 12 || parseInt(fullMonth) < 1) {
if (parseInt(fullMonth) > 12 || parseInt(fullMonth) < 1) {
return 'Full month should be between 1 and 12'
}

if(fullMonth.length > 1 && parseInt(fullMonth) < 10) {
if (fullMonth.length > 1 && parseInt(fullMonth) < 10) {
return 'Month should be between 1 and 12 i.e >=1 and <=12 and not 01 or 09';
}

if(dateOfTheMonth.length > 1 && parseInt(dateOfTheMonth) < 10) {
if (dateOfTheMonth.length > 1 && parseInt(dateOfTheMonth) < 10) {
return 'dateOfTheMonth should be between 1 and 31 i.e >=1 and <=31 and not 01 or 09';
}

if(parseInt(dateOfTheMonth) > 31) {
if (parseInt(dateOfTheMonth) > 31) {
return 'dateOfTheMonth should be between 1 and 31 i.e >=1 and <=31';
}

let paddedDayOfTheMonth = parseInt(dateOfTheMonth) > 9 ? dateOfTheMonth : '0' + dateOfTheMonth;
let paddedMonth = parseInt(fullMonth) > 9 ? fullMonth : '0' + fullMonth;

if(!moment(`${fullYear}-${paddedMonth}-${paddedDayOfTheMonth}`).isValid()) {
if (!moment(`${fullYear}-${paddedMonth}-${paddedDayOfTheMonth}`).isValid()) {
return 'supplied date is not valid';
}
let endOfMonth = moment(`${fullYear}-${paddedMonth}-${paddedDayOfTheMonth}`).endOf('month');
Expand All @@ -67,7 +67,7 @@ function weekNumberForGivenDate (fullYear, fullMonth, dateOfTheMonth) {
let weekCounter = 1;

for (let i = 1; i <= totalNumberOfDaysInAMonth; i++) {
if(beginningOfMonth === 6) {
if (beginningOfMonth === 6) {
thisMonthTracker[i] = weekCounter;
weekCounter++;
beginningOfMonth = 0;
Expand Down

0 comments on commit 2c3fddf

Please sign in to comment.