From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Richard Lawrence Newsgroups: gmane.emacs.bugs Subject: bug#74869: [PATCH] Add predicates for decoded times and time deltas Date: Sun, 05 Jan 2025 09:45:10 +0100 Message-ID: <878qrp8x9l.fsf@recursewithless.net> References: <87zfkeud74.fsf@recursewithless.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22215"; mail-complaints-to="usenet@ciao.gmane.io" To: 74869@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 05 09:46:19 2025 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tUMH3-0005cs-UF for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Jan 2025 09:46:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUMGq-0008BV-2V; Sun, 05 Jan 2025 03:46:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tUMGp-0008BL-0v for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2025 03:46:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tUMGo-0008KN-HB for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2025 03:46:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:From:To:In-Reply-To:Subject; bh=SxaweHZBPl3DqSSJehxpANLk0Gj/5HfBVxto3GNXy6Y=; b=U5dnKUvi/oPdCZtGKYc5OHHmfQ7THIwmw9ezwJuqc8zijYSbQh82Y1nFWon5U6gmMwBwMVdT+aG1jZGMFyQuZ0KE+5b7fJNvOftD4JmAx5SQA7euDHVw65TdU+UtmM/g3IcENl3YJDXTIu3qtfUZ+dT4vKj5LBOsnE06wzgG5BpQ0QMy08Cc0y6VzXAfvSGWk7UQUQeO8aAhOpHVkrMXX3eTLjt5glUbo2xU4LO0dgeLzuQo08YcQLRmBArTsUFqffLPNqKzjxBcggZUqh1xKWiUiY3Z0twWDcJpUYw+SHjNpvMXafaw1BaaX+VhSw7Jaayk+WwVREZC/Kd4g/vSKg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tUMGo-00052O-C8 for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2025 03:46:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <8734iqp7lu.fsf@recursewithless.net> Resent-From: Richard Lawrence Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Jan 2025 08:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74869 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74869-submit@debbugs.gnu.org id=B74869.173606672919319 (code B ref 74869); Sun, 05 Jan 2025 08:46:02 +0000 Original-Received: (at 74869) by debbugs.gnu.org; 5 Jan 2025 08:45:29 +0000 Original-Received: from localhost ([127.0.0.1]:59796 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tUMGG-00051X-KV for submit@debbugs.gnu.org; Sun, 05 Jan 2025 03:45:29 -0500 Original-Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]:53039) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tUMGD-00051D-Cz for 74869@debbugs.gnu.org; Sun, 05 Jan 2025 03:45:26 -0500 Original-Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id AE9E01140137 for <74869@debbugs.gnu.org>; Sun, 5 Jan 2025 03:45:19 -0500 (EST) Original-Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Sun, 05 Jan 2025 03:45:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= recursewithless.net; h=cc:content-type:content-type:date:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1736066719; x= 1736153119; bh=SxaweHZBPl3DqSSJehxpANLk0Gj/5HfBVxto3GNXy6Y=; b=n r4XJGcJpPtxilQG7Xb2C7q2YvJ8dCxI7Zrs3W3DHoJAjNHrGs86vh/li/xZSii0b k6DeCKELv1BrermWIsZYTYwTV9CoIXeG9Uvx0fCjQDCXMq+bmWhVp8tlItBELsy4 oPL0svwXE+R/GfcfWvv+LEoWrJ4aHXz0+NOVY8GFBMNCQlXhk0ApzEc/80TRZWDT DkXsnfkY+X+w1kwVDMC0RyYW1Qg+maESqQyfbK/3vrXvJis8Ge0PYBe9bJSN0HMJ jmktLl22mWqpJAJGHfZN9O6I7ChCpMDHAVc1WYdCqxDPMg0bfVEaHFyUUZpapwid +AIRb8sUJZ45PJqv3haTg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1736066719; x=1736153119; bh=SxaweHZBPl3DqSSJehxpANLk0Gj/5HfBVxt o3GNXy6Y=; b=gZthcPgfID6b6qYmzR149JigiB8LbSS4d8PjziMpu54v4bNHuF4 Ps6kXzLzRKs9Mnae3353NzTFfbndWQazywORnNujDl/MiEclUHLFAuvKz6EsF1oq XXowMwEdi0lHwgHXvTH8vg/NPsG0eBC95ZUp7/gyLyVzMD8z1b/F3B6xYzxT6QvP PBp3OjtpMoy5WGOmcDE/YoXIMR5sUQEfHSRhFpws2OSmaQSLphAjdbAcqawJLvoY u2CKl7JFTnjd1AgqwWaiv7fGlo8EPu07Kifvnsev1H/ZkFVE8gSvm3vtNQqkc5Yr R5XmIBr2ETip6FjfYhTNO3FKcoiSJOXc2rw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudefjedguddvhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvuf hffffkgggtsehttdertddttddtnecuhfhrohhmpeftihgthhgrrhguucfnrgifrhgvnhgt vgcuoehrfihlsehrvggtuhhrshgvfihithhhlhgvshhsrdhnvghtqeenucggtffrrghtth gvrhhnpedvvefgtdetudejkeegjeelhfdvteegjedvheehueffheetkeejuedtuddukeej keenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrfi hlsehrvggtuhhrshgvfihithhhlhgvshhsrdhnvghtpdhnsggprhgtphhtthhopedupdhm ohguvgepshhmthhpohhuthdprhgtphhtthhopeejgeekieelseguvggssghughhsrdhgnh hurdhorhhg X-ME-Proxy: Feedback-ID: if7394488:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA for <74869@debbugs.gnu.org>; Sun, 5 Jan 2025 03:45:18 -0500 (EST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:298519 Archived-At: I'm also forwarding a mis-addressed email back to the relevant bug list -------------------- Start of forwarded message -------------------- From: Richard Lawrence To: Paul Eggert Subject: Re: [PATCH] Add predicates for decoded times and time deltas Date: Sun, 29 Dec 2024 09:05:03 +0100 Paul Eggert writes: > On 12/28/24 07:56, Richard Lawrence wrote: >> I need to use >> `calendar-extract-month' with a plain date value, but >> `decoded-time-month' with a date-time value. I need type predicates to >> do such dispatching. > > Not necessarily; you can instead try each function in turn and use the > first that works. Well, in this case, they'll both "work" but can return incorrect values: `calendar-extract-month' is just implemented as `car', so if I call it on a decoded time, I'll get the seconds slot value rather than the month slot value. Similarly, `decoded-time-second' will return the month if called on a calendar date. If both calendar dates and decoded times were implemented as records/cl-structs, rather than plain lists, then these accessor functions could signal an error if passed a value of the wrong type. But they aren't, and that doesn't seem likely to change anytime soon, so having a predicate seems important. > I have some qualms about saying that decoded times are a "type". Whether > a decoded time is valid depends on the timezone: (0 30 2 10 3 2024 0 t > -21600) is a valid decoded time in Phoenix but not in Denver, because > clocks sprang forward over that time in Denver but not in Phoenix. When > data interpretation gets that complicated, the Emacs notion of "type" is > not always the best. I see. Would it help to change the name, or add some documentation, to make it clear that the predicate doesn't (can't?) test for cases like this? What about calling it something like `decoded-time-like-p' or `maybe-decoded-time-p'? The iCalendar standard sets clear limits on the slot values, but these aren't fine grained enough to rule out cases like the one you gave. All it says is basically: a date-time consists of a year, month, month-day, hour, minute, second, and (possibly) a UTC offset a year is a four digit (positive) integer a month is in the range 1-12 a month-day is in the range 1-28, 1-29, 1-30, or 1-31, depending on the month and year an hour is in the range 0-23 a minute is in the range 0-59 a second is in the range 0-60 (60 represents a leap second) a UTC offset is a sign together with an hour, minute, and second, where the second cannot be 60 So that's what the iCalendar code needs to check for. If it would be better to keep this predicate in the iCalendar code, I can certainly do that. I thought it would be more generally useful and should therefore go with the existing code for decoded times, but maybe I was wrong about that. Best, Richard -------------------- End of forwarded message --------------------