diff --git a/01_git/astime.c b/01_git/astime.c index e331635209717def24d03049fb5b39cf04cb85a9..dc324db4fa178a687fcdf71dfd10029956dd3445 100644 --- a/01_git/astime.c +++ b/01_git/astime.c @@ -13,6 +13,7 @@ #include <string.h> #include <stdlib.h> #include <unistd.h> +#include <time.h> #include "safecopy.h" @@ -60,6 +61,7 @@ void defaults() { int i, j; + tzset(); state.update_interval = CHK_INTERVAL; state.draw_seconds = 1; state.tprop = 1; @@ -316,6 +318,14 @@ void parsercfile(FILE * ifp) tval = atoi(param[1]); if (tval) state.thin_seconds = atoi(param[1]); + } else if (!strcmp(param[0], "latitude")) { + state.lat = atof(param[1]); + state.twentyfour = 1; + state.sunriset = 1; + } else if (!strcmp(param[0], "longitude")) { + state.lon = atof(param[1]); + state.twentyfour = 1; + state.sunriset = 1; } else if (!strcmp(param[0], "handThickness")) { state.hthick = atoi(param[1]); thickspec = 1; @@ -412,12 +422,18 @@ void parsercfile(FILE * ifp) state.twentyfour = 1; } else if (!strcmp(param[0], "sunriset")) { tval = atoi(param[1]); - if (tval) + if (tval) { state.sunriset = 1; + state.twentyfour = 1; + } } else if (!strcmp(param[0], "sunrisetDay")) { safecopy(state.sunrisetday, param[1], MAX_OPT_LEN); + state.twentyfour = 1; + state.sunriset = 1; } else if (!strcmp(param[0], "sunrisetNight")) { safecopy(state.sunrisetnight, param[1], MAX_OPT_LEN); + state.twentyfour = 1; + state.sunriset = 1; } else if (!strcmp(param[0], "counterclockwise")) { tval = atoi(param[1]); if (tval) @@ -531,10 +547,26 @@ void parsecmdline(int argc, char *argv[]) if (++i >= argc) usage(); safecopy(state.sunrisetday, argv[i], MAX_OPT_LEN); + state.sunriset = 1; + state.twentyfour = 1; } else if (!strncmp(argument, "-srtn", 5)) { if (++i >= argc) usage(); safecopy(state.sunrisetnight, argv[i], MAX_OPT_LEN); + state.sunriset = 1; + state.twentyfour = 1; + } else if (!strncmp(argument, "-lat", 4)) { + if (++i >= argc) + usage(); + state.lat = atof(argv[i]); + state.sunriset = 1; + state.twentyfour = 1; + } else if (!strncmp(argument, "-lon", 4)) { + if (++i >= argc) + usage(); + state.lon = atof(argv[i]); + state.sunriset = 1; + state.twentyfour = 1; } else if (!strncmp(argument, "-exe", 4)) { if (++i >= argc) usage(); @@ -582,6 +614,7 @@ void parsecmdline(int argc, char *argv[]) state.twentyfour = 1; } else if (!strncmp(argument, "-srt", 4)) { state.sunriset = 1; + state.twentyfour = 1; } else if (!strncmp(argument, "-cc", 3)) { state.counterclockwise = 1; } else { diff --git a/01_git/astime.man b/01_git/astime.man index f4fed7ac466ba73bd450da4b2d518f74c9b484d4..7d4bfcf769c31b2038ce726fe394aebc6299d553 100644 --- a/01_git/astime.man +++ b/01_git/astime.man @@ -1,4 +1,4 @@ -.TH astime 1 "12 December 2000" "Version 2.8" +.TH astime 1 "26 April 2006" "cvs Version" .UC .SH NAME \fBastime\fP \- the AfterStep analogue clock @@ -30,7 +30,10 @@ [-label \fItext\fP] [-fn \fIfont name\fP] [-lcol \fIlabel color\fP] - [-ltop] [-24 [-srt]] [-cc] + [-ltop] + [-24 [-srt [-srtd \fIcolor\fP] [-srtn \fIcolor\fP] + [-lat \fIlatitude\fP] [-lon \fIlongitude\fP]]] + [-cc] .SH DESCRIPTION The \fBastime\fP is a X11 application that acts as an analogue clock that we all are familiar with. @@ -264,7 +267,25 @@ Run in 24 hour mode. .RE .IP "-srt" .RS -Show sunrise and sunset. +Show sunrise and sunset. This enables twentyfour hour mode. +.RE +.IP "-srtd <color>" +.RS +Draw the day using the specified color. The default color +is #ffa800. This enables -srt mode. +.RE +.IP "-srtn <color>" +.RS +Draw the night using the specified color. The default color +is #000000. This enables -srt mode. +.RE +.IP "-lat <latitude>" +.RS +This specifies the latitude as a floating point number. Enables -srt mode. +.RE +.IP "-lon <latitude>" +.RS +This specifies the longitude as a floating point number. Enables -srt mode. .RE .IP "-cc" .RS @@ -487,8 +508,24 @@ If the value is 1 run in 24 hour mode, else in 12 hour mode. .RE .IP "sunriset <0 | 1>" .RS -If the value is 1 and astime runs in 24 hour mode, draw sunrise and sunset -times. +If the value is 1 and astime switches to 24 hour mode and draws sunrise and +sunset times. +.RE +.IP "sunrisetDay <color>" +.RS +Switch to sunriset mode and draw the day using the given color. +.RE +.IP "sunrisetNight <color>" +.RS +Switch to sunriset mode and draw the night using the given color. +.RE +.IP "latitude <latitude>" +.RS +Switch to sunriset mode and use the given floating point number as latitude. +.RE +.IP "longitude <longitude>" +.RS +Switch to sunriset mode and use the given floating point number as latitude. .RE .IP "counterclockwise <0 | 1>" .RS diff --git a/01_git/astime_x.c b/01_git/astime_x.c index d352c25d883a68d09381b3ab2329e9516cbe045b..03d8cd10b3f7e96477074ee06da6a9854cd33a8f 100644 --- a/01_git/astime_x.c +++ b/01_git/astime_x.c @@ -173,12 +173,13 @@ void draw_sunriset(Window win, return; } if (loc_time->tm_isdst > 0) { - start += 2.0; - end += 2.0; + start += 1.0; + end += 1.0; } angle1 = (int) round(start * 15.0); angle2 = (int) round(end * 15.0); angle2 -= (angle1 + 360) % 360; + angle1 -= timezone * 0.004166667; if (state.counterclockwise) { angle1 = (360 - angle1) % 360; angle2 *= -1; diff --git a/01_git/autoconf/Makefile.defines.in b/01_git/autoconf/Makefile.defines.in index 1d8d6308f5bde78270ff280ebdd35da0d1b4df33..eb2f8298bcd22dff174e9fd700bb95a5bbc4b306 100644 --- a/01_git/autoconf/Makefile.defines.in +++ b/01_git/autoconf/Makefile.defines.in @@ -3,7 +3,7 @@ # CC = @CC@ -CCFLAGS = @CFLAGS@ -std=c99 -D_XOPEN_SOURCE=500 -Wall -Werror -pedantic -pedantic-errors +CCFLAGS = @CFLAGS@ -std=c99 -D_ISO99_SOURCE -Wall -Werror -pedantic -pedantic-errors # -march=pentiumpro -mcpu=pentiumpro RANLIB = @RANLIB@