home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.x
- Path: uunet!think.com!mips!msi!dcmartin
- From: Harald Tveit Alvestrand <harald.alvestrand@delab.sintef.no>
- Subject: v16i095: timex - to keep track of time you spend, Part01/01
- Message-ID: <1992Feb22.192514.5482@msi.com>
- Originator: dcmartin@fascet
- Sender: dcmartin@msi.com (David C. Martin - Moderator)
- Organization: Molecular Simulations, Inc.
- Date: Sat, 22 Feb 1992 19:25:14 GMT
- Approved: dcmartin@msi.com
-
- Submitted-by: Harald Tveit Alvestrand <harald.alvestrand@delab.sintef.no>
- Posting-number: Volume 16, Issue 95
- Archive-name: timex/part01
-
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # If this archive is complete, you will see the following message at the end:
- # "End of archive 1 (of 2)."
- # Contents: README Part01 TODO Timex.ad sumtimex
- # Wrapped by dcmartin@fascet on Sat Feb 22 11:23:43 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(1490 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- XNAME: Timex
- XAUTHOR: Harald Tveit Alvestrand, SINTEF <harald.alvestrand@delab.sintef.no>
- XCOPYRIGHT: Probably.
- X
- XTimex is a very short Xt program to do a quite simple job.
- XIt puts up a list of projects, and the number of minutes worked on each.
- XYou click on the project you want to work on, and it starts counting on that.
- XIt's got a manpage.
- X
- XWhatever you do about it, please tell me.
- X
- XINSTALLATION
- X
- XIf you are lucky:
- X
- X1) Unshar
- X2) % xmkmf
- X3) % make
- X4) # make install
- X (alternate for test: xrdb -merge Timex.ad)
- X5) % Create a directory called .timex in your homedir
- X6) % Edit a file called "projectlist" in the ".timex" directory
- X7) % timex
- X
- XIf you are unlucky, mumble.
- XIf you find out why you are unlucky, send me an E-mail about it.
- X
- XTested on a Sun-3 and Sun-4 running SunOS 4.0.3. X11R4 only.
- X
- XCOPYING, PAYMENT AND SUCH DETAILS
- X
- XThe origin of this program is simple: I wrote it because I needed it.
- XFortunately, I wrote it while working for SINTEF (which has said that
- Xit does not want money for it), on an UNINETT project (which has said
- Xthat it does not want money for it), so I am free to release it.
- XTell me if you like it!
- X
- XYou may copy it and modify it in any way you like, the only thing that
- Xcan make me mad is if you sell it for real money and do not give me some.
- X
- XAs usual, there is no guarantee about anything at all, and you are not able
- Xto claim that I have done any damage to you by providing you with this
- Xprogram; any use you make of it is entirely at your own risk.
- X
- X
- END_OF_FILE
- if test 1490 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'Part01' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Part01'\"
- else
- echo shar: Extracting \"'Part01'\" \(0 characters\)
- sed "s/^X//" >'Part01' <<'END_OF_FILE'
- END_OF_FILE
- if test 0 -ne `wc -c <'Part01'`; then
- echo shar: \"'Part01'\" unpacked with wrong size!
- fi
- # end of 'Part01'
- fi
- if test -f 'TODO' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'TODO'\"
- else
- echo shar: Extracting \"'TODO'\" \(336 characters\)
- sed "s/^X//" >'TODO' <<'END_OF_FILE'
- XIdeas:
- X- Popup widget with scrollbar for changing hours-worked
- X- Sums in upper right-hand corner
- X- Warning when leaving edit-mode timex without saving
- X- Button to reread projectlist without quitting Timex
- X- Finding the pesky problem that makes lockfile not go away when logging out
- X- Finding out why the lockfile never gets any content
- END_OF_FILE
- if test 336 -ne `wc -c <'TODO'`; then
- echo shar: \"'TODO'\" unpacked with wrong size!
- fi
- # end of 'TODO'
- fi
- if test -f 'Timex.ad' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Timex.ad'\"
- else
- echo shar: Extracting \"'Timex.ad'\" \(969 characters\)
- sed "s/^X//" >'Timex.ad' <<'END_OF_FILE'
- X! TIMEX defaults
- X! All questions: Harald Tveit Alvestrand <harald.alvestrand@delab.sintef.no>
- X! General ideas:
- X! Buttons are square - oval did not look too good.
- X! *Command.shapeStyle: oval
- X! Labels don't have borders.
- X*Label.borderWidth: 0
- X! Most things are left-chained
- X*right: ChainLeft
- X*top: ChainTop
- X*bottom: ChainTop
- X! Forms should look a bit "tight"
- X*form.defaultDistance: 2
- X! Specific items
- X*form.date.horizDistance: 20
- X*form.date.vertDistance: 7
- X*form.command.orientation: horizontal
- X*form.command.plus.label: +
- X*form.command.minus.label: -
- X! The scrollbar
- X*form.scrollbar.orientation: horizontal
- X*form.scrollbar.length: 200
- X! Allow vertical resizes of the viewport
- X*form.viewport.allowVert: true
- X! Some things must be resizable
- X*form.viewport*bottom: ChainBottom
- X*form.viewport.right: ChainRight
- X*form.viewport.form.names.right: ChainRight
- X*form.viewport.top: ChainTop
- X*form.viewport.form.times.defaultColumns: 1
- X*form.viewport.form.names.defaultColumns: 1
- X
- X
- END_OF_FILE
- if test 969 -ne `wc -c <'Timex.ad'`; then
- echo shar: \"'Timex.ad'\" unpacked with wrong size!
- fi
- # end of 'Timex.ad'
- fi
- if test -f 'sumtimex' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sumtimex'\"
- else
- echo shar: Extracting \"'sumtimex'\" \(3759 characters\)
- sed "s/^X//" >'sumtimex' <<'END_OF_FILE'
- X#!/local/bin/perl
- X# PERL hours list writer for TIMEX
- X@weekdays = ("Man", "Tir", "Ons", "Tor", "Fre" ,"L|r", "S|n");
- Xpush(@INC, "/isolde/hta/sw/timex"); # Fudge!
- Xdo 'weekno.perl' || die "Could not do weekno.perl\n";
- X
- X$fudge = 0.5; # Dividing point for ROUND. Fudgeable.
- X
- Xwhile ($ARGV[0] =~ /^-[^\d]/) {
- X $option = shift(@ARGV);
- X if ($option eq "-adjust") {
- X $adjust = 1;
- X } elsif ($option eq "-round") {
- X $round = 1;
- X } elsif ($option eq "-fudge") {
- X $fudge = shift(@ARGV);
- X } elsif ($option eq "-year") {
- X $year = shift(@ARGV);
- X } else {
- X die "Usage: $0 [-year nn ] [-adjust] [-round] [week]\nDefault week=last week\n";
- X }
- X}
- X
- X$week = shift(ARGV);
- X$timenow = time;
- X$oneday = 24 * 60 * 60;
- X@daynow = localtime($timenow);
- Xif (!$week) {
- X # Default is last week.
- X $week = &DATE'weekno($timenow) - 1;
- X}
- Xif (!$year) {
- X $year = $daynow[5];
- X}
- X
- X$timefetch = &DATE'firstinweek($week, $year);
- Xprint "Timeliste for uke $week 19$year\n";
- X
- Xfor $wday (1..7) {
- X @dayfetch = localtime($timefetch);
- X $weekdate[$wday] = sprintf("%d/%d", $dayfetch[3], $dayfetch[4] + 1);
- X $filename = sprintf("$ENV{'HOME'}/.timex/%04d-%02d-%02d",
- X 1900 + $dayfetch[5], 1 + $dayfetch[4], $dayfetch[3]);
- X open(FILE, $filename) || do {
- X print STDERR "No file $filename\n";
- X $timefetch = $timefetch + $oneday;
- X next;
- X };
- X while (<FILE>) {
- X chop;
- X if (/^\s*(\d*):(\d*) (.*)/) {
- X $project = $3;
- X $spent = $1 + $2 / 60;
- X $worked{$project} = 1; # Mark as worked-on this week
- X $hours{"$project $wday"} = $spent;
- X }
- X }
- X close FILE;
- X $timefetch = $timefetch + $oneday;
- X}
- X
- X&resum;
- Xif ($hours == 0) {
- X print STDERR "No hours worked this week!\n";
- X exit 1;
- X}
- X
- Xif ($adjust) {
- X &adjust();
- X}
- X
- Xif ($round) {
- X &round;
- X}
- X
- X# Print the result
- X
- Xprintf "%-30.30s%5s!%5s%5s%5s%5s%5s%5s%5s\n",
- X "Project", "TOT", @weekdays;
- Xprintf "%-30.30s%5s!%5s%5s%5s%5s%5s%5s%5s\n",
- X "Date", "", @weekdate[1..7];
- Xprint "======================================================================\n";
- Xfor $pro (sort(keys(%hourstot))) {
- X printf "%-30.30s%5.1f!", $pro, $hourstot{$pro};
- X for $day (1..7) {
- X if ($hours{"$pro $day"}) {
- X printf "%5.1f", $hours{"$pro $day"};
- X } else {
- X printf "%5s", "";
- X }
- X }
- X print "\n";
- X}
- Xprint "======================================================================\n";
- Xprintf "%-30.30s%5.1f!%5.1f%5.1f%5.1f%5.1f%5.1f%5.1f%5.1f\n",
- X "TOTAL", $hours, @hours[1..7];
- X
- Xsub adjust {
- X # Adjust - spread + projects across the board
- X
- X for $pro (keys(%hours)) {
- X if ($pro =~ /^\+/) {
- X $tospread += $hours{$pro};
- X }
- X }
- X $factor = ($tospread/($hours - $tospread)) + 1;
- X printf STDERR "Distributing %5.1f hours across %5.1f hours, factor %5.2f\n",
- X $tospread, $hours, $factor;
- X # 1) Distribute across projects
- X for $pro (keys(%hours)) {
- X if ($pro =~ /^\+/) {
- X $hours{$pro} = 0;
- X } else {
- X $hours{$pro} *= $factor;
- X }
- X }
- X &resum("adjust");
- X}
- X
- Xsub round {
- X# Round all numbers to half-hours
- X for $pro (keys(%hours)) {
- X $hours{$pro} = int(($hours{$pro} * 2) + $fudge) / 2;
- X }
- X &resum("round");
- X}
- X
- Xsub resum {
- X local($why) = @_;
- X local($oldhours) = $hours;
- X undef %hourstot;
- X undef @hours;
- X $hours = 0;
- X for $pro (keys(%hours)) {
- X if ($pro =~ /(^.*) (\d)$/) {
- X $project = $1; $wday = $2;
- X $hourstot{$project} += $hours{$pro};
- X $hours[$wday] += $hours{$pro};
- X $hours += $hours{$pro};
- X } else {
- X print STDERR "Bad projectday: $pro\n";
- X }
- X }
- X if ($oldhours && (($hours - $oldhours) ** 2 > 0.1)) {
- X print STDERR "$why: Changed total from $oldhours to $hours\n";
- X }
- X}
- X
- X
- X
- X
- X
- X
- END_OF_FILE
- if test 3759 -ne `wc -c <'sumtimex'`; then
- echo shar: \"'sumtimex'\" unpacked with wrong size!
- fi
- chmod +x 'sumtimex'
- # end of 'sumtimex'
- fi
- echo shar: End of archive 1 \(of 2\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked both archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- --
- Molecular Simulations, Inc. mail: dcmartin@msi.com
- 796 N. Pastoria Avenue uucp: uunet!dcmartin
- Sunnyvale, California 94086 at&t: 408/522-9236
-