Socket
Book a DemoInstallSign in
Socket

chronological

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chronological

Cron-like time schedule format and calculator

1.4.0
latest
Source
npmnpm
Version published
Maintainers
3
Created
Source

Chronological

Cron-like time schedule format and calculator

Using a starting anchor, iterates by a number of units. Units are the same as provided to moment.add.

Usage

var moment = require('moment');
var chrono = require('chronological');

moment = chrono(moment);

var iso8601 = 'YYYY-MM-DD[T]HH:mm:ssZ';

var startofday = moment.utc().startOf('day');
var everyday = startofday.every(1, 'day');

var daysinmonth = everyday.between(
    moment.utc().startOf('month').subtract(1, 'second'),
    moment.utc().endOf('month').add(1, 'second')
);
daysinmonth.forEach(function (d) {
    console.log(d.format(iso8601));
});

var firstdayafternow = everyday.after(moment.utc());
console.log(firstdayafternow.format(iso8601));

var firstdaybeforenow = everyday.before(moment.utc());
console.log(firstdaybeforenow.format(iso8601));

Bonus timer

var moment = require('moment-timezone');
var spanner = require('timespanner');
var chrono = require('chronological');

moment = chrono(spanner(moment));

var iso8601 = 'YYYY-MM-DD[T]HH:mm:ssZ';

moment.spanner('now/m+3s').every(10, 's').timer(function() {
  console.log(moment.utc().format(iso8601));
});

Keywords

cron

FAQs

Package last updated on 14 Aug 2018

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.