Coder Social home page Coder Social logo

openinghour-shorten's Introduction

openinghour-shorten

Build Status Coverage Status

shorten google map opening hour data

Install

$ npm install --save openinghour-shorten
$ yarn add openinghour-shorten

Usage

import openinghourShorten from 'openinghour-shorten';
//OR const openinghourShorten = require('openinghour-shorten');

// google map api response: result.opening_hours.periods
const openingHour = [
  { close: { day: 0, time: '2100' }, open: { day: 0, time: '1000' } },
  { close: { day: 1, time: '2100' }, open: { day: 1, time: '1100' } },
  { close: { day: 2, time: '2100' }, open: { day: 2, time: '1100' } },
  { close: { day: 3, time: '2100' }, open: { day: 3, time: '1100' } },
  { close: { day: 4, time: '2100' }, open: { day: 4, time: '1100' } },
  { close: { day: 5, time: '2200' }, open: { day: 5, time: '1100' } },
  { close: { day: 6, time: '2200' }, open: { day: 6, time: '1000' } }
];

openinghourShorten(openingHour);
//=> Sun 10:00~21:00; Mon-Thu 11:00~21:00; Fri 11:00~22:00; Sat 10:00~22:00

openinghourShorten(openingHour, { startByMonday: true });
//=> Mon-Thu 11:00~21:00; Fri 11:00~22:00; Sat 10:00~22:00; Sun 10:00~21:00

openinghourShorten(openingHour, { format12Hr: true });
//=> Sun 10:00AM~09:00PM; Mon-Thu 11:00AM~09:00PM; Fri 11:00AM~10:00PM; Sat 10:00AM~10:00PM

What's Next

License

MIT © Oahehc

Contributors

openinghour-shorten's People

Contributors

andrew-deepblu avatar dependabot-preview[bot] avatar oahehc avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.