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

baats-ymd

v0.1.4

Published

Baats YMD - BAATS (Baavgai's TypeScript) Library

Downloads

6

Readme

Baats YMD - BAATS (Baavgai's TypeScript) Library

Simple day representation for simple programs.

The design goal here is to give a day represention that's easy to bind to in things like React. Immutablity, also a plus. Don't need the time, just the day.
Also, to be honest, I find Date confusing, as month is zero indexed and day isn't and it's always bugged me. The getDate() for day is also less than intuative.

More to come, maybe

Just thinking out loud here. This is currently mostly for me, but it needs somewhere to live.

At the most basic level, a calendar day is represented as:

interface IYearMonth {
  year: number; // note, can be negative
  month: number; // 1..12
}

interface IYearMonthDay extends IYearMonth {
  day: number;
}

Functions all return something, there's no messing with your object:

isYm(x: any): x is IYearMonth;
isYmd(x: any): x is IYearMonthDay;
isDate(x: any): x is Date;
toDate(x: IYearMonthDay | IYearMonth): Date;
clone(x: IYearMonthDay): IYearMonthDay;
create(year: number, month: number, day: number): IYearMonthDay;
fromDate(x: Date): IYearMonthDay;
toYmd(year: number, month: number, day: number): IYearMonthDay;
toYmd(x?: any): IYearMonthDay;
toYm(year: number, month: number): IYearMonth;
toYm(x: any): IYearMonth;
addMonths(x: IYearMonth, months: number): IYearMonth;
isLeap(x: IYearMonth): boolean;
getDaysInMonth(x: IYearMonth): number;
compareDay(x: IYearMonthDay, y: IYearMonthDay): number;
weekday(x: IYearMonthDay): number;
addDays(x: IYearMonthDay, days: number): IYearMonthDay;
toJulianDayNum(x: IYearMonthDay): number;
fromJulianDayNum(julianDayNum: number): IYearMonthDay;
getMonthNames(): string[];
getMonthShortNames(): string[];
getDayNames(): string[];
getDayShortNames(): string[];
format(x: IYearMonthDay, mask?: string): string;

Julian day is the continuous count of days since the beginning of the Julian Period used primarily by astronomers.

The Julian Day Number (JDN) is the integer assigned to a whole solar day in the Julian day count starting from noon Greenwich Mean Time, with Julian day number 0 assigned to the day starting at [...] November 24, 4714 BC, in the proleptic Gregorian calendar), a date at which three multi-year cycles started (which are: Indiction, Solar, and Lunar cycles) and which preceded any historical dates. For example, the Julian day number for the day starting at 12:00 UT on January 1, 2000, was 2,451,545.

-- https://en.wikipedia.org/wiki/Julian_day