From 47fc082fb96a187a40413f2dd9df5757abd6b566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=C3=B4=20Ng=E1=BB=8Dc=20=C4=90=E1=BB=A9c=20Huy?= Date: Fri, 24 Mar 2023 20:44:29 +0700 Subject: [PATCH] Fix floating point error for poll expiry Previous code multiply with 0.001 before multiplication which leads to a floating point error. By changing it to division by 1000 after multiplication this is avoided. --- src/components/poll/poll_form.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/poll/poll_form.js b/src/components/poll/poll_form.js index e30645c3..89f01eb4 100644 --- a/src/components/poll/poll_form.js +++ b/src/components/poll/poll_form.js @@ -103,9 +103,9 @@ export default { convertExpiryFromUnit (unit, amount) { // Note: we want seconds and not milliseconds switch (unit) { - case 'minutes': return 0.001 * amount * DateUtils.MINUTE - case 'hours': return 0.001 * amount * DateUtils.HOUR - case 'days': return 0.001 * amount * DateUtils.DAY + case 'minutes': return amount * DateUtils.MINUTE / 1000 + case 'hours': return amount * DateUtils.HOUR / 1000 + case 'days': return amount * DateUtils.DAY / 1000 } }, expiryAmountChange () {