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

tower_moment-readable

v1.0.1

Published

Readble time formats for moment. A moment plugin

Downloads

2

Readme

moment-readable

Readble time formats for moment. A moment plugin

Usage

Readable Date

Just call moment().readableDate() and it returns a string in a human-readable format, correct to day.

You can pass options to this function. Following are available options:

  • defaultFormat: The format to use for a ordinary date. If this is set, the defaultFormat and defaultFormatWithYear of i18n configurations is never used
  • currentWeek: Wether to return the day of the week if the given moment and the current moment are in the same week
  • nextWeek: Wether to return the day of the week if the given moment is in the next week of today
  • lastWeek: Wether to return the day of the week if the given moment is in the previous week of today

i18n

Define a locale

The locale definations of moment.js cannot satisfy the requirement of moment-readable.js, so moment.readable has its own locale defination.

The function moment.readable.defineLocale defines a locale for moment.readable. It demands 2 arguments, the abbreviation of the locale and the configurations. Available configurations are:

  • yesterday: Localized phrase of "Yesterday"
  • tomorrow: Localized phrase of "Tomorrow"
  • today: Localized phrase of "Today"
  • thisWeek: Localized phrase of "This Week"
  • nextWeek: Localized phrase of "Next Week"
  • lastWeek: Localized phrase of "Last Week"
  • thisWeekdays: Localized phrases of the seven days in this week, joined by '_'
  • nextWeekdays: Localized phrases of the seven days in next week, joined by '_'
  • lastWeekdays: Localized phrases of the seven days in previous week, joined by '_'
  • defaultFormat: default format to for a ordinary date which is in the same year with current moment
  • defaultFormatWithYear: default format to for a ordinary date which is not in the same year with current moment

For example, to define a new locale for spanish, just:

moment.readable.defineLocale('sp', {
	yesterday: 'ayer',
	tomorrow: 'mañana',
	today: 'hoy',
	thisWeek: 'esta semana',
	nextWeek: 'la próxima semana',
	lastWeek: 'la semana pasada',
	thisWeekdays: 'este domingo_este lunes_este martes_este miércoles_este jueves_este viernes_este sábado',
nextWeekdays: 'el domingo próximo_el lunes próximo_el martes próximo_el miércoles próximo_el jueves próximo_el viernes próximo_el sábado 	próximo',
	lastWeekdays: 'domingo pasado_lunes pasado_martes pasado_miércoles pasado_jueves pasado_viernes pasado_sábado pasado',
	defaultFormat: 'D de MMM',
	defaultFormatWithYear: 'D de MMM YYYY'
});

Determine the current locale

moment-readable use the locale of moment.