New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

date-frequency

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-frequency

Temporal frequency library

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
decreased by-63.04%
Maintainers
1
Weekly downloads
 
Created
Source

browser support

frequency Build status

Temporal frequency library

Example

var frequency = new Frequency();

frequency.on('hour', 10)
  .on('minute', 30)
  .between(new Date(2013, 8, 2), new Date(2013, 8, 8, 23, 59));

/*
  returns an array with these dates:
  2013-09-02 10:30:00
  2013-09-03 10:30:00
  2013-09-04 10:30:00
  2013-09-05 10:30:00
  2013-09-06 10:30:00
  2013-09-07 10:30:00
  2013-09-08 10:30:00
  */

Methods

Frequency()

Constructor takes a string notation (also see toString()).

var frequency = Frequency('F3D/WT10H30M'); // every 3rd day of the week (Wednesday) at 10:30:00

.on(unit, fix, [of])

Add frequency rules by specifying a unit and a value to fix it to. All units below the specified unit get fixed to the default (their value at the Unix epoch, 1970-01-01 00:00:00). The optional of parameter allows you to change the scope of the unit. By default each unit's scope is the unit above it in a regular date.

frequency.on('hour', 10); // sets the frequency to each day at 10:00:00
frequency.on('day', 6).on('hour', 10).on('minute', 30); // sets the frequency to the 6th day of each month at 12:30:00
frequency.on('day', 7, 'week'); // sets the frequency to Sundays at 00:00:00

.next(date)

Returns the next occurence of the frequency after the specified date.

.between(start, end)

Returns all occurences of the frequency between (and including) the specified start and end date.

.toString()

Returns a string notation of the frequency (useful for storage).

Todo

  • Add filters
    • odd/even (compared to reference date, e.g. Unix epoch)
    • nth ocurrence within scope (e.g. 2nd Thursday of the month)
  • Remove dependencies

Development

  • Install latest node.js version.
  • git clone https://github.com/smhg/date-frequency-js.git to fetch source.
  • npm install to install dependencies.
  • npm test to run tests.

License

The MIT License (MIT)

Copyright (c) Sam Hauglustaine

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 06 Mar 2014

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