1.0.2 • Published 5 years ago

@honestfoodcompany/hfc-utility-plugin v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

#HFC Utility Package

This package contains all the utility methods used across Honest food company.

openingHours utility

Param Description 1. #####OpeningHourRule { fromDay : Monday, toDay : Firday toHour : 2, fromHour : 10, toMinute : 0, fromMinute : 0, description: Mon-Fri 10:00 - 02:00 }

Exposed function List 1. 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
  1. 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
  2. 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}
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago