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

@bart-krakowski/get-week-info-polyfill

v1.0.8

Published

This package provides a polyfill for the Intl.Locale API, adding the getWeekInfo method if it is not already available in the environment.

Downloads

20

Readme

Intl.Locale.prototype.getWeekInfo() polyfill

This package provides a polyfill for the Intl.Locale API, adding the getWeekInfo method if it is not already available in the environment.

Installation

npm install @bart-krakowski/get-week-info-polyfill

Usage

require('@bart-krakowski/get-week-info-polyfill')

const he = new Intl.Locale('he') // Hebrew (Israel)
console.log(he.getWeekInfo()) // { firstDay: 7, weekend: [5, 6], minimalDays: 1 }

const af = new Intl.Locale('af') // Afrikaans (South Africa)
console.log(af.getWeekInfo()) // { firstDay: 7, weekend: [6, 7], minimalDays: 1 }

const enGB = new Intl.Locale('en-GB') // English (United Kingdom)
console.log(enGB.getWeekInfo()) // { firstDay: 1, weekend: [6, 7], minimalDays: 4 }

const arAF = new Intl.Locale('ar-AF') // Arabic (Afghanistan)
console.log(arAF.getWeekInfo()) // { firstDay: 6, weekend: [4, 5], minimalDays: 1 }

const dvMV = new Intl.Locale('dv-MV') // Divehi (Maldives)
console.log(dvMV.getWeekInfo()) // { firstDay: 5, weekend: [6, 7], minimalDays: 1 }

API

Intl.Locale.prototype.getWeekInfo returns an object containing week information for the locale.

Returns:

  • WeekInfo An object with the following properties:
    • firstDay (number) An integer between 1 (Monday) and 7 (Sunday) indicating the first day of the week for the locale. Commonly 1, 5, 6, or 7.
    • weekend (number[]) An array of integers between 1 and 7 indicating the weekend days for the locale. This is usually continuous because UTS 35 stores weekendStart and weekendEnd instead.
    • minimalDays (number) An integer between 1 and 7 (commonly 1 and 4) indicating the minimal days required in the first week of a month or year, for week-of-year or week-of-month calculations (e.g. The 20th week of the year). For example, in the ISO 8601 calendar, the first week of a year must have at least 4 days in this year, so if January 1 is a Friday, Saturday, or Sunday, it will be numbered as part of the last week of the previous year.