react-live-clock
Advanced tools
Comparing version 5.4.2 to 5.5.0
# Changelog | ||
## [5.5.0] | ||
Adds suport back for custom Date in the past or future that ticks | ||
## [5.4.2] | ||
@@ -4,0 +7,0 @@ Bump react-router-dom from 5.3.0 to 6.2.1 #141 |
{ | ||
"name": "react-live-clock", | ||
"version": "5.4.2", | ||
"version": "5.5.0", | ||
"description": "React Live Clock", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -21,3 +21,6 @@ import React, {useState, useEffect} from 'react'; | ||
} = props; | ||
const [currentTime, setCurrentTime] = useState(Date.now()); | ||
const [startTime, setStartTime] = useState(Date.now()); | ||
const [currentTime, setCurrentTime] = useState(date ? new Date(date).getTime() : Date.now()); | ||
const [formatToUse, setFormatToUse] = useState(format); | ||
@@ -46,4 +49,10 @@ let colonOn = true; | ||
const tick = setInterval(() => { | ||
const now = Date.now(); | ||
let now = Date.now(); | ||
if (date) { | ||
const difference = Date.now() - startTime; | ||
now = new Date(date).getTime() + difference; | ||
} | ||
if (blinking) { | ||
@@ -83,3 +92,3 @@ if (colonOn) { | ||
className={className} | ||
date={date} | ||
date={ticking ? '' : date} | ||
filter={filter} | ||
@@ -86,0 +95,0 @@ format={formatToUse} |
@@ -135,3 +135,3 @@ import React from 'react'; | ||
{/* <Panel | ||
<Panel | ||
code={` | ||
@@ -150,5 +150,23 @@ <Clock | ||
timezone={'Australia/Sydney'} /> | ||
</Panel> */} | ||
</Panel> | ||
<Panel | ||
code={` | ||
<Clock | ||
date={'2222-12-31T14:15:23+01:00'} | ||
format={'dddd, MMMM Do, YYYY, h:mm:ss A'} | ||
ticking={true} | ||
timezone={'Australia/Sydney'} /> | ||
`} | ||
title="Date in the future that ticking"> | ||
<Clock | ||
date={'2222-12-31T14:15:23+01:00'} | ||
format={'dddd, MMMM Do, YYYY, h:mm:ss A'} | ||
ticking={true} | ||
timezone={'Australia/Sydney'} /> | ||
</Panel> | ||
<Panel | ||
code="<Clock filter={date => date.replace('8', '7a')} format={'HH:mm:ss'} ticking={true} />" | ||
@@ -155,0 +173,0 @@ title="Filter the value before output."> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8101443
81548