@js-random/date
TypeScript icon, indicating that this package has built-in type declarations

0.3.5 • Public • Published

@js-random/date

A simple and lightweight date randomizer for JavaScript (TypeScript friendly)

Installation

npm i -S @js-random/date

Usage

commonjs:

var randomDate = require('@js-random/date').default;

TS/ES6+:

import randomDate from '@js-random/date';

<script> tag:

<script src="https://unpkg.com/@js-random/date"></script>
var date = randomDate(); // A random date, basically
var from2010To2012 = randomDate({ from: new Date(2010, 1, 1), to: new Date(2010, 1, 1) }); // random date from Jan 1 2010 to Jan 1 2012

Global version

This package also has a global version, which introduces side-effects by exposing the api as Date.random() function.

Import

commonjs:

require('@js-random/date/lib/global');

ES6+:

import '@js-random/date/module/global';

TS:

import '@js-random/date/module/global';

<script> tag

<script src="https://unpkg.com/@js-random/date/unpkg/global"></script>

Usage

var date = Date.random(); // A random date, basically
var from2010To2012 = Date.random({ from: new Date(2010, 1, 1), to: new Date(2010, 1, 1) }); // random date from Jan 1 2010 to Jan 1 2012

Other packages

Please, have a look at other packages from @js-random series:

Package Sidebar

Install

npm i @js-random/date

Weekly Downloads

13

Version

0.3.5

License

MIT

Unpacked Size

11.4 kB

Total Files

21

Last publish

Collaborators

  • raiondesu