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

spacetime-week-start

v0.2.0

Published

calculate start-of-week

Downloads

4

Readme

The start of a week varies officially in different countries.

This is a library to help understand week-starts/ends, by country or timezone.

It does some opinionated guesswork to determine the most appropriate week-start, when a timezone is given.

It returns an english name of the day used in javascript.

It is built for use in/with the spacetime library

Main function weekStart determines when week start in the current time zone or given coutry:

  • it accepts one optional argument - string name of the country
  • you don't have to supply full name of a country - it's enough write part of name (f.e. instead of united states of america just united states or unique part of name, like f.e. ted sta)
  • if searching for country name is successful it returns a simple JSON object for better clarification what is in output, looking f.e.:
{ day: 'sunday', country: 'united states of america' }
  • function also accepts text in any case (lower, upper, camel case)
  • just to make it easy for you write lower cased country name
  • there are some time zones with general names, such as gmt, utc or zulu. These returns JSON such as:
{ day: 'monday', location: 'zulu' }
  • if you write as argument different type as string, null, undefined or supply no argument at all it returns first day of weeek for current time zone
  • it uses spacetime library to determine current time zone only and rest is distinct for searching first day of week

npm i spacetime-week-start

const s = require('spacetime-week-start')

console.log('#1: ', s.weekStart());
console.log('#2: ', s.weekStart(12));
console.log('#3: ', s.weekStart(null));
console.log('#4: ', s.weekStart(''));
console.log('#5: ', s.weekStart(undefined));
console.log('#6: ', s.weekStart('abc'));
// all returns results for current tz, f.e. { day: 'sunday', country: 'canada' }

console.log('#7: ', weekStart('slovakia'));
// tz: europe/bratislava
// { day: 'monday', country: 'slovakia' }

console.log('#8: ', weekStart('iran'));
//tz: asia/tehran
// { day: 'saturday', country: 'iran' }

console.log('#9: ', weekStart('canAda'));
//tz: f.e. america/montreal
// { day: 'sunday', country: 'canada' }

console.log('#10: ', weekStart('lize'));
// tz: america/belize
// { day: 'monday', country: 'belize' }

console.log('#11: ', weekStart('el salvador'));
// tz: america/el_salvador
// { day: 'monday', country: 'el salvador' }

console.log('#12: ', weekStart('zulu'));
// tz: etc/zulu
// { day: 'monday', location: 'zulu' }

console.log('#13: ', weekStart('gmt'));
// tz: f.e. etc/gmt
// { day: 'monday', location: 'gmt' }

console.log('#14: ', weekStart('antarctica'));
// tz: f.e. antarctica/south_pole
// { day: 'monday', location: 'antarctica' }

console.log('#15: ', weekStart('arctic'));
// tz: f.e. arctic/longyearbyen
// { day: 'monday', location: 'arctic' }

Used various sources to determine most accurate guess:

work-in-progress

MIT