Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@t0ri/dates

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@t0ri/dates

![Travis (.com)](https://img.shields.io/travis/com/t0ri/dates?style=flat-square) ![Coveralls github](https://img.shields.io/coveralls/github/t0ri/dates?style=flat-square) ![GitHub repo size](https://img.shields.io/github/repo-size/t0ri/dates?style=flat-sq

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Deights Library

Travis (.com) Coveralls github GitHub repo size

Create a Deight

Create a new Deight similar to creating a Date.

const date = new Deight('2/19/1998')
date.date -> 1998-02-19T08:00:00.000Z

Get Deight Values

Year

const date = new Deight('2/19/1998')
date.year -> 1998

Month

const date = new Deight('2/19/1998')
date.month -> 'February'

Day

const date = new Deight('2/19/1998')
date.month -> 'February'

Hours

const date = new Deight('2/19/1998 13:15:30')
date.hours -> 13

Minutes

const date = new Deight('2/19/1998 13:15:30')
date.minutes -> 15

Seconds

const date = new Deight('2/19/1998 13:15:30')
date.seconds -> 30

Format Mask

Deight objects can return their date and time formatted with many options.

const date = new Deight('2/19/1998 13:15:30')
date.format('M d, Y') -> 'February 19, 1998'

Format Key

'Y' -> 2019

'y' -> 19

'M' -> July

'm' -> Jul

'D' -> 01

'd' -> 1

'H' -> 05

'h' -> 5

'I' -> 08

'i' -> 8

'S' -> 04

's' -> 4

When

Deight's when() method will return how many days, months, or years ago or until a given date.

const date = new Deight('2/19/1998 13:15:30')
date.when('2/22/1998') -> '3 days from now'
date.when('2/22/1997') -> '1 year ago'

FAQs

Package last updated on 05 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc