Business Hour Format

I’m creating a form which allow user to key in multiple days of week with multiple operation hours.

I want the format to save as below, but I found it tedious to reformat for displaying using normal javascript. Look into lodash and found it very handy 🙂

[
  {"day":"Mo","hour":{"from":"10am", "to":"2pm"}},
  {"day":"Mo","hour":{"from":"3pm", "to":"9pm"}},
  {"day":"Th","hour":{"from":"10am", "to":"2pm"}},
  {"day":"Th","hour":{"from":"3pm", "to":"9pm"}},
  {"day":"We","hour":{"from":"10am", "to":"2pm"}},
  {"day":"We","hour":{"from":"4pm", "to":"10pm"}},
];

Format to display:

Mo, Th, We : 10am-2pm
Mo, Th : 3pm-9pm
We : 4pm-10pm

Plunker here

Reference: schema.org

 

dicksonkho

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.