From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Denis 'GNUtoo' Carikli Newsgroups: gmane.lisp.guile.devel Subject: [PATCH v1] SRFI-19: Add support for ISO 8601 zones with a colon. Date: Thu, 29 Feb 2024 22:23:43 +0100 Message-ID: <20240229212343.10442-1-GNUtoo@cyberdimension.org> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25370"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Denis 'GNUtoo' Carikli To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Feb 29 23:45:00 2024 Return-path: Envelope-to: guile-devel@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 1rfp9A-0006Pi-OU for guile-devel@m.gmane-mx.org; Thu, 29 Feb 2024 23:45:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfp8Y-0004Gj-Tv; Thu, 29 Feb 2024 17:44:22 -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 1rfnsm-0002jX-Bv for guile-devel@gnu.org; Thu, 29 Feb 2024 16:24:00 -0500 Original-Received: from cyberdimension.org ([80.67.179.20] helo=gnutoo.cyberdimension.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfnsk-0002AI-K8 for guile-devel@gnu.org; Thu, 29 Feb 2024 16:24:00 -0500 Original-Received: from gnutoo.cyberdimension.org (localhost [127.0.0.1]) by cyberdimension.org (OpenSMTPD) with ESMTP id 6fa77835; Thu, 29 Feb 2024 21:23:55 +0000 (UTC) Original-Received: from localhost.localdomain (localhost [::1]) by gnutoo.cyberdimension.org (OpenSMTPD) with ESMTP id 45538c81; Thu, 29 Feb 2024 21:23:54 +0000 (UTC) X-Mailer: git-send-email 2.41.0 Received-SPF: pass client-ip=80.67.179.20; envelope-from=GNUtoo@cyberdimension.org; helo=gnutoo.cyberdimension.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 29 Feb 2024 17:44:21 -0500 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22330 Archived-At: * module/srfi/srfi-19.scm (zone-reader): handle a colon in the zone. * test-suite/tests/srfi-19.test (SRFI date/time library test): Add test. Signed-off-by: Denis 'GNUtoo' Carikli --- module/srfi/srfi-19.scm | 5 +++++ test-suite/tests/srfi-19.test | 3 +++ 2 files changed, 8 insertions(+) diff --git a/module/srfi/srfi-19.scm b/module/srfi/srfi-19.scm index 570f933ca..23d115926 100644 --- a/module/srfi/srfi-19.scm +++ b/module/srfi/srfi-19.scm @@ -1271,6 +1271,11 @@ (if (eof-object? ch) (time-error 'string->date 'bad-date-template-string (list "Invalid time zone number" ch))) + (if (char=? ch #\:) + (set! ch (read-char port)) + (if (eof-object? ch) + (time-error 'string->date 'bad-date-template-string + (list "Invalid time zone number" ch)))) (set! offset (+ offset (* (char->int ch) 10 60)))) (let ((ch (read-char port))) diff --git a/test-suite/tests/srfi-19.test b/test-suite/tests/srfi-19.test index 1d56214e4..55eb82320 100644 --- a/test-suite/tests/srfi-19.test +++ b/test-suite/tests/srfi-19.test @@ -120,6 +120,9 @@ incomplete numerical tower implementation.)" (pass-if "string->date works" (begin (string->date "2001-06-01@14:00" "~Y-~m-~d@~H:~M") #t)) + (pass-if "string->date accepts ISO 8601 zones with a colon" + (begin (string->date "2024-12-31T23:59:59+01:00" "~Y-~m-~dT~H:~M:~S~z") + #t)) ;; check for code paths where reals were passed to quotient, which ;; doesn't work in Guile (and is unspecified in R5RS) (test-time->date time-utc->date date->time-utc) base-commit: 9e0f03c5fd36764827c8bb03887f14640c883b70 -- 2.41.0