Gnus development mailing list
 help / color / mirror / Atom feed
* time format on message citation line
@ 2014-04-02  4:00 Zhao, Gang
  2014-04-03  5:18 ` Katsumi Yamaoka
  0 siblings, 1 reply; 14+ messages in thread
From: Zhao, Gang @ 2014-04-02  4:00 UTC (permalink / raw)
  To: ding

Hi all,

I use a custom message citation line which includes the time when the
author post his mail. I want the time showed in message citation
line be the original author's timezone, not mine.

For example, if the author's timezone is +0200, the citation line's time
will show in that timezone. In my current setting the time is always
displayed as my own timezone, i.e., +0800.

My message-citation-line-format setting is "On %a, %Y-%m-%d at %T %z, %N wrote:"

Please add me to CC, not subscribed.



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

* Re: time format on message citation line
  2014-04-02  4:00 time format on message citation line Zhao, Gang
@ 2014-04-03  5:18 ` Katsumi Yamaoka
  2014-04-03 11:25   ` Zhao, Gang
  0 siblings, 1 reply; 14+ messages in thread
From: Katsumi Yamaoka @ 2014-04-03  5:18 UTC (permalink / raw)
  To: Zhao, Gang; +Cc: ding

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

On Wed, 2014-04-02 at 12:00:19 +0800, Zhao, Gang wrote:
> I use a custom message citation line which includes the time when the
> author post his mail. I want the time showed in message citation
> line be the original author's timezone, not mine.

> For example, if the author's timezone is +0200, the citation line's time
> will show in that timezone. In my current setting the time is always
> displayed as my own timezone, i.e., +0800.

> My message-citation-line-format setting is "On %a, %Y-%m-%d at %T %z, %N wrote:"

> Please add me to CC, not subscribed.

A hack is below.  Since manipulating timezone is not so easy,
probably we will have to do it in a similar way if we add this
feature to the Gnus code.


[-- Attachment #2: Type: application/emacs-lisp, Size: 1146 bytes --]

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

* Re: time format on message citation line
  2014-04-03  5:18 ` Katsumi Yamaoka
@ 2014-04-03 11:25   ` Zhao, Gang
  2014-04-10 11:06     ` format-time-string (was Re: time format on message citation line) Katsumi Yamaoka
  2014-04-15 23:34     ` time format on message citation line Katsumi Yamaoka
  0 siblings, 2 replies; 14+ messages in thread
From: Zhao, Gang @ 2014-04-03 11:25 UTC (permalink / raw)
  To: ding; +Cc: Katsumi Yamaoka

Hi,
On Thu, 2014-04-03 at 14:18:17 +0900, Katsumi Yamaoka wrote:
> On Wed, 2014-04-02 at 12:00:19 +0800, Zhao, Gang wrote:
>> I use a custom message citation line which includes the time when the
>> author post his mail. I want the time showed in message citation
>> line be the original author's timezone, not mine.
>
>> For example, if the author's timezone is +0200, the citation line's time
>> will show in that timezone. In my current setting the time is always
>> displayed as my own timezone, i.e., +0800.
>
>> My message-citation-line-format setting is "On %a, %Y-%m-%d at %T %z, %N wrote:"
>
>> Please add me to CC, not subscribed.
>
> A hack is below.  Since manipulating timezone is not so easy,
> probably we will have to do it in a similar way if we add this
> feature to the Gnus code.

This really works, as showed in above citation line :) Thanks for your help.

>
> (defadvice message-insert-formatted-citation-line
>     (around use-original-timezone (&optional from date) activate)
>   "Use the original author's timezone in the citation line."
>   (if (and message-reply-headers
> 	   (not date)
> 	   (string-match "%z" message-citation-line-format))
>       (let* ((st (match-beginning 0))
> 	     (nd (match-end 0))
> 	     (message-citation-line-format message-citation-line-format)
> 	     (sent (mail-header-date message-reply-headers))
> 	     (time (progn
> 		     (require 'gnus-util)
> 		     (gnus-date-get-time sent)))
> 	     (tz (nth 8 (parse-time-string sent)))
> 	     (lsd (- (cadr time) (car (current-time-zone)) (- tz)))
> 	     (msd (car time)))
> 	(cond ((< lsd 0)
> 	       (setq msd (1- msd)
> 		     lsd (+ lsd 65536)))
> 	      ((>= lsd 65536)
> 	       (setq msd (1+ msd)
> 		     lsd (- lsd 65536))))
> 	(setq message-citation-line-format
> 	      (concat (substring message-citation-line-format 0 st)
> 		      (format "%s%02d00"
> 			      (if (>= tz 0) "+" "-")
> 			      (abs (/ tz 3600)))
> 		      (substring message-citation-line-format nd)))
> 	(setq date (list msd lsd))
> 	ad-do-it)
>     ad-do-it))



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

* format-time-string (was Re: time format on message citation line)
  2014-04-03 11:25   ` Zhao, Gang
@ 2014-04-10 11:06     ` Katsumi Yamaoka
  2014-04-10 16:50       ` Andreas Schwab
  2014-04-19 21:22       ` Adam Sjøgren
  2014-04-15 23:34     ` time format on message citation line Katsumi Yamaoka
  1 sibling, 2 replies; 14+ messages in thread
From: Katsumi Yamaoka @ 2014-04-10 11:06 UTC (permalink / raw)
  To: ding

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

Hi,

I made a yet another `format-time-string' function (attached),
that allows specifying time zone.  This can be used as a substitute
of it used in `message-insert-formatted-citation-line'[1].
This function works as follows (all represent the same time):

(gmm-format-time-string "%a, %d %b %Y %T %z" '(21508 24512) -18000)
 => "Mon, 01 Sep 2014 07:00:00 -0500"
(gmm-format-time-string "%a, %d %b %Y %T %z" '(21508 24512) 0)
 => "Mon, 01 Sep 2014 12:00:00 +0000"
(gmm-format-time-string "%a, %d %b %Y %T %z" '(21508 24512) 32400)
 => "Mon, 01 Sep 2014 21:00:00 +0900"

But I have a question about the summer time (daylight saving time).
Is a computer clock adjusted automatically when the summer time
starts and ends?  If so, does the return value of (current-time-zone)
switch when the day comes?  Otherwise, do people who live in such
region have to alter the TZ environment variable manually (twice in
a year)?

Thanks.

[1] `message-insert-formatted-citation-line' is one of predefined
 functions used as `message-citation-line-function'.


[-- Attachment #2: Type: application/emacs-lisp, Size: 1292 bytes --]

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

* Re: format-time-string (was Re: time format on message citation line)
  2014-04-10 11:06     ` format-time-string (was Re: time format on message citation line) Katsumi Yamaoka
@ 2014-04-10 16:50       ` Andreas Schwab
  2014-04-10 17:57         ` Eric S Fraga
  2014-04-19 21:22       ` Adam Sjøgren
  1 sibling, 1 reply; 14+ messages in thread
From: Andreas Schwab @ 2014-04-10 16:50 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: ding

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> (defun gmm-format-time-string (format-string &optional time tz)
>   "Use FORMAT-STRING to format the time TIME, or now if omitted.
> The optional TZ specifies the time zone in a number of seconds,
> a multiple of 3600; any other non-nil value will be treated as 0."

$ TZ=Australia/Adelaide date +%z
+0930

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



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

* Re: format-time-string (was Re: time format on message citation line)
  2014-04-10 16:50       ` Andreas Schwab
@ 2014-04-10 17:57         ` Eric S Fraga
  2014-04-10 23:34           ` Katsumi Yamaoka
  0 siblings, 1 reply; 14+ messages in thread
From: Eric S Fraga @ 2014-04-10 17:57 UTC (permalink / raw)
  To: ding

On Thursday, 10 Apr 2014 at 17:50, Andreas Schwab wrote:
> Katsumi Yamaoka <yamaoka@jpl.org> writes:
>
>> (defun gmm-format-time-string (format-string &optional time tz)
>>   "Use FORMAT-STRING to format the time TIME, or now if omitted.
>> The optional TZ specifies the time zone in a number of seconds,
>> a multiple of 3600; any other non-nil value will be treated as 0."
>
> $ TZ=Australia/Adelaide date +%z
> +0930

Yes, the whole issue of time zones is akin to poking a hornet's
nest...  I spent a year in Adelaide recently while working with
colleagues in London on a daily basis.  What a nightmare it was sharing
calendars, especially as the changes to/from daylight savings happen at
different times of the year so the difference between UK and Adelaide
could be 8.5, 9.5, or 10.5 hours.

And, just for fun:

$ TZ=Asia/Kathmandu date +%z
+0545

-- 
: Eric S Fraga, GnuPG: 0xFFFCF67D
: in Emacs 24.4.50.2 + Ma Gnus v0.10 + evil evil-git-fcfb3be
: BBDB version 3.1.1 (2014-03-11 17:17:00 -0500)



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

* Re: format-time-string (was Re: time format on message citation line)
  2014-04-10 17:57         ` Eric S Fraga
@ 2014-04-10 23:34           ` Katsumi Yamaoka
  2014-04-11  8:14             ` Eric S Fraga
  0 siblings, 1 reply; 14+ messages in thread
From: Katsumi Yamaoka @ 2014-04-10 23:34 UTC (permalink / raw)
  To: ding

Eric S Fraga wrote:
> Andreas Schwab wrote:
>> $ TZ=Australia/Adelaide date +%z
>> +0930
> $ TZ=Asia/Kathmandu date +%z
> +0545

Oh, what precise verniers they use!  I realized it is not rare
to set a zone info in units of 15 minutes.  Thanks.  I'm going
to simply remove the filter `(zerop (% tz 3600))'.

(`TZ=Mideast/Riyadh87 date +%z' returns +0307, but it's never
 been used, hasn't it?)

I'm still not sure whether the alternative function works correctly
against switching the summer time.  Folks who live in PST/PDT,
MST/MDT, CST/CDT, EST/EDT, etc., how about the following?

> But I have a question about the summer time (daylight saving time).
> Is a computer clock adjusted automatically when the summer time
> starts and ends?  If so, does the return value of (current-time-zone)
> switch when the day comes?  Otherwise, do people who live in such
> region have to alter the TZ environment variable manually (twice in
> a year)?

Thanks.



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

* Re: format-time-string (was Re: time format on message citation line)
  2014-04-10 23:34           ` Katsumi Yamaoka
@ 2014-04-11  8:14             ` Eric S Fraga
  2014-04-11  9:31               ` Katsumi Yamaoka
  0 siblings, 1 reply; 14+ messages in thread
From: Eric S Fraga @ 2014-04-11  8:14 UTC (permalink / raw)
  To: ding

On Friday, 11 Apr 2014 at 00:34, Katsumi Yamaoka wrote:

[...]

>> But I have a question about the summer time (daylight saving time).
>> Is a computer clock adjusted automatically when the summer time
>> starts and ends?  If so, does the return value of (current-time-zone)
>> switch when the day comes?  Otherwise, do people who live in such
>> region have to alter the TZ environment variable manually (twice in
>> a year)?

In the UK, on my Linux system, (current-time-zone) returns 
(3600 "BST")

The system clock is set to UTC so it is independent of daylight
savings.  The time zone information is used to display the right time.

-- 
: Eric S Fraga, GnuPG: 0xFFFCF67D
: in Emacs 24.4.50.2 + Ma Gnus v0.10 + evil evil-git-fcfb3be
: BBDB version 3.1.1 (2014-03-11 17:17:00 -0500)



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

* Re: format-time-string (was Re: time format on message citation line)
  2014-04-11  8:14             ` Eric S Fraga
@ 2014-04-11  9:31               ` Katsumi Yamaoka
  2014-04-11 13:21                 ` Eric S Fraga
  0 siblings, 1 reply; 14+ messages in thread
From: Katsumi Yamaoka @ 2014-04-11  9:31 UTC (permalink / raw)
  To: ding

Eric S Fraga wrote:
> On Friday, 11 Apr 2014 at 00:34, Katsumi Yamaoka wrote:
>>> But I have a question about the summer time (daylight saving time).
>>> Is a computer clock adjusted automatically when the summer time
>>> starts and ends?  If so, does the return value of (current-time-zone)
>>> switch when the day comes?  Otherwise, do people who live in such
>>> region have to alter the TZ environment variable manually (twice in
>>> a year)?

> In the UK, on my Linux system, (current-time-zone) returns
> (3600 "BST")

> The system clock is set to UTC so it is independent of daylight
> savings.  The time zone information is used to display the right time.

Thanks.  I learned the time zone handling briefly.  Now I believe
that the summer time transition will take place automatically if
a user set the TZ environment variable suitably.  I verified:

% TZ=PST8PDT date +%z
-0700
% date 01010000
% TZ=PST8PDT date +%z
-0800



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

* Re: format-time-string (was Re: time format on message citation line)
  2014-04-11  9:31               ` Katsumi Yamaoka
@ 2014-04-11 13:21                 ` Eric S Fraga
  0 siblings, 0 replies; 14+ messages in thread
From: Eric S Fraga @ 2014-04-11 13:21 UTC (permalink / raw)
  To: ding

On Friday, 11 Apr 2014 at 10:31, Katsumi Yamaoka wrote:

[...]

> Thanks.  I learned the time zone handling briefly.  Now I believe
> that the summer time transition will take place automatically if
> a user set the TZ environment variable suitably.  I verified:

Yes, that is correct, at least on Linux.  I know I have had problems in
the past with MS Windows based systems, especially when dual-booting as
the system clock kept getting changed by the MS Windows side.  This may
no longer be the case but I haven't booted into anything other than
Linux in years.

-- 
: Eric S Fraga, GnuPG: 0xFFFCF67D
: in Emacs 24.4.50.2 + Ma Gnus v0.10 + evil evil-git-fcfb3be
: BBDB version 3.1.1 (2014-03-11 17:17:00 -0500)



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

* Re: time format on message citation line
  2014-04-03 11:25   ` Zhao, Gang
  2014-04-10 11:06     ` format-time-string (was Re: time format on message citation line) Katsumi Yamaoka
@ 2014-04-15 23:34     ` Katsumi Yamaoka
  2014-04-16  9:28       ` Zhao, Gang
  1 sibling, 1 reply; 14+ messages in thread
From: Katsumi Yamaoka @ 2014-04-15 23:34 UTC (permalink / raw)
  To: ding; +Cc: Zhao, Gang

On Thu, 03 Apr 2014 19:25:15 +0800, Zhao, Gang wrote:
> On Thu, 2014-04-03 at 14:18:17 +0900, Katsumi Yamaoka wrote:
>> A hack is below.  Since manipulating timezone is not so easy,
>> probably we will have to do it in a similar way if we add this
>> feature to the Gnus code.

> This really works, as showed in above citation line :) Thanks for your help.

I've implemented the `gmm-format-time-string' function and
modified the `message-insert-formatted-citation-line' function[1]
so as to express a date string in the original author's time
zone.  So, there is no longer a normal way to use the local time
zone.  But who does want it to do so?  Ok, here is a recipe:

(defadvice message-insert-formatted-citation-line
    (before use-local-time-zone (&optional from date tz) activate)
  "Use the local time zone."
  (setq tz (car (current-time-zone))))

[1] `message-insert-formatted-citation-line' is one of predefined
 functions used to generate a citation line, `... wrote:', in
 a reply message like the one in this article.
 To use it, customize the `message-citation-line-function'
 variable and also the `message-citation-line-format' variable.



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

* Re: time format on message citation line
  2014-04-15 23:34     ` time format on message citation line Katsumi Yamaoka
@ 2014-04-16  9:28       ` Zhao, Gang
  0 siblings, 0 replies; 14+ messages in thread
From: Zhao, Gang @ 2014-04-16  9:28 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: ding

On Wed, 2014-04-16 at 08:34:37 +0900, Katsumi Yamaoka wrote:
> On Thu, 03 Apr 2014 19:25:15 +0800, Zhao, Gang wrote:
>> On Thu, 2014-04-03 at 14:18:17 +0900, Katsumi Yamaoka wrote:
>>> A hack is below.  Since manipulating timezone is not so easy,
>>> probably we will have to do it in a similar way if we add this
>>> feature to the Gnus code.
>
>> This really works, as showed in above citation line :) Thanks for your help.
>
> I've implemented the `gmm-format-time-string' function and
> modified the `message-insert-formatted-citation-line' function[1]
> so as to express a date string in the original author's time
> zone.  So, there is no longer a normal way to use the local time
> zone.  But who does want it to do so?  Ok, here is a recipe:
>
> (defadvice message-insert-formatted-citation-line
>     (before use-local-time-zone (&optional from date tz) activate)
>   "Use the local time zone."
>   (setq tz (car (current-time-zone))))
>
It's good to know it will be the default to show the original author's
time zone. I think that's the more reasonable way.

Thanks again for your efforts on this problem.

> [1] `message-insert-formatted-citation-line' is one of predefined
>  functions used to generate a citation line, `... wrote:', in
>  a reply message like the one in this article.
>  To use it, customize the `message-citation-line-function'
>  variable and also the `message-citation-line-format' variable.



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

* Re: format-time-string (was Re: time format on message citation line)
  2014-04-10 11:06     ` format-time-string (was Re: time format on message citation line) Katsumi Yamaoka
  2014-04-10 16:50       ` Andreas Schwab
@ 2014-04-19 21:22       ` Adam Sjøgren
  2014-04-20 23:19         ` Katsumi Yamaoka
  1 sibling, 1 reply; 14+ messages in thread
From: Adam Sjøgren @ 2014-04-19 21:22 UTC (permalink / raw)
  To: ding

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> But I have a question about the summer time (daylight saving time).
> Is a computer clock adjusted automatically when the summer time
> starts and ends?

Yes, and the timezone. So localtime will be 1:59:59 CET and then 3:00:00
CEST, when the change to "summertime" happens where I live.

(Debian allows you to choose whether to keep the computers "hardware"
clock in UTC (makes sense) or localtime (for interoperability with other
operating systems/dual booting).)

> If so, does the return value of (current-time-zone) switch when the
> day comes?

I think it does, yes - currently it returns (7200 "CEST") on my machine.

> Otherwise, do people who live in such region have to alter the TZ
> environment variable manually (twice in a year)?

Nope, it happens automatically (Debian GNU/Linux here).

I take it Japan does not participate in the Daylight Savings Time
sillyness?


  Best regards,

    Adam

-- 
 "we have stairs in our house."                               Adam Sjøgren
                                                         asjo@koldfront.dk




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

* Re: format-time-string (was Re: time format on message citation line)
  2014-04-19 21:22       ` Adam Sjøgren
@ 2014-04-20 23:19         ` Katsumi Yamaoka
  0 siblings, 0 replies; 14+ messages in thread
From: Katsumi Yamaoka @ 2014-04-20 23:19 UTC (permalink / raw)
  To: ding

On Sat, 19 Apr 2014 23:22:47 +0200, Adam Sjøgren wrote:
> Katsumi Yamaoka <yamaoka@jpl.org> writes:
[...]
>> If so, does the return value of (current-time-zone) switch when the
>> day comes?

> I think it does, yes - currently it returns (7200 "CEST") on my machine.

Thanks.  I realized computers set TZ to a city name like
"Europe/Copenhagen" nowadays following Paul Eggert's (and others')
work; it supports the automatic summer time transition.

[...]
> I take it Japan does not participate in the Daylight Savings Time
> sillyness?

Japan probably won't do it, but I heard it's been done for a while
(before I was born), and now a few companies shift the office hours
to 8to4 in the summer or pay well employees who come early.



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

end of thread, other threads:[~2014-04-20 23:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-02  4:00 time format on message citation line Zhao, Gang
2014-04-03  5:18 ` Katsumi Yamaoka
2014-04-03 11:25   ` Zhao, Gang
2014-04-10 11:06     ` format-time-string (was Re: time format on message citation line) Katsumi Yamaoka
2014-04-10 16:50       ` Andreas Schwab
2014-04-10 17:57         ` Eric S Fraga
2014-04-10 23:34           ` Katsumi Yamaoka
2014-04-11  8:14             ` Eric S Fraga
2014-04-11  9:31               ` Katsumi Yamaoka
2014-04-11 13:21                 ` Eric S Fraga
2014-04-19 21:22       ` Adam Sjøgren
2014-04-20 23:19         ` Katsumi Yamaoka
2014-04-15 23:34     ` time format on message citation line Katsumi Yamaoka
2014-04-16  9:28       ` Zhao, Gang

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).