-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is not working if leftTime is more than 24 hours #49
Comments
@kalimulhaq Can u provide the |
@cipchk It is setup for 2 days i.e. 48 hours -> 2880 minutes -> 172800 seconds Compared to version 3.2.0 here StackBlitz |
@kalimulhaq @fuzails Yes, this is a problem. In 3.x we are using manual parsing, which is why we need a weird A standard TimeStamp will be converted to So, if you hava Although it is very bad, but I can think of a solution at present. |
Will fork and have a look, it may just be some TZ tinkering required to resolve. |
@cipchk formatDate is a date function so in a date fuction you cannot have more than 24 hours in a day so if the countdown timer is more than 24 hours formatDate will never work as the reality is that you are not trying to format a date at all but a count down. This is the same issue with days, format date will give you the day of the month from the unix epoch i.e. 01 Jan 1970. To fix this you would have to go back to the manual parsing that was done before, come up with a complex interpreter to convert from a date to a countdown. I would recommend going back to the previous implementation used in 3.2.0 and earlier. if you really want to use format date you have to break up the format specified into its parts. AS an example if the format is specified as HH:mm you should get the HH and the mm separately e.g. now if you take 172799 is actually the date Jan 2 1970 23:59:59 as you see this may be already solved previously in version below 8, and so i would recommend going back to that approach. Any reason you moved away from the manual parsing you had previously? |
@fuzails Sorry, forget this issues, i so busy. you can try custom const CountdownTimeUnits: Array<[string, number]> = [
['Y', 1000 * 60 * 60 * 24 * 365], // years
['M', 1000 * 60 * 60 * 24 * 30], // months
['D', 1000 * 60 * 60 * 24], // days
['H', 1000 * 60 * 60], // hours
['m', 1000 * 60], // minutes
['s', 1000], // seconds
['S', 1] // million seconds
];
formatDate?: CountdownFormatFn = ({ date, formatStr, timezone }) => {
let duration = Number(date || 0);
return CountdownTimeUnits.reduce((current, [name, unit]) => {
if (current.indexOf(name) !== -1) {
const v = Math.floor(duration / unit);
duration -= v * unit;
return current.replace(new RegExp(`${name}+`, 'g'), (match: string) => {
return v.toString().padStart(match.length, '0');
});
}
return current;
}, formatStr);
}; |
is there a way to display more than 24hours like in the demo? |
https://stackblitz.com/edit/ngx-countdown-setup-t82gh9 This doesn't work anymore on Angular ang ngx-countdown version 10^ |
This plugin is not working if leftTime is more than 24 hours
e.g.
leftTime: 60000 // 166 Hours
count down is
22:40:00 // which is wrong
The text was updated successfully, but these errors were encountered: