[pbs-devel] [PATCH v2 proxmox-backup] prune-simulator: allow setting a custom date/time
Fiona Ebner
f.ebner at proxmox.com
Tue Sep 20 14:10:37 CEST 2022
Am 19.09.22 um 13:13 schrieb Matthias Heiserer:
> @@ -456,9 +461,10 @@ Ext.onReady(function() {
> let weekday = parseInt(Ext.Date.format(daysDate, 'w'), 10);
> if (weekdayFlags[weekday]) {
> timesOnSingleDay.forEach(function(time) {
> - backups.push({
> - backuptime: Ext.Date.subtract(new Date(time), Ext.Date.DAY, i),
> - });
> + const backuptime = Ext.Date.subtract(new Date(time), Ext.Date.DAY, i);
> + if (backuptime < vmDate) {
Should we use '<='? Feels more intuitive to me to include a backup that
happens at the end of the schedule. (Well, one could argue it's more
realistic with '<', because that backup wouldn't be completed in
practice :P)
> + backups.push({ backuptime: backuptime });
> + }
> });
> }
> }
(...)
> + items: [
> + {
> + xtype: 'datefield',
> + name: 'currentDate',
> + fieldLabel: 'Date',
> + allowBlank: false,
> + padding: '0 0 0 10',
Should we use "Y-m-d" format here, like in the backup listing? The
default seems to be "m/d/Y" and that is confusing to many people ;)
> + value: vm.get('now'),
> + listeners: {
> + select: function(_, day) {
While this seems to work as-is, I'd prefer a change listener here too,
see below.
> + const date = me.getViewModel().get('now');
> + date.setFullYear(
> + day.getFullYear(),
> + day.getMonth(),
> + day.getDay(),
getDay() returns the day of the week (0-6), not the day of the month.
getDate() seems to be the correct one, but yeah, it's a confusing name :/
> + );
> + },
> + },
> + },
> + {
> + xtype: 'timefield',
> + name: 'currentTime',
> + reference: 'currentTime',
> + fieldLabel: 'Time',
> + allowBlank: false,
> + padding: '0 0 0 10',
> + format: 'H:i',
> + // cant bind value because ExtJS sets the year
> + // to 2008 to protect against DST issues
> + // and date picker zeroes hour/minute
> + value: vm.get('now'),
> + listeners: {
> + select: function(_, record) {
Using a 'change' listener instead should make manual editing work too.
Currently, manual edits don't seem to update the view model entry.
> + const time = record.get('date');
> + const date = me.getViewModel().get('now');
> + date.setHours(time.getHours());
> + date.setMinutes(time.getMinutes());
> + },
> + },
> + },
> + ],
> },
> ],
> },
More information about the pbs-devel
mailing list