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

@robireton/chrono

v2.3.0

Published

date/time related helpers

Downloads

10

Readme

chrono

JavaScript Style Guide current version install size

date/time related helpers

Starting with v2.0.0, this is an ECMAScript module—stick with v1.x.x if you need a CommonJS module.

Exports

timestamp ( number )

Takes a number of milliseconds since January 1, 1970, 00:00:00 UTC (defaults to current time) and returns a string of the form 'YYYY-MM-DD HH:MM:SS'. The space between the date and time is a non-breaking space (U+00A0).

datetag ( number )

Takes a number of milliseconds since January 1, 1970, 00:00:00 UTC (defaults to current time) and returns a string of the form 'YYYY-MM-DD'.

dateFromUnix ( number )

Returns a Javascript Date object for the given unix timestamp (in seconds from 1970). Returns null if a number is not passed.

unixTime ( number or Date )

Returns a unix timestamp (in seconds from 1970) for a given Javascript Date object or equivalent number of milliseconds from 1970.

localDate ( string )

returns a Date object corresponding to a local date string in 'Y-M-D' format. 'Y-M' is interpereted as 'Y-M-1'.

Cron ( interval: number, days: iterable, hours: iterable )

class for creating an object that emits a cron event every interval milliseconds if current weekday index ∈ days and current hour index ∈ hours. Defaults for days and hours include all days and times. Event handlers for cron events are passed a Date object representing the instant the event was emitted.

Cron.prototype.interval: get or set the event interval (milliseconds)

Cron.prototype.days: get or set the Set of weekday indices on which events are emitted

Cron.prototype.hours: get or set the Set of hour indices during which events are emitted

Cron.prototype.close(): stop emitting events

months

An array of month information objects with fields:

| field | description | | --- | --- | | index | 0-based month number: January = 0 … December = 11 | | id | 1-based month number: January = 1 … December = 12 | | digits | 2-digit string: January = '01' … December = '12' | | long | full month name: 'January' … 'December' | | short | 3-character month abbreviation: 'Jan' … 'Dec' | | days | number of days in month (ignoring leap-years) |

weekdays

An array of weekday information objects with fields:

| field | description | | --- | --- | | index | 0-based weekday number: Sunday = 0 … Saturday = 6 | | long | full weekday name: 'Sunday' … 'Saturday' | | short | 3-character weekday abbreviation: 'Sun' … 'Sat' | | narrow | single character abbreviation (not injective) |

hours

An array of hour information objects with fields:

| field | description | | --- | --- | | index | 0-based hour number: 0 … 23 | | digits | 2-digit string: '00' … '23' |