| 1 |
From [email protected] Sun Oct 19 00:52:20 1997 |
| 2 |
Return-Path: <[email protected]> |
| 3 |
Received: from gemini.cesta.com (gemini.cesta.com [206.127.255.218]) |
| 4 |
by mail3.netcom.com (8.8.5-r-beta/8.8.5/(NETCOM v1.01)) with ESMTP id AAA29311 |
| 5 |
for <[email protected]>; Sun, 19 Oct 1997 00:52:19 -0700 (PDT) |
| 6 |
Received: from localhost (julian@localhost) |
| 7 |
by gemini.cesta.com (8.8.5/8.8.5) with SMTP id VAA01485 |
| 8 |
for <[email protected]>; Sat, 18 Oct 1997 21:48:55 -1000 |
| 9 |
X-Authentication-Warning: gemini.cesta.com: julian owned process doing -bs |
| 10 |
Date: Sat, 18 Oct 1997 21:48:53 -1000 (HST) |
| 11 |
From: Julian Cowley <[email protected]> |
| 12 |
Reply-To: Julian Cowley <[email protected]> |
| 13 |
To: Marc Singer <[email protected]> |
| 14 |
Subject: buici clock diffs |
| 15 |
Message-ID: <[email protected]> |
| 16 |
MIME-Version: 1.0 |
| 17 |
Content-Type: TEXT/PLAIN; charset=US-ASCII |
| 18 |
Status: RO |
| 19 |
|
| 20 |
Hi Marc, |
| 21 |
|
| 22 |
Just tried your buici clock. Very nice! I have a couple of requests and |
| 23 |
a fix for a small bug. |
| 24 |
|
| 25 |
First, feature requests :) |
| 26 |
|
| 27 |
* option to leave out seconds hand |
| 28 |
|
| 29 |
* the -geometry option didn't seem to work right with regards to screen |
| 30 |
placement. I.e., using something like -geometry -0+0 still placed the |
| 31 |
clock in the upper-left hand corner. |
| 32 |
|
| 33 |
Now, a bug fix. I live in Hawaii, where we don't use daylight savings |
| 34 |
time (as opposed to most of the US). When I first tried the program, the |
| 35 |
clock was one hour ahead of local time. I tracked the error to |
| 36 |
gettimeofday() and the time zone data it reports. The zoneinfo library is |
| 37 |
better, as it handles exceptions such as Hawaii. |
| 38 |
|
| 39 |
A small note about the patch. localtime() sets two global variables, |
| 40 |
timezone and daylight. Originally, I used daylight to determine if |
| 41 |
daylight savings time is in effect, but it acts the same way as |
| 42 |
gettimeofday(). I solved this by using tm_isdst instead. |
| 43 |
|
| 44 |
ps. QOTD. What does Buici mean? |
| 45 |
|
| 46 |
--- clock..cxx.orig Fri Oct 17 18:20:27 1997 |
| 47 |
+++ clock.cxx Sat Oct 18 20:01:43 1997 |
| 48 |
@@ -373,13 +373,12 @@ |
| 49 |
{ |
| 50 |
// -- Check time |
| 51 |
struct timeval tv; |
| 52 |
- struct timezone tz; |
| 53 |
+ struct tm *tm; |
| 54 |
memset (&tv, 0, sizeof (tv)); |
| 55 |
- memset (&tz, 0, sizeof (tz)); |
| 56 |
- gettimeofday (&tv, &tz); |
| 57 |
- time_t seconds = tv.tv_sec - tz.tz_minuteswest*60; |
| 58 |
- if (tz.tz_dsttime == DST_USA) |
| 59 |
- seconds += 3600; |
| 60 |
+ gettimeofday (&tv, 0); |
| 61 |
+ time_t seconds = tv.tv_sec; |
| 62 |
+ tm = localtime (&seconds); // -- Also sets timezone global variable |
| 63 |
+ seconds = seconds - timezone + (tm->tm_isdst ? 3600 : 0); |
| 64 |
if (seconds == m_seconds) |
| 65 |
return false; |
| 66 |
m_seconds = seconds; |
| 67 |
|
| 68 |
|