@honestfoodcompany/hfc-utility-plugin
v1.0.2
Published
This contains all the utility methods used across Honest food company
Downloads
1
Keywords
Readme
#HFC Utility Package
This package contains all the utility methods used across Honest food company.
openingHours utility
Param Description
- #####OpeningHourRule { fromDay : Monday, toDay : Firday toHour : 2, fromHour : 10, toMinute : 0, fromMinute : 0, description: Mon-Fri 10:00 - 02:00 }
Exposed function List
parseOpeningHourRulesForADate
This function will check if a date falls within an opening rule array or not. Will return OpeningHourRule valid for given datetime and the opening hour rule range in which it falls. @param openingHourRuleArr @param dateToCheck momentobject @returns { success: boolean, openingHourRuleActive: OpeningHourRule, openingHourRulesValid: OpeningHourRuleArr } success - If successfully parsed the opening hour rule array openingHourRuleActive - If given time falls within a range. Active opening hour rule for given date openingHourRulesValid - Valid opening hour rules for given date
helper.updateOpeningHours
If any opening hour rule has time spanning to next day. This function will add an extra opening hours and modify existing one with rule spanning to end of day. For Ex. rule Mon-Fri 10:00 - 02:00 This will be changed to (Mon-Fri 10:00 - 23:59 and Tue-Sat 00:00 - 02:00) Others will have no effect @param - OpeningHourRules @returns {any} openingHourRule Arr
helper.validateWeekday
Validate if a given opening hour rule is valid for given date. Ex: Given rule - Mon-Fri 10:00 - 02:00, dateToCheck - 2019-03-19 Will check if a rule is valid for dateToCheck @param openingHourRule @param dateToCheck string in format YYYY-MM-DD @returns {boolean}