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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@divante-adventure/work-moment

v1.0.2

Published

Improved moment.js library with more features for Adventure.

Readme

work-moment

moment.js extended with moment-range and some utility functions.

Index

Installation

npm install -S @divante-adventure/work-moment

It contains all functions from moment.js extended with moment-range, so in order to replace moment.js with this library you just need to replace:

import moment from 'moment';

or, in case of extending with moment-range:

import Moment from 'moment';
import {extendMoment} from 'moment-range';
const moment = extendMoment(Moment);

with this one line:

import moment from '@divante-adventure/work-moment';

All functions of moment and moment-range are now working:

let date = moment('2018-11-29');
console.log(date.year()); // 2018

let start = moment('2018-11-01');
let end = moment('2018-11-30');
let range = moment.range(start, end);
let days = Array.from(range.by('day')).length;
console.log(days); // 30

work-moment utility functions

toIsoDate

Converts date to ISO 8601 ordinal date:

YYYYDDD

Where YYYY is a four-digit year and DDD is a three-digit day in year.

moment.toIsoDate() is a shortcut for moment.format('YYYYDDDD').

console.log(moment('2018-01-01').isoDate()); //2018001
console.log(moment('2018-11-29').isoDate()); //2018333

rangeOf

Creates range object with given range including date. For example, if your moment object points at 2018-11-23 and you will use rangeOf('month'), it will return range starting in 2018-11-01 and ending in 2018-11-30.

let date = moment('2018-03-15');
let year = date.rangeOf('year');
console.log(year.start.format('YYYY-MM-DD')); //2018-01-01
console.log(year.end.format('YYYY-MM-DD')); //2018-12-31

Shortcuts for rangeOf

let date = moment('2018-03-15');
let day = date.rangeOfDay(); // === date.rangeOf('day');
let week = date.rangeOfWeek(); // === date.rangeOf('week');
let month = date.rangeOfMonth(); // === date.rangeOf('month');
let quarter = date.rangeOfQuarter(); // === date.rangeOf('quarter');
let year = date.rangeOfYear();  // === date.rangeOf('year');

isFreeDay and isWorkingDay

isFreeDay return true if given day is either saturday or sunday and false otherwise. isWorkingDay returns opposite values.

moment('2018-11-09').isFreeDay(); // false
moment('2018-11-09').isWorkingDay(); //true

moment('2018-11-10').isFreeDay(); // true
moment('2018-11-10').isWorkingDay(); // false

As an additional parameter, you can pass array of free days formatted in ISO 8601 ordinal date (result of toIsoDate function). These days will be treated as additional free days, i.e. holidays.

let freeDays = ['2018-12-25', '2018-12-26']; //Christmas
let formattedFreeDays = freeDays.map(entry => moment(entry).toIsoDate()); // ISO 8601 formatted dates

moment('2018-12-25').isFreeDay(); // false - 25th of December 2018 is a tuesday
moment('2018-12-25').isFreeDay(formattedFreeDays); // true

workingDays

For given range (treated as in rangeOf function) returns array of working days. It can also accept ISO 8601 ordinal dates array as additional free days.

let freeDays = ['2018-12-25', '2018-12-26']; //Christmas
let formattedFreeDays = freeDays.map(entry => moment(entry).toIsoDate()); // ISO 8601 formatted dates

//returns array of 5 entries between 2018-12-24 and 2018-12-28:
moment('2018-12-25').workingDays('week');

//returns array of 3 entries: 2018-12-24, 2018-12-27 and 2018-12-28:
moment('2018-12-25').workingDays('week', formattedFreeDays);

workingDaysCount

workingDaysCount is a shortcut for workingDays.length:

let freeDays = ['2018-12-25', '2018-12-26']; //Christmas
let formattedFreeDays = freeDays.map(entry => moment(entry).toIsoDate()); // ISO 8601 formatted dates

moment('2018-12-25').workingDaysCount('week'); //5
moment('2018-12-25').workingDaysCount('week', formattedFreeDays); //3

workingSeconds

Applies multiplier to workingDaysCount. By default one working day equals to 8 hours (28800 seconds).

let freeDays = ['2018-12-25', '2018-12-26']; //Christmas
let formattedFreeDays = freeDays.map(entry => moment(entry).toIsoDate()); // ISO 8601 formatted dates
let fourHours = 4 * 60 * 60; // 14400 seconds

moment('2018-12-25').workingDaysCount('week'); // 5
moment('2018-12-25').workingSeconds('week'); // 5 * 28800
moment('2018-12-25').workingSeconds('week', [], fourHours); // 5 * 14400
moment('2018-12-25').workingDaysCount('week', formattedFreeDays); // 3
moment('2018-12-25').workingDaysCount('week', formattedFreeDays); // 3 * 28800
moment('2018-12-25').workingDaysCount('week', formattedFreeDays, fourHours); // 3 * 14400