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 🙏

© 2026 – Pkg Stats / Ryan Hefner

strongdate

v0.0.2

Published

Correct timezone on a user device

Downloads

1

Readme

StrongDate

A wrapper for Date to calculate a near correct timezone if timezone on a user device is wrong.

This is a big issue for countries that recently changed their timezone(s). There are many phones, and tablets, and even PCs that do not update (especially Android devices). And also some users don't know how (or care) to choose their timezone correctly and instead change time to match their local time.

How StrongDate works

You supply it with a correct timestamp.

var StrongDate = SD({ timestamp: 1442685785698 });

And then use it just like the standard Date.

var myDate = new StrongDate();
myDate.toString(); // 'Sat Jul 11 2015 16:47:30 GMT+0548 (AREA 51)'

StrongDate stores two Date objects inside, the first holds correct UTC time, and the second object with the local time (we assume that observable time is right for the user). Basically StrongDate redirects all methods that deal with UTC to the first object, and all local methods to the second object. It also calculates timezone offset between those.

Installation

Download the latest version from Github or use npm or Bower:

npm install strongdate

Then just include dist/strongdate.js or dist/strongdate.min.js in your html. AMD-version of the library that also supports Browserify also available as dist/strongdate-amd.js/dist/strongdate-amd.min.js.

API

SD(options)

SD function accepts an options object, which can include:

  • timestamp is the correct timestamp you obtain from your server. You'll need to take into account network latency, and deal with it yourself.

  • offset is a precalculated offset in milliseconds.

  • threshold is a threshold value in milliseconds. StrongDate will kick in only if the absolute value of the offset is larger than this. Defaults to 10 min

Either timestamp or offset is required. SD returns StrondDate only if timestamp is correct or offset is larger than a threshold. Otherwise it returns standard Date.

StrongDate

StrongDate has pretty much the same API as Date, so in most cases you can add it drop-in in your project.

The only exceptions are static methods of Date (now, UTC, parse) that currently are not implemented.

StrongDate also exposes _offset property which value you can cache and supply to SD on the next run.

Important note

Note that this library is experimental in some sense. The things may and will go wrong if not only time but user date is different, so always do test if you can rely on it in your particular case.

License

MIT