Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

moment-business-time

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moment-business-time

Query and manipulate moment objects within the context of business/working hours

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.6K
increased by5.2%
Maintainers
1
Weekly downloads
 
Created
Source

moment-business-time

Query and manipulate moment objects within the scope of business/working hours.

Install

npm install [--save] moment-business-time

Methods

moment#isWorkingDay

Returns: Boolean Determines if the day of the current instance is a working day. Working days are defined as any day with working hours in the current locale.

Example:
moment('2015-02-27').isWorkingDay();
// true
moment('2015-02-28').isWorkingDay();
// false

moment#isWorkingTime

Returns: Boolean Determines if the day and time of the current instance corresponds to during business hours as defined by the currnet locale.

Example:
moment('2015-02-27T15:00:00').isWorkingTime();
// true
moment('2015-02-27T20:00:00').isWorkingTime();
// false

moment#nextWorkingDay

Returns: moment Returns a new moment representing the next day considered to be a working day. The hours/minutes/seconds will be as for the source moment.

Example:
moment('2015-02-28T10:00:00Z').nextWorkingDay();
// Mon Mar 02 2015 10:00:00 GMT+0000
moment('2015-02-28T20:00:00Z').nextWorkingDay();
// Mon Mar 02 2015 20:00:00 GMT+0000

moment#nextWorkingTime

Returns: moment Returns a new moment representing the start of the next day considered to be a working day.

Example:
moment('2015-02-28T10:00:00Z').nextWorkingTime();
// Mon Mar 02 2015 09:00:00 GMT+0000
moment('2015-02-28T20:00:00Z').nextWorkingTime();
// Mon Mar 02 2015 09:00:00 GMT+0000

moment#lastWorkingDay

Returns: moment Returns a new moment representing the previous day considered to be a working day. The hours/minutes/seconds will be as for the source moment.

Example:
moment('2015-02-28T10:00:00Z').lastWorkingDay();
// Fri Feb 27 2015 10:00:00 GMT+0000
moment('2015-02-28T20:00:00Z').lastWorkingDay();
// Fri Feb 27 2015 20:00:00 GMT+0000

moment#lastWorkingTime

Returns: moment Returns a new moment representing the end of the previous day considered to be a working day.

Example:
moment('2015-02-28T10:00:00Z').lastWorkingTime();
// Fri Feb 27 2015 17:00:00 GMT+0000
moment('2015-02-28T20:00:00Z').lastWorkingTime();
// Fri Feb 27 2015 17:00:00 GMT+0000

moment#addWorkingTime

Returns: self Adds an amount of working time to a moment, modifying the original moment instance.

Example:
moment('2015-02-27T10:00:00Z').addWorkingTime(5, 'hours');
// Fri Feb 27 2015 15:00:00 GMT+0000
moment('2015-02-28T10:00:00Z').addWorkingTime(5, 'hours');
// Mon Mar 02 2015 14:00:00 GMT+0000
moment('2015-02-27T10:00:00Z').addWorkingTime(5, 'hours', 30, 'minutes');
// Fri Feb 27 2015 15:30:00 GMT+0000

moment#subtractWorkingTime

Returns: self Adds an amount of working time to a moment, modifying the original moment instance.

Example:
moment('2015-02-27T16:00:00Z').subtractWorkingTime(5, 'hours');
// Fri Feb 27 2015 11:00:00 GMT+0000
moment('2015-02-28T16:00:00Z').subtractWorkingTime(5, 'hours');
// Fri Feb 27 2015 12:00:00 GMT+0000
moment('2015-02-27T16:00:00Z').subtractWorkingTime(5, 'hours', 30, 'minutes');
// Fri Feb 27 2015 10:30:00 GMT+0000

Running tests

npm test

Keywords

FAQs

Package last updated on 27 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc