home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume16 / timex / part01 < prev    next >
Encoding:
Text File  |  1992-02-21  |  9.9 KB  |  342 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!think.com!mips!msi!dcmartin
  3. From: Harald Tveit Alvestrand <harald.alvestrand@delab.sintef.no>
  4. Subject: v16i095: timex - to keep track of time you spend, Part01/01
  5. Message-ID: <1992Feb22.192514.5482@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. Date: Sat, 22 Feb 1992 19:25:14 GMT
  10. Approved: dcmartin@msi.com
  11.  
  12. Submitted-by: Harald Tveit Alvestrand <harald.alvestrand@delab.sintef.no>
  13. Posting-number: Volume 16, Issue 95
  14. Archive-name: timex/part01
  15.  
  16. # This is a shell archive.  Remove anything before this line, then feed it
  17. # into a shell via "sh file" or similar.  To overwrite existing files,
  18. # type "sh file -c".
  19. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  20. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  21. # If this archive is complete, you will see the following message at the end:
  22. #        "End of archive 1 (of 2)."
  23. # Contents:  README Part01 TODO Timex.ad sumtimex
  24. # Wrapped by dcmartin@fascet on Sat Feb 22 11:23:43 1992
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'README' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'README'\"
  28. else
  29. echo shar: Extracting \"'README'\" \(1490 characters\)
  30. sed "s/^X//" >'README' <<'END_OF_FILE'
  31. XNAME: Timex
  32. XAUTHOR: Harald Tveit Alvestrand, SINTEF <harald.alvestrand@delab.sintef.no>
  33. XCOPYRIGHT: Probably.
  34. X
  35. XTimex is a very short Xt program to do a quite simple job.
  36. XIt puts up a list of projects, and the number of minutes worked on each.
  37. XYou click on the project you want to work on, and it starts counting on that.
  38. XIt's got a manpage.
  39. X
  40. XWhatever you do about it, please tell me.
  41. X
  42. XINSTALLATION
  43. X
  44. XIf you are lucky:
  45. X
  46. X1) Unshar
  47. X2) % xmkmf
  48. X3) % make
  49. X4) # make install
  50. X   (alternate for test: xrdb -merge Timex.ad)
  51. X5) % Create a directory called .timex in your homedir
  52. X6) % Edit a file called "projectlist" in the ".timex" directory
  53. X7) % timex
  54. X
  55. XIf you are unlucky, mumble.
  56. XIf you find out why you are unlucky, send me an E-mail about it.
  57. X
  58. XTested on a Sun-3 and Sun-4 running SunOS 4.0.3. X11R4 only.
  59. X
  60. XCOPYING, PAYMENT AND SUCH DETAILS
  61. X
  62. XThe origin of this program is simple: I wrote it because I needed it.
  63. XFortunately, I wrote it while working for SINTEF (which has said that
  64. Xit does not want money for it), on an UNINETT project (which has said
  65. Xthat it does not want money for it), so I am free to release it.
  66. XTell me if you like it!
  67. X
  68. XYou may copy it and modify it in any way you like, the only thing that
  69. Xcan make me mad is if you sell it for real money and do not give me some.
  70. X
  71. XAs usual, there is no guarantee about anything at all, and you are not able
  72. Xto claim that I have done any damage to you by providing you with this
  73. Xprogram; any use you make of it is entirely at your own risk.
  74. X
  75. X
  76. END_OF_FILE
  77. if test 1490 -ne `wc -c <'README'`; then
  78.     echo shar: \"'README'\" unpacked with wrong size!
  79. fi
  80. # end of 'README'
  81. fi
  82. if test -f 'Part01' -a "${1}" != "-c" ; then 
  83.   echo shar: Will not clobber existing file \"'Part01'\"
  84. else
  85. echo shar: Extracting \"'Part01'\" \(0 characters\)
  86. sed "s/^X//" >'Part01' <<'END_OF_FILE'
  87. END_OF_FILE
  88. if test 0 -ne `wc -c <'Part01'`; then
  89.     echo shar: \"'Part01'\" unpacked with wrong size!
  90. fi
  91. # end of 'Part01'
  92. fi
  93. if test -f 'TODO' -a "${1}" != "-c" ; then 
  94.   echo shar: Will not clobber existing file \"'TODO'\"
  95. else
  96. echo shar: Extracting \"'TODO'\" \(336 characters\)
  97. sed "s/^X//" >'TODO' <<'END_OF_FILE'
  98. XIdeas:
  99. X- Popup widget with scrollbar for changing hours-worked
  100. X- Sums in upper right-hand corner
  101. X- Warning when leaving edit-mode timex without saving
  102. X- Button to reread projectlist without quitting Timex
  103. X- Finding the pesky problem that makes lockfile not go away when logging out
  104. X- Finding out why the lockfile never gets any content
  105. END_OF_FILE
  106. if test 336 -ne `wc -c <'TODO'`; then
  107.     echo shar: \"'TODO'\" unpacked with wrong size!
  108. fi
  109. # end of 'TODO'
  110. fi
  111. if test -f 'Timex.ad' -a "${1}" != "-c" ; then 
  112.   echo shar: Will not clobber existing file \"'Timex.ad'\"
  113. else
  114. echo shar: Extracting \"'Timex.ad'\" \(969 characters\)
  115. sed "s/^X//" >'Timex.ad' <<'END_OF_FILE'
  116. X! TIMEX defaults
  117. X! All questions: Harald Tveit Alvestrand <harald.alvestrand@delab.sintef.no>
  118. X! General ideas:
  119. X! Buttons are square - oval did not look too good.
  120. X! *Command.shapeStyle: oval
  121. X! Labels don't have borders.
  122. X*Label.borderWidth: 0
  123. X! Most things are left-chained
  124. X*right: ChainLeft
  125. X*top: ChainTop
  126. X*bottom: ChainTop
  127. X! Forms should look a bit "tight"
  128. X*form.defaultDistance: 2
  129. X! Specific items
  130. X*form.date.horizDistance: 20
  131. X*form.date.vertDistance: 7
  132. X*form.command.orientation: horizontal
  133. X*form.command.plus.label: +
  134. X*form.command.minus.label: -
  135. X! The scrollbar
  136. X*form.scrollbar.orientation: horizontal
  137. X*form.scrollbar.length: 200
  138. X! Allow vertical resizes of the viewport
  139. X*form.viewport.allowVert: true
  140. X! Some things must be resizable
  141. X*form.viewport*bottom: ChainBottom
  142. X*form.viewport.right: ChainRight
  143. X*form.viewport.form.names.right: ChainRight
  144. X*form.viewport.top: ChainTop
  145. X*form.viewport.form.times.defaultColumns: 1
  146. X*form.viewport.form.names.defaultColumns: 1
  147. X
  148. X
  149. END_OF_FILE
  150. if test 969 -ne `wc -c <'Timex.ad'`; then
  151.     echo shar: \"'Timex.ad'\" unpacked with wrong size!
  152. fi
  153. # end of 'Timex.ad'
  154. fi
  155. if test -f 'sumtimex' -a "${1}" != "-c" ; then 
  156.   echo shar: Will not clobber existing file \"'sumtimex'\"
  157. else
  158. echo shar: Extracting \"'sumtimex'\" \(3759 characters\)
  159. sed "s/^X//" >'sumtimex' <<'END_OF_FILE'
  160. X#!/local/bin/perl
  161. X# PERL hours list writer for TIMEX
  162. X@weekdays = ("Man", "Tir", "Ons", "Tor", "Fre" ,"L|r", "S|n");
  163. Xpush(@INC, "/isolde/hta/sw/timex"); # Fudge!
  164. Xdo 'weekno.perl' || die "Could not do weekno.perl\n";
  165. X
  166. X$fudge = 0.5;  # Dividing point for ROUND. Fudgeable.
  167. X
  168. Xwhile ($ARGV[0] =~ /^-[^\d]/) {
  169. X   $option = shift(@ARGV);
  170. X   if ($option eq "-adjust") {
  171. X      $adjust = 1;
  172. X   } elsif ($option eq "-round") {
  173. X      $round = 1;
  174. X   } elsif ($option eq "-fudge") {
  175. X      $fudge = shift(@ARGV);
  176. X   } elsif ($option eq "-year") {
  177. X      $year = shift(@ARGV);
  178. X   } else {
  179. X      die "Usage: $0 [-year nn ] [-adjust] [-round] [week]\nDefault week=last week\n";
  180. X   }
  181. X}
  182. X
  183. X$week = shift(ARGV);
  184. X$timenow = time;
  185. X$oneday = 24 * 60 * 60;
  186. X@daynow = localtime($timenow);
  187. Xif (!$week) {
  188. X   # Default is last week.
  189. X   $week = &DATE'weekno($timenow) - 1;
  190. X}
  191. Xif (!$year) {
  192. X  $year = $daynow[5];
  193. X}
  194. X   
  195. X$timefetch = &DATE'firstinweek($week, $year);
  196. Xprint "Timeliste for uke $week 19$year\n";
  197. X
  198. Xfor $wday (1..7) {
  199. X   @dayfetch = localtime($timefetch);
  200. X   $weekdate[$wday] = sprintf("%d/%d", $dayfetch[3], $dayfetch[4] + 1);
  201. X   $filename = sprintf("$ENV{'HOME'}/.timex/%04d-%02d-%02d",
  202. X       1900 + $dayfetch[5], 1 + $dayfetch[4], $dayfetch[3]);
  203. X   open(FILE, $filename) || do { 
  204. X       print STDERR "No file $filename\n";
  205. X       $timefetch = $timefetch + $oneday;
  206. X       next;
  207. X   };
  208. X   while (<FILE>) {
  209. X       chop;
  210. X       if (/^\s*(\d*):(\d*) (.*)/) {
  211. X       $project = $3;
  212. X           $spent = $1 + $2 / 60;
  213. X           $worked{$project} = 1;  # Mark as worked-on this week
  214. X           $hours{"$project $wday"} = $spent;
  215. X       }
  216. X   }
  217. X   close FILE;
  218. X   $timefetch = $timefetch + $oneday;
  219. X}
  220. X
  221. X&resum;
  222. Xif ($hours == 0) {
  223. X   print STDERR "No hours worked this week!\n";
  224. X   exit 1;
  225. X}
  226. X
  227. Xif ($adjust) {
  228. X   &adjust();
  229. X}
  230. X
  231. Xif ($round) {
  232. X   &round;
  233. X}
  234. X
  235. X# Print the result
  236. X
  237. Xprintf "%-30.30s%5s!%5s%5s%5s%5s%5s%5s%5s\n",
  238. X    "Project", "TOT", @weekdays;
  239. Xprintf "%-30.30s%5s!%5s%5s%5s%5s%5s%5s%5s\n",
  240. X        "Date", "", @weekdate[1..7];
  241. Xprint "======================================================================\n";
  242. Xfor $pro (sort(keys(%hourstot))) {
  243. X   printf "%-30.30s%5.1f!", $pro, $hourstot{$pro};
  244. X   for $day (1..7) {
  245. X       if ($hours{"$pro $day"}) {
  246. X          printf "%5.1f", $hours{"$pro $day"};
  247. X       } else {
  248. X          printf "%5s", "";
  249. X       }
  250. X   }
  251. X   print "\n";
  252. X}
  253. Xprint "======================================================================\n";
  254. Xprintf "%-30.30s%5.1f!%5.1f%5.1f%5.1f%5.1f%5.1f%5.1f%5.1f\n",
  255. X    "TOTAL", $hours, @hours[1..7];
  256. X
  257. Xsub adjust {
  258. X   # Adjust - spread + projects across the board
  259. X
  260. X   for $pro (keys(%hours)) {
  261. X     if ($pro =~ /^\+/) {
  262. X        $tospread += $hours{$pro};
  263. X     }
  264. X   }
  265. X   $factor = ($tospread/($hours - $tospread)) + 1; 
  266. X   printf STDERR "Distributing %5.1f hours across %5.1f hours, factor %5.2f\n",
  267. X    $tospread, $hours, $factor;
  268. X   # 1) Distribute across projects
  269. X   for $pro (keys(%hours)) {
  270. X      if ($pro =~ /^\+/) {
  271. X         $hours{$pro} = 0;
  272. X      } else {
  273. X         $hours{$pro} *= $factor;
  274. X      }
  275. X   }
  276. X   &resum("adjust");
  277. X}
  278. X
  279. Xsub round {
  280. X# Round all numbers to half-hours
  281. X   for $pro (keys(%hours)) {
  282. X      $hours{$pro} =  int(($hours{$pro} * 2) + $fudge) / 2; 
  283. X   }
  284. X   &resum("round");
  285. X}
  286. X
  287. Xsub resum {
  288. X   local($why) = @_;
  289. X   local($oldhours) = $hours;
  290. X   undef %hourstot;
  291. X   undef @hours;
  292. X   $hours = 0;
  293. X   for $pro (keys(%hours)) {
  294. X      if ($pro =~ /(^.*) (\d)$/) {
  295. X         $project = $1; $wday = $2;
  296. X         $hourstot{$project} += $hours{$pro};
  297. X         $hours[$wday] += $hours{$pro};
  298. X         $hours += $hours{$pro};
  299. X      } else {
  300. X         print STDERR "Bad projectday: $pro\n";
  301. X      }
  302. X   }
  303. X   if ($oldhours && (($hours - $oldhours) ** 2 > 0.1)) {
  304. X      print STDERR "$why: Changed total from $oldhours to $hours\n";
  305. X   }
  306. X}
  307. X
  308. X
  309. X
  310. X
  311. X
  312. X
  313. END_OF_FILE
  314. if test 3759 -ne `wc -c <'sumtimex'`; then
  315.     echo shar: \"'sumtimex'\" unpacked with wrong size!
  316. fi
  317. chmod +x 'sumtimex'
  318. # end of 'sumtimex'
  319. fi
  320. echo shar: End of archive 1 \(of 2\).
  321. cp /dev/null ark1isdone
  322. MISSING=""
  323. for I in 1 2 ; do
  324.     if test ! -f ark${I}isdone ; then
  325.     MISSING="${MISSING} ${I}"
  326.     fi
  327. done
  328. if test "${MISSING}" = "" ; then
  329.     echo You have unpacked both archives.
  330.     rm -f ark[1-9]isdone
  331. else
  332.     echo You still need to unpack the following archives:
  333.     echo "        " ${MISSING}
  334. fi
  335. ##  End of shell archive.
  336. exit 0
  337. -- 
  338. --
  339. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  340. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  341. Sunnyvale, California 94086            at&t: 408/522-9236
  342.