mockdate

WebJar for mockdate

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

mockdate
Последняя версия

Последняя версия

2.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

mockdate
WebJar for mockdate
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/boblauer/MockDate

Скачать mockdate

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/mockdate/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>mockdate</artifactId>
    <version>2.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/mockdate/
implementation 'org.webjars.npm:mockdate:2.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/mockdate/
implementation ("org.webjars.npm:mockdate:2.0.2")
'org.webjars.npm:mockdate:jar:2.0.2'
<dependency org="org.webjars.npm" name="mockdate" rev="2.0.2">
  <artifact name="mockdate" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='mockdate', version='2.0.2')
)
libraryDependencies += "org.webjars.npm" % "mockdate" % "2.0.2"
[org.webjars.npm/mockdate "2.0.2"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

MockDate

A JavaScript Mock Date object that can be used to change when "now" is.

Build Status

Installation

npm install mockdate

Environment Support

MockDate has been tested in Node, IE9+, Chrome, Firefox, and Opera.

Usage

import MockDate from 'mockdate'

API

MockDate.set(date)

date

date: Object

The Date to be returned when no parameters are passed to new Date(). Supports any object that has a .valueOf method that returns a value that can be passed to new Date().

date: String

The string representation of the date which is passed to the new Date() constructor. This creates the Date to be returned when no parameters are passed to new Date().

date: Number

The millisecond representation of the Date to be returned when no parameters are passed to new Date().

MockDate.reset();

Will restore the original Date object back to the native implementation.

Example

MockDate.set('2000-11-22');

new Date().toString() // "Tue Nov 21 2000 18:00:00 GMT-0600 (CST)"

MockDate.set('1/30/2000');

new Date().toString() // "Sun Jan 30 2000 00:00:00 GMT-0600 (CST)"

MockDate.set(new Date('2/20/2000'));

new Date().toString() // "Sun Feb 20 2000 00:00:00 GMT-0600 (CST)"

MockDate.set(moment('3/30/2000').toDate()); // using momentjs

new Date().toString() // "Thu Mar 30 2000 00:00:00 GMT-0600 (CST)"

MockDate.reset();

new Date().toString() // "Mon Mar 17 2014 18:08:44 GMT-0500 (CDT)"

Test

npm test

Версии библиотеки

Версия
2.0.2