Skip to content

Commit

Permalink
reset time when first arg is null or undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
dherault committed Jan 17, 2017
1 parent 5cacd8b commit 76b995a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.0.1

**Bug fixes:**
- Allow to reset time when first argument is `null` or `undefined`.

## 0.0.0

First release! :tada:
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "timeshift",
"version": "0.0.0",
"version": "0.0.1",
"description": "Time shifting in JavaScript",
"author": "David Hérault <dherault@nelson.ai> (https://github.com/dherault)",
"license": "SEE LICENSE IN LICENSE",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const OriginalDate = Date;

function timeshift(...args) {

if (!args.length) return Date = OriginalDate;
if (!args.length || args[0] === null || typeof args[0] === 'undefined') return Date = OriginalDate;

const diff = OriginalDate.now() - new OriginalDate(...args).getTime();

Expand Down

0 comments on commit 76b995a

Please sign in to comment.