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

sfn-date

v0.1.4

Published

Simple Formatting Nice Date functions for Node.js and browsers.

Downloads

10

Readme

SFN-Date

Simple Formatting Nice Date functions for Node.js and browsers.

Install

npm install sfn-date --save

Example

const date = require("sfn-date");

console.log("Y-m-d H:i:s", date("Y-m-d H:i:s"));
console.log("W M d Y H:i:s", date("W M d Y H:i:s"));
console.log("utc", date("utc"));
console.log("iso", date("iso"));

var count = 0;
console.log("\nStart ticking (Y-m-d H:i:s.ms)...");
date.tick("Y-m-d H:i:s.ms", text => {
    console.log(text);
    count += 1;
    if (count === 10)
        return false; // break tick.
}, 1000);

API

  • date(format?: string, timestamp?: number) Gets formatted date-time string.

    • format A format representation carries these symbols:

      • Y the year with 4 digits;
      • y the year with 2 digits;
      • Month the month in English;
      • M short-hand month;
      • m the month, 2 digits with leading zeros;
      • n the month, 1 or 2 digits without leading zeros;
      • d day of the month, 2 digits with leading zeros;
      • G 24-hour format of hours without leading zeros;
      • g 12-hour format of hours without leading zeros;
      • H 24-hour format hours with leading zeros;
      • h 12-hour format hours with leading zeros;
      • i minutes, with leading zeros;
      • s seconds, with leading zeros;
      • ms ms, with leading zeros;
      • Week day of the week in English;
      • W short-hand week;
      • A AM or PM;
      • a am or pm;
      • gmt GMT date-time string, case-insensitive;
      • utc same as gmt;
      • iso ISO8601 date-time string, case-insensitive.

      Default value is Y-m-d H:i:s.

    • timestamp Set a particular UNIX timestamp.

  • date.tick(format?: string, cb: (dateStr: string) => void, interval?: number): void Runs a function continuously according to a specific interval.

    • format is the format as date().
    • callback A function called every time reaches the interval, accepts one parameter, which is the current date-time string. If this function returns false, then break the time tick.
    • interval Default value is 1000 ms.

More Details About date.tick()

Unlike the original setInterval() function, this method won't start ticking immediately, it will firstly wait until the current time reaches a integral second, and runs the callback once before setting interval.