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

tempe

v1.0.12

Published

Featherlight (< 2kB) helper for simple javascript date formatting without all of those superpowers

Downloads

45

Readme

Featherlight (2kB) helper for Javascript date formatting

min min

Sometimes all you need is just a simple date formatting without all of those super powers.

Name is a play from tempus, Latin word meaning time and tempe an Indonesian traditional food.

📦 Install

$ yarn add tempe

 or

$ npm install tempe --save

💻 Usage

Use the default export, pass existing date object or you can initialize it like normal Javascript Date object.

import tempe from 'tempe';

// use tempe as Date initializer
tempe(2020, 0, 13).format('dd, DD MMM YYYY'); // "Monday, 13 Jan 2020"

// pass existing Date object to tempe
tempe(new Date(2020, 0, 13)).format('dd, DD MMM YYYY'); // "Monday, 13 Jan 2020"

// time formatting
tempe(2020, 2, 25, 23, 59).format('DD MMMM YYYY hh:mm:ss'); // "25 March 2020 23:59:00"
tempe(2020, 2, 25, 23, 59).format('H at DD/MM/YYYY'); // "11 PM at 25/03/2020"

🌐 i18n

Tempe supports internationalization by specifying the locale while formatting

import tempe from 'tempe';

tempe(2020, 5, 13).format('DD MMM YYYY', 'ja'); // "13日 6月 2020年"
tempe(2020, 5, 13).format('DD MMM YYYY', 'vi'); // "13 Tháng 6 2020"
tempe(2020, 5, 13).format('DD MMM YYYY', 'id'); // "13 Juni 2020"

Calendar Types

Meanwhile, some locale have their own default calendar type. For example, if you're using a Thailand locale it will generate a Buddhist calendar that show a different year than standard gregorian calendar.

tempe(2020, 5, 13).format('DD MMM YYYY', 'th'); // 13 มิถุนายน พ.ศ. 2563

You can change it by providing the calendar type in the third optional parameter of format() function.

// change calendar type to gregorian
tempe(2020, 5, 13).format('DD MMM YYYY', 'th', 'gregory' ); // 13 มิถุนายน พ.ศ. 2020

// change calendar type to islamic
tempe(2020, 5, 13).format('DD MMM YYYY', 'id', 'islamic' ); // 22 Syawal 1441 H

Possible values for this parameter includes:

  • "buddhist"
  • "chinese"
  • "coptic"
  • "ethiopia"
  • "ethiopic"
  • "gregory"
  • "hebrew"
  • "indian"
  • "islamic"
  • "iso8601"
  • "japanese"
  • "persian"
  • "roc"

This is an optional parameter. By leaving this parameter empty, the date will be generated using the default type of provided locale.

📝 List of all available formats

| Format | Output | Description | | ------ | ---------------- | ------------------------------------- | | YY | 18 | Two-digit year | | YYYY | 2018 | Four-digit year | | M | 1-12 | The month, beginning at 1 | | MM | 01-12 | The month, 2-digits | | MMM | Jan-Dec | The abbreviated month name | | MMMM | January-December | The full month name | | D | 1-31 | The day of the month | | DD | 01-31 | The day of the month, 2-digits | | dd | Sun-Sat | The short name of the day of the week | | ddd | Sunday-Saturday | The name of the day of the week | | H | 0-23 AM/PM | The hour with AM/PM | | HH | 0-23 AM/PM | The hour with AM/PM | | h | 01-12 | The hour, 12-hour clock | | hh | 01-12 | The hour, 12-hour clock | | m | 0-59 | The minute | | mm | 00-59 | The minute, 2-digits | | s | 0-59 | The second | | ss | 00-59 | The second, 2-digits |


This project was bootstrapped with TSDX.