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

chrono

v1.0.5

Published

Format dates in JavaScript

Downloads

1,313

Readme

chrono.js Build Status

Date.prototype.format(format, [timezone])

Allows formatting of time in a strftime style, but with syntax taken from PHP's date function. It implements pretty much all of the tokens from PHP's date function, except for B (Swatch internet time) and e (Content/City timezone identifier). You can escape characters with a \ (remember to encode the \ in a string as well). All other characters will be printed as they appear in the format string.

The optional timezone parameter specifies the time zone to be used. The values allowed are the same as for Date.prototype.setTimezone(). If no value is specified, the Date object's internal time zone will be used.

The function returns a string with the tokens replaced with the Date object's information.

Example: new Date().format('d.m.Y H:i:s', 'CET'); returns 19.10.2010 15:48:20 (in CET, without regard to DST).

Date.prototype.isLeapYear()

Returns true if the Date object's UTC date is in a leap year.

Date.prototype.getUTCISOWeek()

Returns the ISO-8601 week number of the year, using the Date object's UTC date.

Date.prototype.getUTCISOFullYear()

Returns the ISO-8601 year, using the Date object's UTC date. This is generally the same as the Gregorian year, but may sometimes deviate at the beginning or end of the year. It is commonly used in conjunction with the ISO-8601 week number.

Date.prototype.getUTCDaysOfMonth()

Returns the number of days in the Date object's UTC date's month.

Date.prototype.getUTCDayOfYear()

Returns the day of the year of the Date object's UTC date.

Date.prototype.getTimezone()

Returns the deviation from UTC in minutes (using JavaScript's inverse offset). If no explicit time zone has been specified, it returns the system clock's time zone offset.

Date.prototype.getTimezoneName()

Returns the time zone acronym of the Date object's timezone.

Date.prototype.setTimezone(val)

Sets the Date object's timezone. Numbers are interpreted as deviation in minutes from UTC, with positive values west of UTC and negative values east thereof (this is JavaScript's way of specifying time zone offset and is the exact opposite of how timezone offsets normally work). Alternatively, you can specify a offset in RFC2822 notation, for example '+0200' for UTC + 2 hours. Common time zone shortcuts like 'PST' also work.

TESTS

Tests can be run with make test after installing Expresso. make test-cov reports test coverage.