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

@meniga/dates

v6.1.37-alpha.0

Published

A utility package for localized date formatting

Downloads

486

Readme

@meniga/dates

Dates is a utility library for working with dates and date locales. It's basically a wrapper for moment js right now but is abstracted so that we can easily switch 3rd party libraries if we want).

Exports


Date utilities

dates(date = null, format = null, strict = null)

Wrapper for moment(date, format, strict) or moment() if date is null

maxDate

Wrapper for moment.max

minDate

Wrapper for moment.min

formatDate(date, format, parseFromat, stripTime)

Wrapper for moment(date, parseFormat).format(format). If stripTime is given, the timestamp from the date object will be removed before formatting.

isSameDate(date, compareDate, dateGrouping)

Wrapper for moment(date).isSame(compareDate, dateGrouping)

isBeforeDate(date, compareDate, dateGrouping)

Wrapper for moment(date).isBefore(compareDate, dateGrouping)

isAfterDate(date, compareDate, dateGrouping)

Wrapper for moment(date).isAfter(compareDate, dateGrouping)

isSameOrBeforeDate(date, compareDate, dateGrouping)

Wrapper for moment(date).isSameOrBefore(compareDate, dateGrouping)

isSameOrAfterDate(date, compareDate, dateGrouping)

Wrapper for moment(date).isSameOrAfter(compareDate, dateGrouping)

isValidDate(date)

Wrapper for moment(date).isValid()

stripTimeFromDate(date)

Removes timestamp information from the date object

getWeekDayInCorrectFormat(format, date)

Formats a weekday in the grammatically correct custom format as defined in the locale settings for moment

getDaysLeft(date)

Returns the day difference between today and the given day

getDatesFromPeriod(period, includeCurrentMonth)

Meniga has a concept of period which is defined as:

0 = This month, [1-12] = Last X months, 'thisYear' = This year, 'lastYear' = Last year

This function gives you an object that includes the period itself, and the start and end dates for the given period. If includeCurrentMonth is true the end date will be the current month, otherwise it will be the last completed month.

Locale utilities

setLocale(locale, config)

Wrapper for moment.locale(locale) and moment.updateLocale(locale, config)

weekdaysShort(day)

Wrapper for moment.weekdaysShort(day)

weekdays(day)

Wrapper for moment.weekdays(day)

months(month)

Wrapper for moment.months(month)

monthsShort(month)

Wrapper for moment.monthsShort(month)

getLocaleObject

Returns a locale object intended for d3 use that includes the following:

{
	'periods': ['AM', 'PM'],
	'days': moment.weekdays(),
	'shortDays': moment.weekdaysShort(),
	'months': moment.months(),
	'shortMonths': moment.monthsShort(),
}

Example usage:

import { getLocaleObject } from '@meniga/dates'
import { timeFormatDefaultLocale } from 'd3-time-format'

const locale = getLocaleObject()
timeFormatDefaultLocale(locale)