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

py-strftime

v0.0.2

Published

Using Python's strftime function in Javascript

Downloads

6

Readme

py-strftime

Using Python's strftime function in Javascript

Build Status

Installation

$ npm install py-strftime
$ py-strftime --help

Usage

var date = new Date(2020, 0, 1)
strftime(date, '%c')
// "Wed Jan 01 00:00:00 2020"

Directives

Code | Meaning | Example ---- | ----------- | --- %a | Weekday as locale’s abbreviated name. | Mon %A | Weekday as locale’s full name. | Monday %w | Weekday as a decimal number, where 0 is Sunday and 6 is Saturday. | 1 %d | Day of the month as a zero-padded decimal number. | 30 %-d | Day of the month as a decimal number. (Platform specific) | 30 %b | Month as locale’s abbreviated name. | Sep %B | Month as locale’s full name. | September %m | Month as a zero-padded decimal number. | 09 %-m | Month as a decimal number. (Platform specific) | 9 %y | Year without century as a zero-padded decimal number. | 13 %Y | Year with century as a decimal number. | 2013 %H | Hour (24-hour clock) as a zero-padded decimal number. | 07 %-H | Hour (24-hour clock) as a decimal number. (Platform specific) | 7 %I | Hour (12-hour clock) as a zero-padded decimal number. | 07 %-I | Hour (12-hour clock) as a decimal number. (Platform specific) | 7 %p | Locale’s equivalent of either AM or PM. | AM %M | Minute as a zero-padded decimal number. | 06 %-M | Minute as a decimal number. (Platform specific) | 6 %S | Second as a zero-padded decimal number. | 05 %-S | Second as a decimal number. (Platform specific) | 5 %f | Microsecond as a decimal number, zero-padded on the left. | 000000 %z | UTC offset in the form +HHMM or -HHMM (empty string if the the object is naive). %Z | Time zone name (empty string if the object is naive). %j | Day of the year as a zero-padded decimal number. | 273 %-j | Day of the year as a decimal number. (Platform specific) | 273 %U | Week number of the year (Sunday as the first day of the week) as a zero padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0. | 39 %W | Week number of the year (Monday as the first day of the week) as a decimal number. All days in a new year preceding the first Monday are considered to be in week 0. | 39 %c | Locale’s appropriate date and time representation. | Mon Sep 30 07:06:05 2013 %x | Locale’s appropriate date representation. | 09/30/13 %X | Locale’s appropriate time representation. | 07:06:05 %% | A literal '%' character. | %

Reference: Python strftime cheat sheet

Localization

Day names, month names and the AM/PM indicators can be localized by passing an object with the necessary strings. For example:

var strftime = require('strftime');
strftime.i18n = {
    dayNames: [
        'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',
        'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
    ],
    monthNames: [
        'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
        'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
    ],
    timeNames: [
        'a', 'p', 'am', 'pm', 'A', 'P', 'AM', 'PM'
    ]
};

Notice that only one language is supported at a time and all strings must be present in the new value.

License

(c) 2020 JinXJinX, MIT license.