How would you store a business's hours in the db/model of a Rails app?

后端 未结 5 750
余生分开走
余生分开走 2021-01-31 05:43

I\'m creating a Rails app that will store the opening and closing hours for a business. Originally, I thought of simply using a text data type and letting it be free-form:

5条回答
  •  离开以前
    2021-01-31 06:16

    I would say that Operating Hours belong to a Party Address, and should be represented by an RFC 5455 RRULE and optionally an EXRULE or EXDATEs.

    Let's say you have a Party:

    "Acme, Inc."

    They have one PhysicalAddress:

    "123 Main Street, Vancouver"

    Their address plays two roles:

    "Sales" and "Service"

    Sales is open Mo-Sa 10-8 and Service is open Mo-Fr 9-5

    These are the RRULES:

    (Sales)

    startTime:'10:00:00'
    endTime:'20:00:00'
    RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA
    

    (Service)

    startTime:'09:00:00'
    endTime:'17:00:00'
    RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR
    

提交回复
热议问题