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

@patient-otter/dateonly

v0.1.5

Published

Date objects without time

Readme

dateonly

A drop in replacement for Date objects in JavaScript without a time component. This avoids any hassel having to do with timezones.

Why?

If you find yourself only caring about dates, like a birthday, holiday, or vacation day but the dates keep getting changed around because of timezones, this library avoids the hassel.

Status

This project is in beta. It is stable under the "happy path" usage but still needs to have added validation around inputs.

Installation

npm install @patient-otter/dateonly

Differences with Date Objects

There are some differences to with built in Date objects

  • The default date is 1970-01-01 not the current day. e.g. new DateOnly().toString() // 1970-01-01
  • The Constructor only takes numbers, you must use static methods to create from a number, string, or Date object
  • The month properties are indexed at 1, so the range is 1-12 where 1 is January 12 is December

Usage

under construction...

import DateOnly from "@patient-otter/dateonly";

const dt = new DateOnly() //1970-01-01

dt.setDate(dt.getDate() + 12)
//1970-01-13

dt.toJSON() //1970-01-13T:00:00.000Z

const dateWithTime = new Date();
const dateWithouttime = DateOnly.fromDate(dateWithTime);

const dateFromString = DateOnly.fromString('06/25/2030');

console.log(dateFromString.toString()) //'2030-06-25'

API

Classes

Create a new DateOnly object

Kind: global class

new Create a new DateOnly object([year], [date], [month])

| Param | Type | Default | Description | | --- | --- | --- | --- | | [year] | number | 1970 | The year the of the date | | [date] | number | 1 | The year the of the date | | [month] | number | 1 | The year the of the date |

DateOnly

A date object with without time

Kind: global class

dateOnly.getFullYear()

Return the year only from the DateOnly

Kind: instance method of DateOnly
Returns{number}:

dateOnly.getMonth()

Return the month value from the DateOnly. Indexed from 1, 12 is december

Kind: instance method of DateOnly
Returns{number}:

dateOnly.getDate()

Return the date value, or the day of the month Indexed from 1, max of 31 depending the month

Kind: instance method of DateOnly
Returns{number}:

dateOnly.setFullYear(v)

Return the year only from the DateOnly

Kind: instance method of DateOnly

| Param | Type | Description | | --- | --- | --- | | v | number | The new desired value for the year |

dateOnly.getDay()

Get day of the week

Kind: instance method of DateOnly

dateOnly.setMonth(v)

Return the month value from the DateOnly. Indexed from 1, 12 is december

Kind: instance method of DateOnly

| Param | Type | Description | | --- | --- | --- | | v | number | The new desired value for the value |

dateOnly.setDate(v)

Set the date value, or the day of the month

Kind: instance method of DateOnly

| Param | Type | Description | | --- | --- | --- | | v | number | The new desired value for the date |

dateOnly.toString([sep])

Set the date value, or the day of the month

Kind: instance method of DateOnly
Returns{string}: the date represented as a string

| Param | Type | Default | Description | | --- | --- | --- | --- | | [sep] | string | "-" | The seperator to use between date components |

dateOnly.toISOString()

Return a string in ISO8601 format All time values are set to zero

Kind: instance method of DateOnly
Returns{string}: the date represented as an ISO8601 string

dateOnly.toJSON()

JSON serializes the date to an ISO8601 date

Kind: instance method of DateOnly
Returns{string}: the date represented as an ISO8601 string

dateOnly.toDateString()

Returns a Date stirng

Kind: instance method of DateOnly

dateOnly.isValid()

Returns if the current date time object is valid or not

Kind: instance method of DateOnly

DateOnly.fromNumber(n)

Crete a DateOnly Object from a number, numbers represent the days since 1 Jan 1970

Kind: static method of DateOnly

| Param | Type | Description | | --- | --- | --- | | n | number | The number to be converted to a DateOnly Object |

DateOnly.fromString(s)

Create a DateOnly Object from some string. Wraps new Date(str)

Kind: static method of DateOnly

| Param | Type | Description | | --- | --- | --- | | s | string | The string to read the date info from |

DateOnly.fromDate(d)

Create a DateOnly Object from some string. Wraps new Date(str)

Kind: static method of DateOnly

| Param | Type | Description | | --- | --- | --- | | d | Date | The date to use in creating a new DateOnly object using the date's UTC values |

DateOnly.now()

Create a new DateOnly object for the current date

Kind: static method of DateOnly
Returns{dateonly}: A donly only object with the current local date