From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: dates before 1970 Date: Sun, 13 Mar 2011 08:39:13 +0100 Message-ID: References: <87ei6en127.fsf@ucl.ac.uk> <5422.1299798393@alphaville.usa.hp.com> <87hbbaoy6l.fsf@gnu.org> Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: multipart/mixed; boundary=Apple-Mail-4--427793604 Return-path: Received: from [140.186.70.92] (port=46882 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PyftX-0005IK-PA for emacs-orgmode@gnu.org; Sun, 13 Mar 2011 03:39:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PyftW-0005ue-CM for emacs-orgmode@gnu.org; Sun, 13 Mar 2011 03:39:19 -0400 Received: from mail-ew0-f41.google.com ([209.85.215.41]:64705) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PyftW-0005tR-2q for emacs-orgmode@gnu.org; Sun, 13 Mar 2011 03:39:18 -0400 Received: by ewy9 with SMTP id 9so1353899ewy.0 for ; Sat, 12 Mar 2011 23:39:16 -0800 (PST) In-Reply-To: <87hbbaoy6l.fsf@gnu.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Guerry Cc: Eric S Fraga , Emacs Org mode mailing list , "nicholas.dokos@hp.com Dokos" --Apple-Mail-4--427793604 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Hi everyone, On 11.3.2011, at 09:31, Bastien wrote: > Hi, > > Nick Dokos writes: > >> So I'd guess raising an exception might be the simplest way to deal with >> this. Here's a patch to try out: > > This patch has side-effects that Carsten have been recently exploring a > bit. Those side-effects seem to depend on how Emacs has been compiled. > > For now it's best to stick to this restriction. I am attaching a patch which tries to implement some kind of a solution for this problem. The patch introduces a new variable which will allow you to use dates outside the safe range 1970-2037 once you have convinced yourself that all Emacs implementation you are likely to use now and in the future will support the extended range. To be clear, I do not recommend to make use of this, the danger that you will find yourself on a system where this issue is not resolved is not negligible. That is also why I would recommend the default `t' for this variable, and why I will continue to use diary-sexp dates for the few dates where I need a greater range. The patch also introduces a warning with a beep when Org has forced the year, which, I think, was really the main concern in this thread. Here is the docstring of the new variable - it explains what is going on. (defcustom org-read-date-force-compatible-dates t "Should date/time prompt force dates that are guaranteed to work in Emacs? Depending on the system Emacs is running on, certain dates cannot be represented with the type used internally to represent time. Dates between 1970-1-1 and 2038-1-1 can always be represented correctly. Some systems allow for earlier dates, some for later, some for both. One way to find out it to insert any date into an Org buffer, putting the cursor on the year and hitting S-up and S-down to test the range. When this variable is set to t, the date/time prompt will not let you specify dates outside the 1970-2037 range, so it is certain that these dates will work in whatever version of Emacs you are running, and also that you can move a file from one Emacs implementation to another. WHenever Org is forcing the year for you, it will display a message and beep. When this variable is nil, Org will check if the date is representable in the specific Emacs implementation you are using. If not, it will force a year, usually the current year, and beep to remind you. Currently this setting is not recommended because the likelihood that you will open your Org files in an Emacs that has limited date range is not negligible. A workaround for this problem is to use diary sexp dates for time stamps outside of this range." :group 'org-time :type 'boolean) --Apple-Mail-4--427793604 Content-Disposition: attachment; filename=0001-Improve-handling-of-years-with-limitations-on-repres.patch Content-Type: application/octet-stream; name="0001-Improve-handling-of-years-with-limitations-on-repres.patch" Content-Transfer-Encoding: quoted-printable =46rom=20138615942fe12b40f8fbb1de5ead5ae5960032f3=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Carsten=20Dominik=20= =0ADate:=20Sun,=2013=20Mar=202011=2008:06:22=20= +0100=0ASubject:=20[PATCH]=20Improve=20handling=20of=20years=20with=20= limitations=20on=20representable=20dates=0A=0A*=20lisp/org.el=20= (org-read-date-force-compatible-dates):=20New=20option.=0A= (org-read-date,=20org-read-date-analyze):=20Check=20representable=20date=20= range.=0A*=20doc/org.texi=20(The=20date/time=20prompt):=20Document=20= date=20range=20protection.=0A=0ANew=20variable=20= `org-read-date-force-compatible-dates'=20to=20control=0Ahandling=20of=20= dates.=0A---=0A=20doc/org.texi=20|=20=20=2012=20++++++++++--=0A=20= lisp/org.el=20=20|=20=20=2054=20= ++++++++++++++++++++++++++++++++++++++++++++++++++++--=0A=202=20files=20= changed,=2062=20insertions(+),=204=20deletions(-)=0A=0Adiff=20--git=20= a/doc/org.texi=20b/doc/org.texi=0Aindex=20e13af4b..dd6d945=20100644=0A= ---=20a/doc/org.texi=0A+++=20b/doc/org.texi=0A@@=20-5394,9=20+5394,17=20= @@=20The=20function=20understands=20English=20month=20and=20weekday=20= abbreviations.=20=20If=0A=20you=20want=20to=20use=20unabbreviated=20= names=20and/or=20other=20languages,=20configure=0A=20the=20variables=20= @code{parse-time-months}=20and=20@code{parse-time-weekdays}.=0A=20=0A= +@vindex=20org-read-date-force-compatible-dates=0A+Not=20all=20dates=20= can=20be=20represented=20in=20a=20given=20Emacs=20implementation.=20=20= By=20default=0A+Org=20mode=20forces=20dates=20into=20the=20compatibility=20= range=201970--2037=20which=20works=20on=0A+all=20Emacs=20= implementations.=20=20If=20you=20want=20to=20use=20dates=20outside=20of=20= this=20range,=0A+read=20the=20docstring=20of=20the=20variable=0A= +@code{org-read-date-force-compatible-dates}.=0A+=0A=20You=20can=20= specify=20a=20time=20range=20by=20giving=20start=20and=20end=20times=20= or=20by=20giving=20a=0A-start=20time=20and=20a=20duration=20(in=20HH:MM=20= format).=20Use=20`-'=20or=20`-@{@}-'=20as=20the=20separator=0A-in=20the=20= former=20case=20and=20use=20'+'=20as=20the=20separator=20in=20the=20= latter=20case.=20E.g.@:=0A+start=20time=20and=20a=20duration=20(in=20= HH:MM=20format).=20Use=20`-'=20or=20`-@{@}-'=20as=20the=0A+separator=20= in=20the=20former=20case=20and=20use=20'+'=20as=20the=20separator=20in=20= the=20latter=0A+case.=20E.g.@:=0A=20=0A=20@example=0A=2011am-1:15pm=20=20= =20=20@result{}=2011:00-13:15=0Adiff=20--git=20a/lisp/org.el=20= b/lisp/org.el=0Aindex=2096ad8ff..a145de6=20100644=0A---=20a/lisp/org.el=0A= +++=20b/lisp/org.el=0A@@=20-2651,6=20+2651,36=20@@=20This=20may=20t=20or=20= nil,=20or=20the=20symbol=20`org-read-date-prefer-future'."=0A=20=09=20=20= (const=20:tag=20"Never"=20nil)=0A=20=09=20=20(const=20:tag=20"Always"=20= t)))=0A=20=0A+(defcustom=20org-read-date-force-compatible-dates=20t=0A+=20= =20"Should=20date/time=20prompt=20force=20dates=20that=20are=20= guaranteed=20to=20work=20in=20Emacs?=0A+=0A+Depending=20on=20the=20= system=20Emacs=20is=20running=20on,=20certain=20dates=20cannot=0A+be=20= represented=20with=20the=20type=20used=20internally=20to=20represent=20= time.=0A+Dates=20between=201970-1-1=20and=202038-1-1=20can=20always=20be=20= represented=0A+correctly.=20=20Some=20systems=20allow=20for=20earlier=20= dates,=20some=20for=20later,=0A+some=20for=20both.=20=20One=20way=20to=20= find=20out=20it=20to=20insert=20any=20date=20into=20an=0A+Org=20buffer,=20= putting=20the=20cursor=20on=20the=20year=20and=20hitting=20S-up=20and=0A= +S-down=20to=20test=20the=20range.=0A+=0A+When=20this=20variable=20is=20= set=20to=20t,=20the=20date/time=20prompt=20will=20not=20let=0A+you=20= specify=20dates=20outside=20the=201970-2037=20range,=20so=20it=20is=20= certain=20that=0A+these=20dates=20will=20work=20in=20whatever=20version=20= of=20Emacs=20you=20are=0A+running,=20and=20also=20that=20you=20can=20= move=20a=20file=20from=20one=20Emacs=20implementation=0A+to=20another.=20= =20WHenever=20Org=20is=20forcing=20the=20year=20for=20you,=20it=20will=20= display=0A+a=20message=20and=20beep.=0A+=0A+When=20this=20variable=20is=20= nil,=20Org=20will=20check=20if=20the=20date=20is=0A+representable=20in=20= the=20specific=20Emacs=20implementation=20you=20are=20using.=0A+If=20= not,=20it=20will=20force=20a=20year,=20usually=20the=20current=20year,=20= and=20beep=0A+to=20remind=20you.=20=20Currently=20this=20setting=20is=20= not=20recommended=20because=0A+the=20likelihood=20that=20you=20will=20= open=20your=20Org=20files=20in=20an=20Emacs=20that=0A+has=20limited=20= date=20range=20is=20not=20negligible.=0A+=0A+A=20workaround=20for=20this=20= problem=20is=20to=20use=20diary=20sexp=20dates=20for=20time=0A+stamps=20= outside=20of=20this=20range."=0A+=20=20:group=20'org-time=0A+=20=20:type=20= 'boolean)=0A+=0A=20(defcustom=20org-read-date-display-live=20t=0A=20=20=20= "Non-nil=20means=20display=20current=20interpretation=20of=20date=20= prompt=20live.=0A=20This=20display=20will=20be=20in=20an=20overlay,=20in=20= the=20minibuffer."=0A@@=20-14503,6=20+14533,13=20@@=20user."=0A=20=0A=20=20= =20=20=20(setq=20final=20(org-read-date-analyze=20ans=20def=20= defdecode))=0A=20=0A+=20=20=20=20(when=20= org-read-date-analyze-forced-year=0A+=20=20=20=20=20=20(message=20"Year=20= was=20forced=20into=20%s"=0A+=09=20=20=20=20=20=20=20(if=20= org-read-date-force-compatible-dates=0A+=09=09=20=20=20"compatible=20= range=20(1970-2037)"=0A+=09=09=20"range=20representable=20on=20this=20= machine"))=0A+=20=20=20=20=20=20(ding))=0A+=0A=20=20=20=20=20;;=20One=20= round=20trip=20to=20get=20rid=20of=2034th=20of=20August=20and=20stuff=20= like=20that....=0A=20=20=20=20=20(setq=20final=20(decode-time=20(apply=20= 'encode-time=20final)))=0A=20=0A@@=20-14520,6=20+14557,7=20@@=20user."=0A= =20(defvar=20defdecode)=0A=20(defvar=20with-time)=0A=20(defvar=20= org-read-date-analyze-futurep=20nil)=0A+(defvar=20= org-read-date-analyze-forced-year=20nil)=0A=20(defun=20= org-read-date-display=20()=0A=20=20=20"Display=20the=20current=20date=20= prompt=20interpretation=20in=20the=20minibuffer."=0A=20=20=20(when=20= org-read-date-display-live=0A@@=20-14562,7=20+14600,8=20@@=20user."=0A=20= =09delta=20deltan=20deltaw=20deltadef=20year=20month=20day=0A=20=09hour=20= minute=20second=20wday=20pm=20h2=20m2=20tl=20wday1=0A=20=09iso-year=20= iso-weekday=20iso-week=20iso-year=20iso-date=20futurep=20kill-year)=0A-=20= =20=20=20(setq=20org-read-date-analyze-futurep=20nil)=0A+=20=20=20=20= (setq=20org-read-date-analyze-futurep=20nil=0A+=09=20=20= org-read-date-analyze-forced-year=20nil)=0A=20=20=20=20=20(when=20= (string-match=20"\\`[=20\t]*\\.[=20\t]*\\'"=20ans)=0A=20=20=20=20=20=20=20= (setq=20ans=20"+0"))=0A=20=0A@@=20-14720,7=20+14759,18=20@@=20user."=0A=20= =09=20=20=20=20=20(nth=202=20tl))=0A=20=09(setq=20org-time-was-given=20= t))=0A=20=20=20=20=20(if=20(<=20year=20100)=20(setq=20year=20(+=202000=20= year)))=0A-=20=20=20=20(if=20(<=20year=201970)=20(setq=20year=20(nth=205=20= defdecode)))=20;=20not=20representable=0A+=20=20=20=20;;=20Check=20of=20= the=20date=20is=20representable=0A+=20=20=20=20(if=20= org-read-date-force-compatible-dates=0A+=09(progn=0A+=09=20=20(if=20(<=20= year=201970)=0A+=09=20=20=20=20=20=20(setq=20year=201970=20= org-read-date-analyze-forced-year=20t))=0A+=09=20=20(if=20(>=20year=20= 2037)=0A+=09=20=20=20=20=20=20(setq=20year=202037=20=20= org-read-date-analyze-forced-year=20t)))=0A+=20=20=20=20=20=20= (condition-case=20nil=0A+=09=20=20(encode-time=20second=20minute=20hour=20= day=20month=20year)=0A+=09(error=0A+=09=20(setq=20year=20(nth=205=20= defdecode))=0A+=09=20(setq=20org-read-date-analyze-forced-year=20t))))=0A= =20=20=20=20=20(setq=20org-read-date-analyze-futurep=20futurep)=0A=20=20=20= =20=20(list=20second=20minute=20hour=20day=20month=20year)))=0A=20=0A--=20= =0A1.7.1.575.gf526=0A=0A= --Apple-Mail-4--427793604 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail-4--427793604--