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

astrodate

v0.7.10

Published

Javascript Date object with Astronomy in mind.

Downloads

42

Readme

Master

Build Status

Dependency Status

Dev Dependency Status

Coverage Status

NPM version

browser support

#AstroDate 0.7.10

Graham Fairweather [email protected]

Still very much work in progress, so there are bugs and the API has not been fully defined (or documented) and is subject to major changes.

The idea behind the project is to not rely on Javascript's rather flaky Date object, give better accuracy, flexibility and be cross-browser.

Besides the standard Gregorian calendar, the Julian calendar is also available. This allows for AstroDate to be used in astronomical calculations. A set of routines will be made available for changing between systems and methods for obtaining Julian Day Numbers, Julian Dates, Modified Julian Dates, Delta Time and Terestrial Time etc.

For dates beyond the normal Date range and Javascript's limited number arithmetic, it is necessary to do the Math using arbitrary-precision arithmetic, BigNumber.js is the library chosen for this.

Both calendars can be extrapolated to dates prior to their first adoption and hence are a Proleptic Gregorian calendar and Proleptic Julian Calendar.

AstroDate includes an ISO 8601 parser as one means of setting the date and time, other methods will be available, ie. using an Array and Object of discrete values.

As with ISO 8601 and the Proleptic calendars, Astronomical year numbering will be used for input and so have a year zero. Outputs may be formated to use either Astronomical year numbering or Calendar Era numbering, ie. BC/AD.

It is not intended for AstroDate to be a generic date parser and handle formats like 13/10/12. Though in future it will be possible to develop addons to do this.

Times beginning 1961 will be assumed to be UTC before this it is assumed to be Universal Time, specifically UT1.

You can see AstroDate in use (jsFiddle) to get an idea of how things are currently functioning until the API and documentation are standardised.

CLDR Languages available.

  • ar
  • ca
  • cs
  • da
  • de
  • el
  • en
  • en_AU
  • en_CA
  • en_GB
  • en_HK
  • en_IN
  • es
  • fi
  • fr
  • he
  • hi
  • hr
  • hu
  • it
  • ja
  • ko
  • nb
  • nl
  • pl
  • pt
  • pt_PT
  • ro
  • root
  • ru
  • sk
  • sl
  • sr
  • sv
  • th
  • tr
  • uk
  • vi
  • zh
  • zh_Hant

The defaut language is 'en'.

Once loaded use AstroDate.lang('en'); to set the default application language, or change a particular instance new AstroDate().lang('en-GB');

CLDR locale modifiers

Loaded languages may be modified for locale, use AstroDate.locale('sr_ME'); to set the default application locale, or change a particular instance new AstroDate().locale('sr_RO');

toString methods

By default .toString(), .toDateString() and .toTimeString() use 'full' locale format, options are 'full', 'long', 'medium' and 'short'.

.toISOString() has no modifiers and will produce a standard ISO 8601 time-stamp string, ie. 1972-07-01T00:00:00.000Z

Pattern formatting

.format("YYYY'-W'ww'-'E") // 2013-W46-3

Date and time formats are specified by date and time pattern strings. Within date and time pattern strings, all unquoted ASCII letters [A-Za-z] are reserved as pattern letters representing calendar fields. astrodate supports the date and time formatting algorithm and pattern letters defined by UTS#35 Unicode Locale Data Markup Language (LDML)

Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', '.', ' ', '#' and '@' will appear in the resulting time text even they are not embraced within single quotes.

A pattern containing any invalid pattern letter will result in a thrown exception during formatting.