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

date-grab

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-grab

Functional wrapper for getting date properties

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Date Grab

Date grab provides a thin functional wrapper for getting Date object properties.

Useage

var grab = require('date-grab');
var countdown = new Date('July 1, 2015');

var year = grab('year')
  // year(countdown) === 2015

var date = grab('date')
  // date('December 22, 2015') === 22 

var utcHours = grab('hours', { utc: true })
  // utcHours(countdown) === 7(PST)

var monthYear = grab(['month', 'year'])
  // monthYear(countdown) === { month: 6, year: 2015 }

grab(property, options)

Date grab creates a function that gets date property, wraps standard Date object functions. property should be a String or String Array and config should be an Object.

More thorough documentation on Dates can be found at MDN, but here is a basic conversion chart.

grabdate
grab('time')(date)date.getTime()
grab('timezone')(date)date.getTimezoneOffset()
grab('year')(date)date.getYear()
grab('month')(date)date.getMonth()
grab('date')(date)date.getDate()
grab('day')(date)date.getDay()
grab('hours')(date)date.getHours()
grab('minutes')(date)date.getMinutes()
grab('seconds')(date)date.getSeconds()
grab('milliseconds')(date)date.getMilliseconds()

options

utc

Setting utc to true will use UTC instead of local date functions.

var now = new Date()
var utcHours = grab('hours', { utc: true })

utcHours(now) === now.getUTCHours() // true

Keywords

FAQs

Package last updated on 04 Jun 2015

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