Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!cmcl2!yale!husc6!rutgers!sri-spam!mordor!styx!lll-crg!lll-lcc!unisoft!jef From: jef@unisoft.UUCP (Jef Poskanzer) Newsgroups: net.sources Subject: PHOON, part one of two. Message-ID: <167@unisoft.UUCP> Date: Thu, 20-Nov-86 12:09:44 EST Article-I.D.: unisoft.167 Posted: Thu Nov 20 12:09:44 1986 Date-Received: Thu, 20-Nov-86 23:20:15 EST Reply-To: jef@unisoft.UUCP (Jef Poskanzer) Organization: UniSoft Systems; Berkeley, CA Lines: 1221 First distribution of phoon, deltime, and libtws - 15nov86. This package contains two programs and a library: phoon - program to display the PHase of the mOON. Unlike other such programs, which just tell you how long since first quarter or something like that, phoon *shows* you the phase with a little picture. I've put an example at the end of this file. deltime - program to subtract date/times. Tells you the difference between two date/times, or between now and a specified date/time. I once used this to help a friend quit smoking - every time she logged in, the computer told her how many days since her last cigarette. I also use it in my .login, to tell me how old I am. libtws - date/time library. Unlike the standard Unix(R) date/time routines, libtws lets you parse a date/time string into internal form. Most of this library came from version 6.5 of the MH message handling system, courtesy of Marshall Rose. Files in this distribution: README this Makefile guess deltime.c source for time subtraction tool deltime.man manual for time subtraction tool dtime.c source for most of the time routines dtimep.lex source for time-parsing routine lexedit.sed script to modify output of lex lexstring.c front end for time-parsing routine libtws.man manual for time library parsetime.c source for test program phoon.c source for phase of moon program phoon.man manual for phase of moon program tws.h include file for time library Unpack the files, edit Makefile and change the options to suit, make, and enjoy! I've tested this stuff under 4.2 BSD, 4.3 BSD, and System V rel 2. Nevertheless, I'm sure bugs remain. Feedback is welcome - send bug reports, enhancements, checks, money orders, etc. to the addresses below. Jef Poskanzer, UniSoft Systems, Berkeley unisoft!jef@ucbvax.Berkeley.Edu ...ucbvax!unisoft!jef (415)644-1230 ------------. .--' o . . `--. .-' . O . . `-. -'@ @@@@@@@ . @@@@@ `-. @@@ @@@@@@@@@@@ @@@@@@@ . \ / o @@@@@@@@@@@ @@@@@@@ . \. @@ o @@@@@@@@@@@. @@@@@@@ O \ @@@@ . @@@@@@@o @@@@@@@@@@ @@@ \ @@@@@ . @@@@@@@@@@@@@ o @@@@| @@@@@ O `.-./ . @@@@@@@@@@@@ @@ \ First Quarter + @@@@ --`-' o @@@@@@@@ @@@@ | 5 22:33:24 @ @@@ ` o . @@ . @@@@@@@ | Full Moon - @@ .-. @@@ @@@@@@@ | 1 10:37:39 . o @@@ `-' . @@@@ @@@@ o / @@ @@@@@ . @@ . | @@@@ @\@@ / . O . o . / o @@ \ \ / . . / \ . .\.-.___ . . .-. /' `-' `-' / -. o / | o O . .-' `-. / . . .-' `--. . .--' ------------' #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # README # Makefile # deltime.c # deltime.man # dtime.c # dtimep.lex # This archive created: Mon Nov 17 11:55:54 1986 # By: Jef Poskanzer () export PATH; PATH=/bin:$PATH echo shar: extracting "'README'" '(3041 characters)' if test -f 'README' then echo shar: will not over-write existing file "'README'" else sed 's/^X//' << \SHAR_EOF > 'README' XFirst distribution of phoon, deltime, and libtws - 15nov86. X X XThis package contains two programs and a library: X X phoon - program to display the PHase of the mOON. Unlike other X such programs, which just tell you how long since first quarter X or something like that, phoon *shows* you the phase with a little X picture. I've put an example at the end of this file. X X deltime - program to subtract date/times. Tells you the difference X between two date/times, or between now and a specified date/time. X I once used this to help a friend quit smoking - every time she X logged in, the computer told her how many days since her last X cigarette. I also use it in my .login, to tell me how old I am. X X libtws - date/time library. Unlike the standard Unix(R) X date/time routines, libtws lets you parse a date/time string X into internal form. Most of this library came from version X 6.5 of the MH message handling system, courtesy of Marshall Rose. X X XFiles in this distribution: X X README this X Makefile guess X deltime.c source for time subtraction tool X deltime.man manual for time subtraction tool X dtime.c source for most of the time routines X dtimep.lex source for time-parsing routine X lexedit.sed script to modify output of lex X lexstring.c front end for time-parsing routine X libtws.man manual for time library X parsetime.c source for test program X phoon.c source for phase of moon program X phoon.man manual for phase of moon program X tws.h include file for time library X X XUnpack the files, edit Makefile and change the options to suit, Xmake, and enjoy! I've tested this stuff under 4.2 BSD, 4.3 BSD, Xand System V rel 2. Nevertheless, I'm sure bugs remain. Feedback Xis welcome - send bug reports, enhancements, checks, money orders, Xetc. to the addresses below. X X X Jef Poskanzer, UniSoft Systems, Berkeley X unisoft!jef@ucbvax.Berkeley.Edu X ...ucbvax!unisoft!jef X (415)644-1230 X X ------------. X .--' o . . `--. X .-' . O . . `-. X -'@ @@@@@@@ . @@@@@ `-. X @@@ @@@@@@@@@@@ @@@@@@@ . \ X / o @@@@@@@@@@@ @@@@@@@ . \. X @@ o @@@@@@@@@@@. @@@@@@@ O \ X @@@@ . @@@@@@@o @@@@@@@@@@ @@@ \ X @@@@@ . @@@@@@@@@@@@@ o @@@@| X @@@@@ O `.-./ . @@@@@@@@@@@@ @@ \ First Quarter + X @@@@ --`-' o @@@@@@@@ @@@@ | 5 22:33:24 X @ @@@ ` o . @@ . @@@@@@@ | Full Moon - X @@ .-. @@@ @@@@@@@ | 1 10:37:39 X . o @@@ `-' . @@@@ @@@@ o / X @@ @@@@@ . @@ . | X @@@@ @\@@ / . O . o . / X o @@ \ \ / . . / X \ . .\.-.___ . . .-. /' X `-' `-' / X -. o / | o O . .-' X `-. / . . .-' X `--. . .--' X ------------' SHAR_EOF if test 3041 -ne "`wc -c < 'README'`" then echo shar: error transmitting "'README'" '(should have been 3041 characters)' fi fi # end of overwriting check echo shar: extracting "'Makefile'" '(1873 characters)' if test -f 'Makefile' then echo shar: will not over-write existing file "'Makefile'" else sed 's/^X//' << \SHAR_EOF > 'Makefile' X# Makefile for phoon, deltime, parsetime, and libtws (stolen from mh). X X X# Valid options: X# BSD42 Set this if your system is BSD 4.2 or later. X# SYS5 Set this if your system is System V. X# EUROPE Makes nn/nn/nn mean dd/mm/yy instead of mm/dd/yy. X# ATZ This has something to do with alpha-numeric time zones. X# DSTXXX This has something to do with daylight savings time. X# HUJI I don't X# INETONLY know what X# LEXDEBUG the rest of these X# ONECASE do. XOPTIONS = -DBSD42 -DATZ -DDSTXXX X X XCC = cc XCFLAGS = -O $(OPTIONS) XLDFLAGS = -ns X X.SUFFIXES: .man .cat X.man.cat: X nroff -h -man $< > $@ X X Xall: phoon phoon.cat deltime deltime.cat parsetime libtws.cat X X Xphoon: phoon.o libtws.a X $(CC) $(LDFLAGS) -o phoon phoon.o -lm libtws.a X Xphoon.o: phoon.c tws.h X X Xdeltime: deltime.o libtws.a X $(CC) $(LDFLAGS) -o deltime deltime.o libtws.a X Xdeltime.o: deltime.c tws.h X X Xparsetime: parsetime.o libtws.a X $(CC) $(LDFLAGS) -o parsetime parsetime.o libtws.a X Xparsetime.o: parsetime.c tws.h X X Xlibtws.a: dtime.o dtimep.o lexstring.o X ar r libtws.a dtime.o dtimep.o lexstring.o X ranlib libtws.a X X Xdtime.o: dtime.c tws.h X X Xdtimep.o: dtimep.c tws.h X Xdtimep.c: dtimep.lex X lex -nt dtimep.lex | sed -f lexedit.sed > dtimep.c X X Xlexstring.o: lexstring.c X $(CC) $(CFLAGS) -c -DONECASE lexstring.c X X Xclean: X -rm -f dtimep.c *.o libtws.a phoon deltime parsetime *.cat phoon.shar core X Xphoon.shar: phoon.shar1 phoon.shar2 X Xphoon.shar1: README Makefile deltime.c deltime.man dtime.c dtimep.lex X shar -v -c -p X README Makefile deltime.c deltime.man dtime.c dtimep.lex > phoon.shar1 X Xphoon.shar2: lexedit.sed lexstring.c libtws.man parsetime.c phoon.c phoon.man tws.h X shar -v -c -p X lexedit.sed lexstring.c libtws.man parsetime.c phoon.c phoon.man tws.h > phoon.shar2 SHAR_EOF if test 1873 -ne "`wc -c < 'Makefile'`" then echo shar: error transmitting "'Makefile'" '(should have been 1873 characters)' fi fi # end of overwriting check echo shar: extracting "'deltime.c'" '(2156 characters)' if test -f 'deltime.c' then echo shar: will not over-write existing file "'deltime.c'" else sed 's/^X//' << \SHAR_EOF > 'deltime.c' X/* deltime.c - subtract date/times X Xver date who remarks X--- ------- --- ------------------------------------------------------------- X01B 15nov86 JP Modified to use twsubtract(). X01A 08nov86 JP Written. X XCopyright (C) 1986 by Jef Poskanzer. Permission to use, copy, Xmodify, and distribute this software and its documentation for any Xpurpose and without fee is hereby granted, provided that this copyright Xnotice appear in all copies and in all supporting documentation. No Xrepresentation is made about the suitability of this software for any Xpurpose. It is provided "as is" without express or implied warranty. X X*/ X Xstatic char copyright[] = "\nCopyright (C) 1986 by Jef Poskanzer.\n"; X X X#include "tws.h" X#include X X#define SECSPERMINUTE 60 X#define SECSPERHOUR (60 * SECSPERMINUTE) X#define SECSPERDAY (24 * SECSPERHOUR) X Xmain( argc, argv ) Xint argc; Xchar *argv[]; X { X struct tws tws1, tws2, *twp; X long delta, days, hours, minutes, secs; X char *illdt = "illegal date/time: %s\n"; X X if ( argc == 2 ) X { X twp = dparsetime( argv[1] ); X if ( twp == NULL || twp -> tw_flags & TW_JUNK ) X { X fprintf( stderr, illdt, argv[1] ); X exit( 1 ); X } X twscopy( &tws1, twp ); X twscopy( &tws2, dtwstime( ) ); X } X else if ( argc == 3 ) X { X twp = dparsetime( argv[1] ); X if ( twp == NULL || twp -> tw_flags & TW_JUNK ) X { X fprintf( stderr, illdt, argv[1] ); X exit( 1 ); X } X twscopy( &tws1, twp ); X twp = dparsetime( argv[2] ); X if ( twp == NULL || twp -> tw_flags & TW_JUNK ) X { X fprintf( stderr, illdt, argv[2] ); X exit( 1 ); X } X twscopy( &tws2, twp ); X } X else X { X fprintf( stderr, "usage: %s