Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@qc/date-round

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

@qc/date-round

Rounds a date to the nearest interval.

Source
npmnpm
Version
0.0.0-alpha
Version published
Weekly downloads
5
-88.37%
Maintainers
1
Weekly downloads
 
Created
Source

@qc/date-round

Rounds a date to the nearest interval from 0 milliseconds up to 24 hours.

Installation

npm install @qc/date-round

# or
yarn add @qc/date-round

Usage

Nearest Five Minutes

import { round } from '@qc/date-round'

let date = new Date(Date.UTC(2000, 0, 1, 2, 34, 56))
console.log(date) // 2000-01-01T02:34:56
let interval = 5 * 60 * 1000
date = round(date, interval)
console.log(date) // 2000-01-01T02:35:00

Nearest Ten Minutes

import { round } from '@qc/date-round'

let date = new Date(Date.UTC(2000, 0, 1, 2, 34, 56))
console.log(date) // 2000-01-01T02:34:56
let interval = 10 * 60 * 1000
date = round(date, interval)
console.log(date) // 2000-01-01T02:30:00

Nearest 15 Minutes

import { round } from '@qc/date-round'

let date = new Date(Date.UTC(2000, 0, 1, 2, 34, 56))
console.log(date) // 2000-01-01T02:34:56
let interval = 15 * 60 * 1000
date = round(date, interval)
console.log(date) // 2000-01-01T02:30:00

Keywords

closest

FAQs

Package last updated on 04 Nov 2018

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