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

@kop3yka/time

v0.0.7

Published

The package contains the Time class, which provides the ability to conveniently work with the familiar Date class.

Readme

Time

Time is a lightweight library focused on time formatting and convenient manipulation. With it, you can easily perform mathematical operations with dates, compare them, and format them.

Constructor

The constructor takes 2 arguments: time — can be either a Date, Time object or a number (a UNIX timestamp). dateIn — an optional parameter. If time is given in seconds, you can specify 'seconds', and the time will be automatically multiplied by 1000.

Method Descriptions:

changeDefaultFormat(format: string) => void

This static method changes the default time format. For example, you can specify YYYY/MM/DD HH:mm:ss and you won’t have to pass this string to the format method every time. Important: the format changes for the entire application.

getDefaultFormat() => string

This method provides the current format as a string.

values() => {...}

This method returns an object with fields containing the year, month, day, hours, minutes, and seconds of the current date.

add...(any: number) => Time

These methods add the specified units of time to the current time. For example, addHours(1) will add 1 hour to the current date.

take...(any: number) => Time

These methods work the same way as the previous ones but subtract the specified unit of time from the current date.

getDifference...(date: Date = new Date()) => number

These methods return the difference between dates in the specified unit. For example, if the current date is now, and you call the method getDifferenceHours() passing a time that is 1 hour earlier, the method will return 1. If the time differs by, say, 30 minutes, the method will return 0. And if it differs by two days, it will return 48.

toMS() => number

The method returns a standard UNIX timestamp (in milliseconds).

toSeconds() => number

The method returns the UNIX time in seconds.

format(format: string = Time.defaultFormat) => string

The method converts the current time to a string in the specified format (or the default one). DD is replaced by days, MM by months, YYYY by years, HH by hours, mm by minutes, and ss by seconds. For example, DD/MM/YYYY HH:mm:ss will return the current time in the format DAY/MONTH/YEAR HOUR:MINUTES:SECONDS.

startOfDay() => Time

The method sets the time to 0 hours, 0 minutes, and 0 seconds.

endOfDay() => Time

The method sets the time to 23 hours, 59 minutes, and 59 seconds.

startOfMonth() => Time

The method sets the date to the first day of the current month and the time to 00:00:00.

endOfMonth() => Time

The method sets the date to the last day of the current month and the time to 23:59:59.

isPast() => boolean

The method returns true if this timestamp is earlier than the current time, and false otherwise.

isFuture() => boolean

The method returns true if this time has not yet occurred, and false otherwise.

clone() => Time

The method creates a complete copy of the current time, returning a new Time object that is independent of the original.

isEqual(otherTime: Time) => boolean

The method returns true if both times match exactly.

getMonthName() => string

Returns the name of the month.

getDayName() => string

Returns the name of the day.

parse(dateString: string, format: string = Time.defaultFormat) => Time

Parses a Time object from a string by format.

License

This project is licensed under the Apache License 2.0.
See the LICENSE file for details.