@@ -65,18 +65,19 @@ const buildSchedule = (object, id) => {
65
65
} ;
66
66
67
67
/**
68
- * [todays room schedule information]
68
+ * [gets room schedule information by specific date ]
69
69
* @param {[object] } object [cherio html object]
70
- * @return {[object] } [only todays room schedule information]
70
+ * @param {[string] } id [sechdule id]
71
+ * @param {Date } [date=new Date()] [Date object]
72
+ * @return {[object] } [only room schedule information for specific date]
71
73
*/
72
- const buildTodaysSchedule = ( object , id ) => {
74
+ const buildScheduleByDate = ( object , id , date = new Date ( ) ) => {
73
75
const todaysSchedule = buildSchedule ( object , id )
74
76
. filter ( ( reservation ) => {
75
77
const reservationDate = _parseDate ( reservation . time . startDate ) ;
76
- const todaysDate = new Date ( ) ;
77
- return reservationDate . getFullYear ( ) === todaysDate . getFullYear ( ) &&
78
- reservationDate . getMonth ( ) === todaysDate . getMonth ( ) &&
79
- reservationDate . getDate ( ) === todaysDate . getDate ( ) ;
78
+ return reservationDate . getFullYear ( ) === date . getFullYear ( ) &&
79
+ reservationDate . getMonth ( ) === date . getMonth ( ) &&
80
+ reservationDate . getDate ( ) === date . getDate ( ) ;
80
81
} ) ;
81
82
return todaysSchedule . length > 0 ? todaysSchedule : null ;
82
83
} ;
@@ -88,7 +89,7 @@ const isValidSearch = html => {
88
89
89
90
module . exports = {
90
91
isValidSearch,
91
- buildTodaysSchedule ,
92
+ buildScheduleByDate ,
92
93
buildSchedule,
93
94
getSearchId,
94
95
getTypes,
0 commit comments