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

weeknumber

v1.2.1

Published

week number systems for Gregorian year according to ISO-8601 or starting on sundays, saturdays

Downloads

7,954

Readme

weeknumber

NPM version build status

week number systems for Gregorian year according to ISO-8601 or starting on sundays, saturdays

API

dayOfYear

Get day of year in Gregorian year

Parameters

  • date?: Date; optional: local date

Example

import { dayOfYear } from 'weeknumber'

dayOfYear(new Date(2017, 11, 31, 12))
//> 365
dayOfYear(new Date(2018, 0, 1, 12))
//> 1

Returns Number, number of day in year (1 ... 366)

weekNumber

ISO-8601 week numbering.

New week starts on Mondays. Used by most European countries, most of Asia and Oceania.

1st week contains 4-7 days of the new year.

Parameters

  • date?: Date; optional: local date

Example

import { weekNumber } from 'weeknumber'

weekNumber(new Date(2016, 0, 3, 12)) // Sun
//> 53
weekNumber(new Date(2016, 0, 4, 12)) // Mon
//> 1

Returns Number, week number in ISO 8601 format

weekNumberSun

North American and Islamic system.

New week starts on Sundays. Used in Canada, United States, India, Japan, Taiwan, Hong Kong, Macau, Israel, South Africa, most of Latin America.

1st week contains 1-7 days of the new year

Parameters

  • date?: Date; optional: local date

Example

weekNumberSun(new Date(2016, 0, 2, 12)) // Sat
//> 52
weekNumberSun(new Date(2016, 0, 3, 12)) // Sun
//> 1

Returns Number, week number

weekNumberSat

Middle Eastern system.

New week starts on Saturdays. Used in most of the Middle East.

1st week contains 1-7 days of the new year

Parameters

  • date?: Date; optional: local date

Example

weekNumberSat(new Date(2016, 0, 1, 12)) // Fri
//> 52
weekNumberSat(new Date(2016, 0, 2, 12)) // Sat
//> 1

Returns Number, week number

weekNumberYear

ISO-8601 calendar year, week, and day

New week starts on Mondays. Used by most European countries, most of Asia and Oceania.

1st week contains 4-7 days of the new year.

Parameters

  • date?: Date; optional: local date

Example

weekNumberYear(new Date(2008, 11, 29, 12)) // Monday
//> { year: 2009, week: 1, day: 1 }
weekNumberYear(new Date(2010, 0, 3, 12)) // Sunday
//> { year: 2009, week: 53, day: 7 }

Returns Object, {year, week, day} where day 1=Monday ... 7=Sunday

weekNumberYearSun

North American and Islamic system calendar year, week, and day

New week starts on Sundays. Used in Canada, United States, India, Japan, Taiwan, Hong Kong, Macau, Israel, South Africa, most of Latin America.

1st week contains 1-7 days of the new year

Parameters

  • date?: Date; optional: local date

Example

weekNumberYearSun(new Date(2009, 0, 3, 12)) // Saturday
//> { year: 2008, week: 52, day: 7 }
weekNumberYearSun(new Date(2009, 0, 4, 12)) // Sunday
//> { year: 2009, week: 1, day: 1 }

Returns Object, {year, week, day} where day 1=Sunday ... 7=Saturday

weekNumberYearSat

Middle Eastern system calendar year, week, and day

New week starts on Saturdays. Used in most of the Middle East.

1st week contains 1-7 days of the new year

Parameters

  • date?: Date; optional: local date

Example

weekNumberYearSat(new Date(2009, 0, 2, 12)) // Friday
//> { year: 2008, week: 52, day: 7 }
weekNumberYearSat(new Date(2009, 0, 3, 12)) // Saturday
//> { year: 2009, week: 1, day: 1 }

Returns Object, {year, week, day} where day 1=Saturday ... 7=Friday

weeksPerYear

ISO 8601 calendar weeks in a given year

New week starts on mondays. Used by most European countries, most of Asia and Oceania.

Parameters

  • year: number;

Returns number weeks in year

weeksPerYearSun

North American and islamic system calendar weeks in a given year

New week starts on sundays. Used in Canada, United States, India, Japan, Taiwan, Hong Kong, Macau, Israel, South Africa, most of Latin America.

Parameters

  • year: number;

Returns number weeks in year

weeksPerYearSat

Middle Eastern system calendar weeks in a given year

New week starts on saturdays. Used in most of the Middle East.

Parameters

  • year: number;

Returns number weeks in year

Installation

Requires nodejs.

$ npm install weeknumber

Tests

npm test

License

Unlicense https://unlicense.org/