bramdeleeuw / silverstripe-openinghours
将营业时间添加到数据对象
1.1.2
2023-02-23 11:04 UTC
Requires
README
将营业时间添加到数据对象。我建议添加silverstripe-australia/addressable来将营业时间和地址数据添加到商店网站。未来我建议使用bramdeleeuw/silverstripe-schema来添加结构化数据,如商店信息,到您的网站,但这项工作仍在进行中。
要添加营业时间,只需扩展您想使用它们的对象。
YourObject: extensions: - 'Broarm\OpeningHours\OpeningHours'
该对象包含一些方法,您可以使用它们来显示营业时间
// Returns the opening hours as a summarized list, this means days with similar opening hours are combined e.g "Mon – Tue" $openingHourHolder->getOpeningHoursSummarized() // Returns todays opening hours $openingHourHolder->getOpeningHoursToday() // Return the short localized version for the current day (in the loop) $openingHour->getShortDay(); // Return the short localized version for the current day (in the loop) $openingHour->getFullDay(); // Return the concatnated days list as a range, only used when looping over the summarized days loop. $openingHour->getConcatenatedDays(); // Returns true when the From and Till data are equal (shop is closed for that day) $openingHour->IsClosed(); // Returns true when the current time falls between the opening hours $openingHour->IsOpenNow();