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

svz-date

v3.2.3

Published

A tool for managing Dates and time spaces, with a variety of use cases, including formatting from a string and reporting lengths of time between two times in any measurement, from ms to millenia.

Downloads

8

Readme

svz-date

This module provides four management classes for manipulating Numbers, Objects, Cookies, and Dates in ways with multiple use cases I've employed on a number of occasions.

Installation

To install, in terminal type

	npm i --save svz-date

then, in your project,

import SVZDate from 'svz-date';

SVZDate(time)

Manipulates a supplied date in a variety of ways to suit all your datetime needs!


Class Variables

  • format Type: string This is probably one of the best features of the SVZDate. When you supply a string setting your format, given particular parameters, the result of the toString method will be altered to reflect your new format!

YY | yy: a 2 digit date string (88) YYYY | yyyy: a full date string. (1988)

M or m when directly preceded or followed by time value ( h, s, 0, z, am/pm, ): M | m : minutes without leading 0. MM | mm : 2 digit minutes.

M or m otherwise: m: month without leading 0. mm: 2 digit months. M: first letter of month. MM: three letter month abbreviation. MMM: full month

D | d: Day of month without leading 0. DD | dd: Day of month in two digit format.

W | w: First letter of weekday. WW | ww: Three letter weekday abbreviation. WWW | www: full weekday as string.

h: 12 hour style hour without leading 0. hh: 2 digit 12 hour style hour. H: 24 hour style hour without leading 0. HH: 2 24 hour style hour.

S | s: seconds without leading 0. SS | ss: seconds in 2 digit format.

0 | 00 | 000 | 0000: milliseconds by that number of digits.

z: generic timezone letter abbreviation.
zz: full generic timezone name.
Z: timezone letter abbrevation.
ZZ: full timezone name.

O | o: timezone offset without leading 0.
OO | o: timezone offset in 2 digit format.

AM/PM : AM or PM of 12 hour time.
am/pm : am or pm of 12 hour time.

  • valid
    Read Only Type: SVZDate | null If the current string or number supplied is a valid date, this simply returns the SVZDate, if not it returns null.

  • fromToday
    Read Only
    Returns the date an amount of time into the future from the current moment.

  • milliseconds
    Read Only
    ms: Returns the total number of milliseconds in the time period given.
    date: Returns the number of milliseconds from the last second in the Date given.

  • seconds
    Read Only
    ms: Returns the total number of seconds in the time period given.
    date: Returns the total number of seconds from the beginning of the last minute in the Date given.

  • minutes
    Read Only
    ms: Returns the total number of minutes in the time period given.
    date: Returns the total number of minutes from the beginning of the last hour in the Date given.

  • hours
    Read Only
    ms: Returns the total number of hours in the time period given.
    date: Returns the total number of hours from the beginning of the last day in the Date given.

  • days
    Read Only
    ms: Returns the total number of days in the time period given.
    date: Returns the total number of days from the beginning of the last month in the Date given.

  • weekday
    Read Only
    ms: Returns the full name of the weekday that the time period given would fall on, starting from 0 at 00:00 Sunday. date: Returns the full name of the weekday of the Date given.

  • millisecond
    ms: sets or returns the total time in milliseconds.
    date: sets or returns the total milliseconds from the last second in the Date given.

  • second
    ms: sets or returns the total time in seconds.
    date: sets or returns the total seconds from the last minute in the Date given.

  • minute
    ms: sets or returns the total time in mm:ss format.
    date: sets or returns the total time in mm:ss from the last minute in the Date given.

  • hour
    ms: sets or returns the total time in mm:ss format.
    date: sets or returns the total time in mm:ss from the last minute in the Date given.

  • day
    ms: sets or returns the total time in mm:ss format.
    date: sets or returns the total time in mm:ss from the last minute in the Date given.


Methods

add (span: number | string | Date)

Adds the span value to the current SVZDate value.

add.year ( year: number )

add.month( months: number )

add.week( weeks: number )

add.day( days: number )

add.hour( hours: number )

add.minute( minutes: number )

add.second( seconds: number )

Adds the value provided to the current SVZDate value.

millisecondsFrom (inputDate, absolute)

  • inputDate
    Type: Date||Number
    This is the date that is being tested. If it is after this.day, the value returned is positive, and if it is before this.time and absolute is not true, the value returned is negative.

  • absolute
    Type: Boolean
    If set to true, the value returned is a positive number, regardless of whether it is before or after the time given.

secondsFrom (inputDate, absolute)

  • absolute
    Type: Boolean
    If set to true, the value returned is a positive number, regardless of whether it is before or after the time given.

minutesFrom (inputDate, absolute)

  • inputDate
    Type: Date||Number
    This is the date that is being tested. If it is after this.day, the value returned is positive, and if it is before this.time and absolute is not true, the value returned is negative.

  • absolute
    Type: Boolean
    If set to true, the value returned is a positive number, regardless of whether it is before or after the time given.

hoursFrom (inputDate, absolute)

  • inputDate
    Type: Date||Number
    This is the date that is being tested. If it is after this.day, the value returned is positive, and if it is before this.time and absolute is not true, the value returned is negative.

  • absolute
    Type: Boolean
    If set to true, the value returned is a positive number, regardless of whether it is before or after the time given.

daysFrom (inputDate, absolute)

  • inputDate
    Type: Date||Number
    This is the date that is being tested. If it is after this.day, the value returned is positive, and if it is before this.time and absolute is not true, the value returned is negative.

  • absolute
    Type: Boolean
    If set to true, the value returned is a positive number, regardless of whether it is before or after the time given.

yearsFrom (inputDate, absolute)

  • inputDate
    Type: Date||Number
    This is the date that is being tested. If it is after this.day, the value returned is positive, and if it is before this.time and absolute is not true, the value returned is negative.

  • absolute
    Type: Boolean
    If set to true, the value returned is a positive number, regardless of whether it is before or after the time given.

centuriesFrom (inputDate, absolute)

  • inputDate
    Type: Date||Number
    This is the date that is being tested. If it is after this.day, the value returned is positive, and if it is before this.time and absolute is not true, the value returned is negative.

  • absolute
    Type: Boolean
    If set to true, the value returned is a positive number, regardless of whether it is before or after the time given.

milleniaFrom (inputDate, absolute)

  • inputDate
    Type: Date||Number
    This is the date that is being tested. If it is after this.day, the value returned is positive, and if it is before this.time and absolute is not true, the value returned is negative.

  • absolute
    Type: Boolean
    If set to true, the value returned is a positive number, regardless of whether it is before or after the time given.

Author

Version History

1.0.0 - Initial Release.

2.0.0 - Now with typescript, and a while bunch of new features!