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

@sharon-xa/strftime

v0.9.0

Published

lightweight ruby-like strftime date formatting implementation

Downloads

15

Readme

strftime

Ruby-like strftime method implementation in Javascript with / without the percentage notation.

The formatting is based on strftime.org

Usage

const date = new Date();
strftime(date, 'I:M p - A') // => 09:32 AM - Thursday
strftime(date, 'm/b/Y')     // => 1/Jan/2018
strftime(date, 'do B Y')    // => 18th January 2018

strftimeWithText(date, '%I:%M %p - %A') // => 09:32 AM - Thursday
strftimeWithText(date, '%m/%b/%Y')     // => 1/Jan/2018
strftimeWithText(date, '%d%o %B %Y')    // => 18th January 2018

Use strftime when you want a date or time or both only. Use strftimeWithText when you want your format string to contain text aside from the specifiers (take look at the Warning).

Warning

Don't use words inside the strftime function example:

const date = new Date();
strftime(date, 'The time is: I:M p') 
// This call will cause in error, this function only takes specifiers

Instead use strftimeWithText function that takes the % sign example:

const date = new Date();
strftimeWithText(date, 'The time is: %I:%M %p') 
// This is a fine call for this function 

Available Specifiers

Date

a => Abbreviated weekday name (e.g., Sun, Mon) Sun A => Full weekday name (e.g., Sunday, Monday) Sunday w => Day of the week (1-7, where 1 is Sunday) q => Padded day of the week (01-07) e => Day of the month (1-31) d => Padded day of the month (01-31) b => Short month name (e.g., Jan) B => Full month name (e.g., January) m => Month number (1-12) N => Padded month number (01-12) y => Short year (e.g., 22 for 2022) Y => Full year (e.g., 2022) o => Ordinal day of the month (st, nd, rd, th) x => Localized date string (e.g., "6/22/2023")

Time

H => Hours (0-23) h => Padded hours (00-23) I => 12-hour format (01-12) p => AM/PM M => Minutes (0-59) i => Padded minutes (00-59) S => Seconds (0-59) s => Padded seconds (00-59) f => Milliseconds X => Localized time string (e.g., "1:45:30 PM")

Date and Time

c => Date and time string (e.g., "Thu Jun 22 2023 - 13:45:30 GMT+0100 (GMT+01:00)")

NOTE

All these specifiers are available for strftime and strftimeWithText, The only difference is with using the % sign. strftime => no percentage sign strftimeWithText => with percentage sign