From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 51EF61FF183 for ; Wed, 17 Dec 2025 11:30:03 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E7C5C253C7; Wed, 17 Dec 2025 11:30:50 +0100 (CET) From: Dominik Csapak To: yew-devel@lists.proxmox.com Date: Wed, 17 Dec 2025 11:30:11 +0100 Message-ID: <20251217103017.1103164-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251217103017.1103164-1-d.csapak@proxmox.com> References: <20251217103017.1103164-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.031 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [self.day] Subject: [yew-devel] [PATCH yew-widget-toolkit 2/2] plain date: add some useful methods X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" these reuse the also new 'to_date' which can be handy if one needs to work with javascript date objects. In the future we should replace that with the equivalent temporal api types. Signed-off-by: Dominik Csapak --- src/widget/form/date_field/plain_date.rs | 29 ++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/widget/form/date_field/plain_date.rs b/src/widget/form/date_field/plain_date.rs index e7d8a97..107c5f9 100644 --- a/src/widget/form/date_field/plain_date.rs +++ b/src/widget/form/date_field/plain_date.rs @@ -27,17 +27,32 @@ impl PlainDate { } } + /// Return a new [`js_sys::Date`] with a time value of 00:00:00. + pub fn to_date(&self) -> Date { + Date::new_with_year_month_day(self.year as u32, self.month as i32, self.day as i32) + } + /// Convert to a timestamp (milliseconds). /// Returns the timestamp for 12:00:00 (Noon) local time on this date. pub fn to_timestamp(&self) -> f64 { - let d = Date::new_0(); - d.set_full_year(self.year as u32); - d.set_month(self.month); - d.set_date(self.day); + let d = self.to_date(); d.set_hours(12); - d.set_minutes(0); - d.set_seconds(0); - d.set_milliseconds(0); + d.get_time() + } + + /// Convert to a timestamp (milliseconds). + /// Returns the timestamp for 00:00:00 local time on this date. + pub fn to_timestamp_start(&self) -> f64 { + self.to_date().get_time() + } + + /// Convert to a timestamp (milliseconds). + /// Returns the timestamp for 23:59:59 local time on this date. + pub fn to_timestamp_end(&self) -> f64 { + let d = self.to_date(); + d.set_hours(23); + d.set_minutes(59); + d.set_seconds(59); d.get_time() } -- 2.47.3 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel