* [pve-devel] [PATCH widget-toolkit] datetimefield: fix changing date to end of month from short months
@ 2024-02-27 13:23 Dominik Csapak
2024-02-27 13:34 ` [pve-devel] applied: [pmg-devel] " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2024-02-27 13:23 UTC (permalink / raw)
To: pve-devel, pmg-devel
When selecting a new date, we get a date object from the currently
selected date before the change. If that month has less days than what
was selected for the new month, `setDate` will wrap that to the
following month since the old month is still selected there.
For example:
select any date in april (has 30 days)
then select the 31th of january
this will actually select the 1st of january since we first get
setDate: 20xx-04-XX -> 20xx-04-31 (wrap) -> 20xx-05-01
setMonth: 20xx-05-01 -> 20xx-01-01
To fix this, use the additional parameters of setFullYear[0] to set
all of them simultaneously
0: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/form/DateTimeField.js | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/form/DateTimeField.js b/src/form/DateTimeField.js
index 4bfa9bd..ea09f8a 100644
--- a/src/form/DateTimeField.js
+++ b/src/form/DateTimeField.js
@@ -24,9 +24,7 @@ Ext.define('Proxmox.DateTimeField', {
return;
}
let datetime = new Date(this.get('datetime'));
- datetime.setDate(date.getDate());
- datetime.setMonth(date.getMonth());
- datetime.setFullYear(date.getFullYear());
+ datetime.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
this.set('datetime', datetime);
},
},
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-27 13:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 13:23 [pve-devel] [PATCH widget-toolkit] datetimefield: fix changing date to end of month from short months Dominik Csapak
2024-02-27 13:34 ` [pve-devel] applied: [pmg-devel] " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox