-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix indentation: some files use tabs, other spaces. All should be set…
… to two spaces #8
- Loading branch information
Showing
14 changed files
with
714 additions
and
714 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
function haveDaysInCommon(days1, days2) { | ||
for (var i = 0; i < days1.length; i++) { | ||
var day1 = days1[i] | ||
for (var j = 0; j < days2.length; j++) { | ||
var day2 = days2[j] | ||
if (day1.id === day2.id) { | ||
return true | ||
} | ||
} | ||
} | ||
return false | ||
for (var i = 0; i < days1.length; i++) { | ||
var day1 = days1[i] | ||
for (var j = 0; j < days2.length; j++) { | ||
var day2 = days2[j] | ||
if (day1.id === day2.id) { | ||
return true | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
|
||
function addBedsCountPerWeek(retreat, participants) { | ||
for (var i = 0; i < retreat.weeks.length; i++) { | ||
var bedsAvailable = retreat.house.beds | ||
var week = retreat.weeks[i] | ||
for (var i = 0; i < retreat.weeks.length; i++) { | ||
var bedsAvailable = retreat.house.beds | ||
var week = retreat.weeks[i] | ||
|
||
// Remove a bed each time a participant is found in the week | ||
for (var j = 0; j < participants.length; j++) { | ||
var participant = participants[j] | ||
if (haveDaysInCommon(week.days, participant.days)) { | ||
bedsAvailable -= 1 | ||
} | ||
} | ||
// Remove a bed each time a participant is found in the week | ||
for (var j = 0; j < participants.length; j++) { | ||
var participant = participants[j] | ||
if (haveDaysInCommon(week.days, participant.days)) { | ||
bedsAvailable -= 1 | ||
} | ||
} | ||
|
||
// Add beds count to week | ||
retreat.weeks[i].beds = bedsAvailable | ||
} | ||
return retreat | ||
// Add beds count to week | ||
retreat.weeks[i].beds = bedsAvailable | ||
} | ||
return retreat | ||
} | ||
|
||
module.exports = { | ||
addBedsCountPerWeek: addBedsCountPerWeek | ||
addBedsCountPerWeek: addBedsCountPerWeek | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
function formatDay(date) { | ||
const weekDays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] | ||
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Nov', 'Dec'] | ||
return { | ||
id: months[date.getMonth()] + date.getDate(), | ||
name: weekDays[date.getDay()], | ||
number: date.getDate(), | ||
month: months[date.getMonth()], | ||
date: date | ||
} | ||
const weekDays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] | ||
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Nov', 'Dec'] | ||
return { | ||
id: months[date.getMonth()] + date.getDate(), | ||
name: weekDays[date.getDay()], | ||
number: date.getDate(), | ||
month: months[date.getMonth()], | ||
date: date | ||
} | ||
} | ||
|
||
function formatWeeks(beginDate, endDate) { | ||
var days = [] | ||
var day = new Date(beginDate) | ||
|
||
while(day.getTime() < new Date(endDate).getTime()) { | ||
days.push(formatDay(day)) | ||
day = new Date(day.getTime() + 24 * 60 * 60 * 1000) | ||
} | ||
days.push(formatDay(new Date(endDate))) | ||
|
||
var weeks = [] | ||
for (var i = 0; i < days.length; i++) { | ||
if (i % 7 == 0) { | ||
weeks.push({days: []}) | ||
} | ||
var weekIndex = parseInt(i / 7) | ||
weeks[weekIndex].days.push(days[i]) | ||
} | ||
|
||
return weeks | ||
var days = [] | ||
var day = new Date(beginDate) | ||
|
||
while(day.getTime() < new Date(endDate).getTime()) { | ||
days.push(formatDay(day)) | ||
day = new Date(day.getTime() + 24 * 60 * 60 * 1000) | ||
} | ||
days.push(formatDay(new Date(endDate))) | ||
|
||
var weeks = [] | ||
for (var i = 0; i < days.length; i++) { | ||
if (i % 7 == 0) { | ||
weeks.push({days: []}) | ||
} | ||
var weekIndex = parseInt(i / 7) | ||
weeks[weekIndex].days.push(days[i]) | ||
} | ||
|
||
return weeks | ||
} | ||
|
||
function formatDays(beginDate, endDate) { | ||
var days = [] | ||
var day = new Date(beginDate) | ||
var days = [] | ||
var day = new Date(beginDate) | ||
|
||
while(day.getTime() < new Date(endDate).getTime()) { | ||
days.push(formatDay(day)) | ||
day = new Date(day.getTime() + 24 * 60 * 60 * 1000) | ||
} | ||
days.push(formatDay(new Date(endDate))) | ||
while(day.getTime() < new Date(endDate).getTime()) { | ||
days.push(formatDay(day)) | ||
day = new Date(day.getTime() + 24 * 60 * 60 * 1000) | ||
} | ||
days.push(formatDay(new Date(endDate))) | ||
|
||
return days | ||
return days | ||
} | ||
|
||
module.exports = { | ||
formatDays: formatDays, | ||
formatWeeks: formatWeeks | ||
formatDays: formatDays, | ||
formatWeeks: formatWeeks | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.