vydimitrov / react-countdown-circle-timer

Lightweight React/React Native countdown timer component with color and progress animation based on SVG
MIT License
692 stars 87 forks source link

On Ios the counter remainingTime becames NaN #231

Closed simoneagostinelli closed 1 year ago

simoneagostinelli commented 1 year ago

Hi, i'm using the counter on my webapp, when the counter is rendered on a mobile ios device the counter callback with remainingTime becames NaN as you can see on my screen.

image

here is my code

image

the parseTime function is this:

const parseTime = (props) => {
    console.log('props', props);
    const hours = minTwoDigits(Math.floor(props.remainingTime / 3600));
    const minutes = minTwoDigits(Math.floor((props.remainingTime % 3600) / 60));
    const seconds = minTwoDigits(props.remainingTime % 60);
}

and the browser logs is below

image

I'm able to reproduce the issue also with chrome inspector as an ios device

vydimitrov commented 1 year ago

Hey @simoneagostinelli, is it possible because the duration prop is set to null. It is required prop by the way.

simoneagostinelli commented 1 year ago

Hi @vydimitrov that is not my case, because the duration is setted with the totalTime and as you can see in the logs totalTime is valorized, the case in which the duration is null was different, in that case i'm not showing the numbers so I have no problems. plus, if what you said was true, the timer will be NaN always, not only with an ios device

vydimitrov commented 1 year ago

I see, it would be nice to get it reproduce somewhere so I can take a look on what goes wrong there.

simoneagostinelli commented 1 year ago

Sorry for the late response, during this WE i will try to replicate on a codesandbox and i will provide it to you

vydimitrov commented 1 year ago

Closing due to inactivity.

daygarcia commented 8 months ago

I'm having the same issue here. On IOS, always enter the else (for example 5699). And just in case, if I remove the or statement, it becomes NaN

image

image

daygarcia commented 8 months ago

After some tests, i discovered the problem.

IOS, for some reason, dont accept the date format that I was using: "03/08/2024 : 23:59:00" mm/dd/yyyy : hh:mm:ss

All I had to do was convert this date to a valid ISO string, just like that: "2024-03-08T23:59:00"

And everything works fine now.

image