From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.ebner@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 0059693C46
 for <pbs-devel@lists.proxmox.com>; Tue, 20 Sep 2022 14:10:43 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id D16FF1B7D9
 for <pbs-devel@lists.proxmox.com>; Tue, 20 Sep 2022 14:10:43 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS
 for <pbs-devel@lists.proxmox.com>; Tue, 20 Sep 2022 14:10:43 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id BC5CC43BF8
 for <pbs-devel@lists.proxmox.com>; Tue, 20 Sep 2022 14:10:42 +0200 (CEST)
Message-ID: <895444e8-e091-272d-d6c2-355d902a547f@proxmox.com>
Date: Tue, 20 Sep 2022 14:10:37 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.13.0
Content-Language: en-US
To: pbs-devel@lists.proxmox.com, Matthias Heiserer <m.heiserer@proxmox.com>
References: <20220919111347.187510-1-m.heiserer@proxmox.com>
From: Fiona Ebner <f.ebner@proxmox.com>
In-Reply-To: <20220919111347.187510-1-m.heiserer@proxmox.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 1.129 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -2.182 Looks like a legit reply (A)
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup] prune-simulator: allow
 setting a custom date/time
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Tue, 20 Sep 2022 12:10:44 -0000

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());
> +						},
> +					    },
> +					},
> +				    ],
>  				},
>  			    ],
>  			},