npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

1-line-opening-hours

v0.3.2

Published

Simple parser for OpenStreetMap `opening_hours`

Downloads

264

Readme

1-line-opening-hours

Get rid of heavy responses from API when using simple opening hours, by using the OpenStreetMap opening_hours format.

This was first forked from wbkd. The project then aimed to be bigger, so a lot of code has been rewrote and new features added.

It only supports the human readable parts and not this complete crazy overengineered specification.

Supported opening_hours examples

  • Mo-Sa 06:00-22:00
  • Mo-Fr 08:00-18:00; Sa 10:00-14:00
  • Mo-Fr 08:00-18:00; Sa,Su 10:00-20:00
  • Mo-Fr 08:00-12:00, We 14:00-18:00
  • Mo-Fr 08:00-12:00, 14:00-18:00
  • Mo-Fr 08:00+
  • Mo-Fr 08:00-01:00
  • Mo-Fr 08:00-18:00; We off
  • 24/7

Getting started

Install

npm install 1-line-opening-hours --save
yarn add 1-line-opening-hours

Usage

const openingHours = new OpeningHours('Mo-Sa 06:00-22:00');

console.log('Is this open now?', openingHours.isOpenNow());
console.log('Is this open on 2016-10-01 18:00?', openingHours.isOpenOn(new Date('2016-10-01 18:00')));
console.table(openingHours.getTable());

API

| Method | Description | Return value | |--------|-------------|--------------| | isOpenNow() | Check whether the establishment is open now based on the provided opening hour | true or false | isOpenOn(date: Date) | Same than above for any date | true or false | getTable() | Get an array of each day and the corresponding opening time | { su: [], mo: ['06:00-22:00'] ... } | getFullStatusOfToday() | Send more information about the current opening status, the next day that it will be opened... | { open: false openUntil: null, nextReopening: { hour: '11:00', day: 'tu', opensInDay: 0 } | getFullStatusOfDay(date: Date) | Same than above for any date | { open: false openUntil: null, nextReopening: { hour: '11:00', day: 'tu', opensInDay: 0 }