Gnus development mailing list
 help / color / mirror / Atom feed
* date
@ 1998-09-11  5:50 Katsumi Yamaoka
  1998-09-11  5:56 ` date Katsumi Yamaoka
  1998-09-11  6:20 ` date Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Katsumi Yamaoka @ 1998-09-11  5:50 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

The last argument for encode-time() must be TZ. However, the last
element of list from parse-time-string() is nil. I wonder the number
of ellements from parse-time-string() exceeds right one by one.

And one another thing. When we calculate UT in article-make-date-line(),
only to input zero to TZ don't make the right value.

This is the patch for it.

[-- Attachment #2: pgnus-0.24-date.patch --]
[-- Type: application/octet-stream, Size: 1842 bytes --]

--- pgnus-0.24/lisp/gnus-art.el~	Thu Sep 10 11:01:51 1998
+++ pgnus-0.24/lisp/gnus-art.el	Fri Sep 11 14:41:46 1998
@@ -1352,17 +1352,26 @@
      ;; functions since they aren't particularly resistant to
      ;; buggy dates.
      ((eq type 'local)
-      (concat "Date: " (current-time-string time)))
+      (let ((tz (car (current-time-zone))))
+	(format "Date: %s %s%04d" (current-time-string time)
+		(if (> tz 0) "+" "-") (abs (/ tz 36)))))
      ;; Convert to Universal Time.
      ((eq type 'ut)
       (concat "Date: "
 	      (current-time-string
-	       (let ((e (parse-time-string date)))
-		 (setcar (last e) 0)
-		 (apply 'encode-time e)))))
+	       (let* ((e (parse-time-string date))
+		     (tm (apply 'encode-time e))
+		     (ms (car tm))
+		     (ls (- (cadr tm) (car (current-time-zone)))))
+		 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
+		       ((> ls 65535) (list (1+ ms) (- ls 65536)))
+		       (t (list ms ls)))))
+	      " UT"))
      ;; Get the original date from the article.
      ((eq type 'original)
-      (concat "Date: " date))
+      (concat "Date: " (if (string-match "\n+$" date)
+			   (substring date 0 (match-beginning 0))
+			 date)))
      ;; Let the user define the format.
      ((eq type 'user)
       (if (gnus-functionp gnus-article-time-format)
--- pgnus-0.24/lisp/parse-time.el~	Thu Sep 10 11:01:53 1998
+++ pgnus-0.24/lisp/parse-time.el	Fri Sep 11 14:41:46 1998
@@ -169,7 +169,7 @@
   "Parse the time-string STRING into (SEC MIN HOUR DAY MON YEAR DOW DST TZ).
 The values are identical to those of `decode-time', but any values that are
 unknown are returned as nil."
-  (let ((time (list nil nil nil nil nil nil nil nil nil nil))
+  (let ((time (list nil nil nil nil nil nil nil nil nil))
 	(temp (parse-time-tokenize (downcase string))))
     (while temp
       (let ((elt (pop temp))

[-- Attachment #3: Type: text/plain, Size: 44 bytes --]

-- 
Katsumi Yamaoka <yamaoka@ga.sony.co.jp>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: date
  1998-09-11  5:50 date Katsumi Yamaoka
@ 1998-09-11  5:56 ` Katsumi Yamaoka
  1998-09-11  6:22   ` date Lars Magne Ingebrigtsen
  1998-09-11  6:20 ` date Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 5+ messages in thread
From: Katsumi Yamaoka @ 1998-09-11  5:56 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 969 bytes --]

>>>>> In <28n287qjtk.fsf@kchisa.ga.sony.co.jp> 
>>>>>	Katsumi Yamaoka <yamaoka@ga.sony.co.jp> wrote:

KY> The last argument for encode-time() must be TZ. However, the last
KY> element of list from parse-time-string() is nil. I wonder the number
KY> of ellements from parse-time-string() exceeds right one by one.

KY> And one another thing. When we calculate UT in article-make-date-line(),
KY> only to input zero to TZ don't make the right value.

By the way, there are some Emacsen, which depends on OS and have the
BUG that TZ of the last argument is ignored by encode-time().

(current-time-string (encode-time 56 34 14 11 9 1998 32400))
	"Fri Sep 11 14:34:56 1998"

(current-time-string (encode-time 56 34 12 11 9 1998 0))
	"Fri Sep 11 14:34:56 1998"  <-- ???

I certified that they have the problem.
	Any Emacsen on NEWSOS4
        Meadow 1.01 on Windows NT

So I tried to make a program that replaces encode-time() to the
function, which returnes correct value.

[-- Attachment #2: revised-encode-time.el --]
[-- Type: application/octet-stream, Size: 1603 bytes --]

(if (fboundp 'original-broken-encode-time)
    nil
  (if (equal (encode-time 0 0 0 1 1 2001 0)
	     (encode-time 0 0 0 1 1 2001 43200))
      (fset 'original-broken-encode-time (symbol-function 'encode-time))))

(defun revised-encode-time (&rest args)
  "Convert SECOND, MINUTE, HOUR, DAY, MONTH, YEAR and ZONE to internal time.
This is the reverse operation of `decode-time', which see.
ZONE defaults to the current time zone rule.  This can
be a string (as from `set-time-zone-rule'), or it can be a list
\(as from `current-time-zone') or an integer (as from `decode-time')
applied without consideration for daylight savings time.

You can pass more than 7 arguments; then the first six arguments
are used as SECOND through YEAR, and the *last* argument is used as ZONE.
The intervening arguments are ignored.
This feature lets (apply 'encode-time (decode-time ...)) work.

Out-of-range values for SEC, MINUTE, HOUR, DAY, or MONTH are allowed;
for example, a DAY of 0 means the day preceding the given month.
Year numbers less than 100 are treated just like other year numbers.
If you want them to stand for years in this century, you must do that yourself.
"
  (let* ((len (length args))
	 (tz (if (> len 6) (nth (1- len) args)))
	 (time (apply 'original-broken-encode-time args))
	 ms ls)
    (if (numberp tz)
	(progn
	  (setq ms (car time)
		ls (- (car (cdr time)) tz))
	  (cond ((< ls 0)
		 (list (1- ms) (+ ls 65536)))
		((> ls 65535)
		 (list (1+ ms) (- ls 65536)))
		(t
		 (list ms ls))))
      time)))

(if (fboundp 'original-broken-encode-time)
    (fset 'encode-time 'revised-encode-time))

[-- Attachment #3: Type: text/plain, Size: 44 bytes --]

-- 
Katsumi Yamaoka <yamaoka@ga.sony.co.jp>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: date
  1998-09-11  5:50 date Katsumi Yamaoka
  1998-09-11  5:56 ` date Katsumi Yamaoka
@ 1998-09-11  6:20 ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Lars Magne Ingebrigtsen @ 1998-09-11  6:20 UTC (permalink / raw)


Katsumi Yamaoka <yamaoka@ga.sony.co.jp> writes:

> The last argument for encode-time() must be TZ. However, the last
> element of list from parse-time-string() is nil. I wonder the number
> of ellements from parse-time-string() exceeds right one by one.

Thanks for the patch; I've applied it to Pterodactyl Gnus v0.26.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: date
  1998-09-11  5:56 ` date Katsumi Yamaoka
@ 1998-09-11  6:22   ` Lars Magne Ingebrigtsen
  1998-09-11 13:56     ` date Katsumi Yamaoka
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Magne Ingebrigtsen @ 1998-09-11  6:22 UTC (permalink / raw)


Katsumi Yamaoka <yamaoka@ga.sony.co.jp> writes:

> User-Agent: Gnus/5.0700000000000003 (Pterodactyl Gnus v0.24) Emacs/19.34

Hm?  How did that happen?

(gnus-continuum-version "Pterodactyl Gnus v0.24")
=> 5.070024

Do you get 5.0700000000000003?

> By the way, there are some Emacsen, which depends on OS and have the
> BUG that TZ of the last argument is ignored by encode-time().

You should report this to the Emacs maintainers.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: date
  1998-09-11  6:22   ` date Lars Magne Ingebrigtsen
@ 1998-09-11 13:56     ` Katsumi Yamaoka
  0 siblings, 0 replies; 5+ messages in thread
From: Katsumi Yamaoka @ 1998-09-11 13:56 UTC (permalink / raw)


>>>>> In <m3k93bi2xr.fsf@sparky.gnus.org> 
>>>>>	Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:

Lars> User-Agent: Gnus/5.0700000000000003 (Pterodactyl Gnus v0.24) Emacs/19.34
Lars> Hm?  How did that happen?

Lars> (gnus-continuum-version "Pterodactyl Gnus v0.24")
=> 5.070024

Lars> Do you get 5.0700000000000003?

Don't mind please.
I'm using Mule 2.3 based on Emacs 19.34 for mere pleasure. :-)

(* 0.1 1)
=> 0.10000000000000001

(string-to-number "5.07002600")
=> 5.0700260000000004
-- 
Katsumi Yamaoka <yamaoka@ga.sony.co.jp>



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1998-09-11 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-09-11  5:50 date Katsumi Yamaoka
1998-09-11  5:56 ` date Katsumi Yamaoka
1998-09-11  6:22   ` date Lars Magne Ingebrigtsen
1998-09-11 13:56     ` date Katsumi Yamaoka
1998-09-11  6:20 ` date Lars Magne Ingebrigtsen

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 NNTP newsgroup(s).