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

@mailbutler/dayjs-plugins

v0.2.2

Published

Mailbutler dayjs utility and formatting plugins.

Downloads

372

Readme

@mailbutler/dayjs-plugins

A set of utility and formatting plugins for Dayjs.

Getting Started

Prerequisites

The plugins in this package depends on the following dayjs plugins:

  • calendar
  • localizedFormat

You also need to import the following locales before registering the plugin:

  • de
  • en
  • fr

You need to import those dependencies before you import the plugins from this package.

Installation

With npm (or yarn)

$ npm install --save @mailbutler/dayjs-plugins
$ # Or
$ yarn add @mailbutler/dayjs-plugins

With a CDN

Dayjs must be available as a global object so you will need to import it from a CDN too, we use unpkg here as an example.

<script src="https://unpkg.com/[email protected]/dayjs.min.js"></script>
<script src="https://unpkg.com/@mailbutler/[email protected]/dist/dayjs-plugin-mailbutler-calendar.min.js"></script>

Quick start

If you are using a bundler, like webpack or rollup you'll just need to require the lib.

If you are using a CDN, the lib will be available under window.dayjsPluginMailbutlerCalendar.

const dayjs = require('dayjs')
const localizedFormat = require('dayjs/plugin/localizedFormat');
const calendar = require('dayjs/plugin/calendar');
const { relative, calendarLocalization } = require('@mailbutler/dayjs-plugins')

// import required translation files
require('dayjs/locale/de')
require('dayjs/locale/en')
require('dayjs/locale/fr')

// register required plugins
dayjs.extends(localizedFormat)
dayjs.extends(calendar)

// register the plugins
dayjs.extends(calendarLocalization)
dayjs.extends(relative)

The calendarLocalization plugin

Depends on calendar and localizedFormat plugins.

Adds localized formatting for the calendar for the folllowing languages:

  • en
  • de
  • fr

When using calendar with one of these languages, the output string will be localized.

Example:

const localized = dayjs('2019-05-01').calendar();

The relative plugin

Depends on the calendarLocalization plugin.

adds two new methods to the dayjs instance.

  • relative allows the user to format the date relatively to another date.
  • relativeNow allows the user to format the date relatively to the current date.

Example:

// relative
dayjs('2018-12-12').relative(dayjs('2018-12-25'))
dayjs('2018-12-12').relativeNow()

Development

Clone the project to the directory and install dependencies

$ git clone https://github.com/Mailbutler/dayjs-plugins
$ cd dayjs-plugins
$ yarn # or npm install
$ npm i --no-save dayjs # install dayjs peer dependency

Start bundling in watch mode

$ npm run watch