Gnus development mailing list
 help / color / mirror / Atom feed
From: Katsumi Yamaoka <yamaoka@ga.sony.co.jp>
Subject: Re: date
Date: 11 Sep 1998 14:56:21 +0900	[thread overview]
Message-ID: <28k93bqjju.fsf@kchisa.ga.sony.co.jp> (raw)
In-Reply-To: Katsumi Yamaoka's message of "11 Sep 1998 14:50:31 +0900"

[-- 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>

  reply	other threads:[~1998-09-11  5:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-11  5:50 date Katsumi Yamaoka
1998-09-11  5:56 ` Katsumi Yamaoka [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=28k93bqjju.fsf@kchisa.ga.sony.co.jp \
    --to=yamaoka@ga.sony.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).