unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob b03c0265727f5035666755f94c5b04dd65528009 4308 bytes (raw)
name: test/corpora/threading/thread-fusing/cur/1397885606.000232.mbox:2,S 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
 
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on shi.workgroup
Delivery-date: Fri, 11 Mar 2011 00:08:47 +0100
Delivered-To: GMX delivery to telegraph@gmx.net
To: Eric S Fraga <e.fraga@ucl.ac.uk>
From: Nick Dokos <nicholas.dokos@hp.com>
Subject: Re: [O] dates before 1970
In-Reply-To: Message from Eric S Fraga <e.fraga@ucl.ac.uk> 	of "Thu, 10 Mar 2011 21:00:16 GMT." <87ei6en127.fsf@ucl.ac.uk>
References: <87ei6en127.fsf@ucl.ac.uk>
X-Mailer: MH-E 8.2; nmh 1.3; GNU Emacs 24.0.50
Date: Thu, 10 Mar 2011 18:06:33 -0500
Message-ID: <5422.1299798393@alphaville.usa.hp.com>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 	4)
X-Received-From: 15.201.24.20
Cc: nicholas.dokos@hp.com, Emacs Org mode mailing list <emacs-orgmode@gnu.org>
X-BeenThere: emacs-orgmode@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: nicholas.dokos@hp.com
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/emacs-orgmode>, 	<mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/emacs-orgmode>, 	<mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+telegraph=gmx.net@gnu.org
X-GMX-Antivirus: 0 (no virus found)
X-GMX-Antispam: 0 (Mail was not recognized as spam);  Detail=5D7Q89H36p4U4jfdfC5HDevlx1X2sAZgAaLl3DbFfW0PXxL7WgvovMFXXSEPrACW/b9IW  Qp+GhEViZlUW4mdBntgP1X8KwB5tjHCA/yxSZMYzm4ZTjPJ5/Fr7D0QgNt/3lmuFSuOJGxtBQaM0  OMz0Q==V1;
Status: O
Content-Length: 2565
Lines: 73

Content-Length: 2543

Eric S Fraga <e.fraga@ucl.ac.uk> wrote:

> This is a sort of bug report but possibly more a curiosity...
> 
> I imagine this has something to do with time 0 in Unix but I cannot seem
> to be able to enter any date earlier than 1 Jan 1970 using C-c! (say).
> However, once I have entered a date (later than that), I can use
> S-<down> on the year to get to the date I want.  This seems rather
> inconsistent?
> 
> To be precise, I get the wrong date recorded if I try:
> 
>   C-c ! 1968-12-10 RET
> 
> (where C-c ! is =org-time-stamp-inactive=).
> The result is =[2011-12-10 Sat]=
> 
> The bug is not so much that I cannot input dates I want but that the
> inactive timestamp generated is *incorrect* and yet there is no error
> message.
> 

Good one! The culprit is org-read-date-analyze which near the end contains
this snippet of code:

,----
|     ...
|     (if (< year 100) (setq year (+ 2000 year)))
|     (if (< year 1970) (setq year (nth 5 defdecode))) ; not representable
|     (setq org-read-date-analyze-futurep futurep)
|     (list second minute hour day month year)))
`----

The trouble is that the caller (org-read-date) takes the result and
does a round-trip through the emacs time encode/decode functions to make
sure the result is sane. Dates before 1970 would break that (I get (0 9
10 26 11 2033 6 nil -18000)) so it seems it wraps around to 2033 or so).

In addition, most callers of org-read-date call it with a non-nil
to-time argument: that makes it return an emacs-encoded time (which is
then manipulated as such and which I believe has to satisfy the >=1970
requirement).

So I'd guess raising an exception might be the simplest way to deal with
this. Here's a patch to try out:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org.el b/lisp/org.el
index 92f2406..b9acf11 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14718,7 +14718,8 @@ user."
 	     (nth 2 tl))
 	(setq org-time-was-given t))
     (if (< year 100) (setq year (+ 2000 year)))
-    (if (< year 1970) (setq year (nth 5 defdecode))) ; not representable
+;    (if (< year 1970) (setq year (nth 5 defdecode))) ; not representable
+    (if (< year 1970) (error "Year must be >= 1970"))
     (setq org-read-date-analyze-futurep futurep)
     (list second minute hour day month year)))
--8<---------------cut here---------------end--------------->8---

I think it does not break anything but I'm not sure I like it much.

Patchwork note: this should not be applied without a lot more thought
and experimentation.

Nick





debug log:

solving b03c0265 ...
found b03c0265 in https://yhetil.org/notmuch/20211226161716.2079457-1-david@tethera.net/

applying [1/1] https://yhetil.org/notmuch/20211226161716.2079457-1-david@tethera.net/
diff --git a/test/corpora/threading/thread-fusing/cur/1397885606.000232.mbox:2,S b/test/corpora/threading/thread-fusing/cur/1397885606.000232.mbox:2,S
new file mode 100644
index 00000000..b03c0265

1:43: trailing whitespace.
> 
1:49: trailing whitespace.
> 
1:51: trailing whitespace.
> 
1:53: trailing whitespace.
> 
1:56: trailing whitespace.
> 
Checking patch test/corpora/threading/thread-fusing/cur/1397885606.000232.mbox:2,S...
Applied patch test/corpora/threading/thread-fusing/cur/1397885606.000232.mbox:2,S cleanly.
warning: squelched 4 whitespace errors
warning: 9 lines add whitespace errors.

index at:
100644 b03c0265727f5035666755f94c5b04dd65528009	test/corpora/threading/thread-fusing/cur/1397885606.000232.mbox:2,S

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).