From root@alcoholix.wu-wien.ac.at  Sat Mar 19 08:25:37 2005
Return-Path: <root@alcoholix.wu-wien.ac.at>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A00D316A4CF
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 19 Mar 2005 08:25:37 +0000 (GMT)
Received: from alcoholix.wu-wien.ac.at (alcoholix.wu-wien.ac.at [137.208.3.67])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D3B9943D1D
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 19 Mar 2005 08:25:36 +0000 (GMT)
	(envelope-from root@alcoholix.wu-wien.ac.at)
Received: from alcoholix.wu-wien.ac.at (localhost.wu-wien.ac.at [127.0.0.1])
	by alcoholix.wu-wien.ac.at (8.13.1/8.13.1) with ESMTP id j2J8OUXM060031;
	Sat, 19 Mar 2005 09:24:30 +0100 (CET)
	(envelope-from root@alcoholix.wu-wien.ac.at)
Received: (from root@localhost)
	by alcoholix.wu-wien.ac.at (8.13.1/8.13.1/Submit) id j2J8OUDb060030;
	Sat, 19 Mar 2005 09:24:30 +0100 (CET)
	(envelope-from root)
Message-Id: <200503190824.j2J8OUDb060030@alcoholix.wu-wien.ac.at>
Date: Sat, 19 Mar 2005 09:24:30 +0100 (CET)
From: Gerhard Gonter <g.gonter@ieee.org>
Reply-To: Gerhard Gonter <g.gonter@ieee.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Gerhard Gonter <g.gonter@ieee.org>
Subject: add option for pom to specify EPOCH
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         79008
>Category:       bin
>Synopsis:       [patch] add option for pom(6) to specify EPOCH
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    edwin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 19 08:30:02 GMT 2005
>Closed-Date:    Tue May 04 08:07:18 UTC 2010
>Last-Modified:  Tue May  4 08:10:03 UTC 2010
>Originator:     Gerhard Gonter
>Release:        FreeBSD 5.3-STABLE i386
>Organization:
none
>Environment:
System: FreeBSD alcoholix.wu-wien.ac.at 5.3-STABLE FreeBSD 5.3-STABLE #0: Sun Dec 26 12:56:10 CET 2004 root@alcoholix.wu-wien.ac.at:/usr/obj/usr/src/sys/GENERIC i386
Architecture: i386

>Description:

	The pom command only displays the output for the current
	time.  This submit allows the user to supply a different
	time expressed in EPOCH to obtain results for that time.

>How-To-Repeat:

>Fix:

diff -ruN pom.orig/pom.6 pom/pom.6
--- pom.orig/pom.6	Sun Jul 15 09:49:21 2001
+++ pom/pom.6	Sun Nov 28 22:02:07 2004
@@ -44,3 +44,16 @@
 utility displays the current phase of the moon.
 Useful for selecting software completion target dates and predicting
 managerial behavior.
+.PP
+.\" FIX ME!  This should look slightly different!
+The options are as follows:
+.BL -tag -width indent
+.PP
+.I \-r seconds
+.PP
+display phase of moon for the given time (in EPOCH).  This is usefull
+to explain past or predict future managerial behavior.
+.SH HISTORY    
+The
+.I pom
+command was derived from software posted to USENET.
diff -ruN pom.orig/pom.c pom/pom.c
--- pom.orig/pom.c	Mon May  5 11:52:25 2003
+++ pom/pom.c	Sun Nov 28 10:03:21 2004
@@ -60,6 +60,8 @@
 #include <time.h>
 #include <stdio.h>
 #include <math.h>
+#include <stdlib.h>
+#include <string.h>
 
 #ifndef	PI
 #define	PI	  3.14159265358979323846
@@ -76,16 +78,32 @@
 static void	adj360(double *);
 static double	dtor(double);
 static double	potm(double);
+int main_pom (time_t);
 
-int
-main()
+#ifndef NO_MAIN
+int main (argc, argv)
+  int argc;
+  char *argv[];
 {
 	time_t tt;
+	(void) time(&tt);
+
+	if (argc > 2 && strcmp (argv [1], "-r") == 0)
+          tt= atol (argv[2]);
+
+	return main_pom (tt);
+
+}
+#endif /* NO_MAIN */
+
+int
+main_pom(tt)
+  time_t tt;
+{
 	struct tm *GMT;
 	double days, today, tomorrow;
 	int cnt;
 
-	(void) time(&tt);
 	GMT = gmtime(&tt);
 	days = (GMT->tm_yday + 1) + ((GMT->tm_hour +
 	    (GMT->tm_min / 60.0) + (GMT->tm_sec / 3600.0)) / 24.0);

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->edwin 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Wed Aug 13 01:16:52 UTC 2008 
Responsible-Changed-Why:  
Handle with mentor. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=79008 
State-Changed-From-To: open->closed 
State-Changed-By: edwin 
State-Changed-When: Tue May 4 08:07:01 UTC 2010 
State-Changed-Why:  
Something similar commited to head and stable/8 

http://www.freebsd.org/cgi/query-pr.cgi?pr=79008 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/79008: commit references a PR
Date: Tue,  4 May 2010 08:07:04 +0000 (UTC)

 Author: edwin
 Date: Tue May  4 08:06:53 2010
 New Revision: 207609
 URL: http://svn.freebsd.org/changeset/base/207609
 
 Log:
   MFC of r201613, r201627
   
   Be able to specify a certain date and/or time for which to calculate
   the phase of the moon.
   While not worlds best improvements, it will help calendar(1) later on.
   
   Also closed bin/79008
   
   PR:		bin/79008
 
 Modified:
   stable/8/games/pom/pom.6
   stable/8/games/pom/pom.c
 Directory Properties:
   stable/8/games/pom/   (props changed)
 
 Modified: stable/8/games/pom/pom.6
 ==============================================================================
 --- stable/8/games/pom/pom.6	Tue May  4 06:19:19 2010	(r207608)
 +++ stable/8/games/pom/pom.6	Tue May  4 08:06:53 2010	(r207609)
 @@ -32,15 +32,34 @@
  .\"	@(#)pom.6	8.1 (Berkeley) 5/31/93
  .\" $FreeBSD$
  .\"
 -.TH POM 6 "May 31, 1993"
 +.Dd May 31, 1993
 +.Dt POM 6
  .UC 7
 -.SH NAME
 -pom \- display the phase of the moon
 -.SH SYNOPSIS
 -.B pom
 -.SH DESCRIPTION
 +.Sh NAME
 +.Nm pom
 +.Nd display the phase of the moon
 +.Sh SYNOPSIS
 +.Nm 
 +.Op Fl d Ar yyyy.mm.dd
 +.Op Fl t Ar hh:mm:ss
 +.Sh DESCRIPTION
  The
 -.I pom
 +.Nm
  utility displays the current phase of the moon.
  Useful for selecting software completion target dates and predicting
  managerial behavior.
 +.Pp
 +Use the arguments
 +.Fl d
 +and
 +.Fl o
 +to specify a specific date and time for which the phase of the moon
 +has to be calculated.
 +If
 +.Fl d
 +but not
 +.Fl t
 +has been specified, it will calculate the phase of the moon on that
 +day at midnight.
 +.Sh SEE ALSO
 +`Practical Astronomy with Your Calculator' by Duffett-Smith.
 
 Modified: stable/8/games/pom/pom.c
 ==============================================================================
 --- stable/8/games/pom/pom.c	Tue May  4 06:19:19 2010	(r207608)
 +++ stable/8/games/pom/pom.c	Tue May  4 08:06:53 2010	(r207609)
 @@ -57,9 +57,13 @@ __FBSDID("$FreeBSD$");
   *
   */
  
 -#include <time.h>
  #include <stdio.h>
 +#include <stdlib.h>
  #include <math.h>
 +#include <string.h>
 +#include <sysexits.h>
 +#include <time.h>
 +#include <unistd.h> 
  
  #ifndef	PI
  #define	PI	  3.14159265358979323846
 @@ -76,20 +80,62 @@ __FBSDID("$FreeBSD$");
  static void	adj360(double *);
  static double	dtor(double);
  static double	potm(double);
 +static void	usage(char *progname);
  
  int
 -main(void)
 +main(int argc, char **argv)
  {
  	time_t tt;
 -	struct tm *GMT;
 +	struct tm GMT, tmd;
  	double days, today, tomorrow;
 -	int cnt;
 +	int ch, cnt;
 +	char *odate = NULL, *otime = NULL;
 +
 +	while ((ch = getopt(argc, argv, "d:t:")) != -1)
 +		switch (ch) {
 +		case 'd':
 +			odate = optarg;
 +			break;
 +		case 't':
 +			otime = optarg;
 +			break;
 +		default:
 +			usage(argv[0]);
 +		}
 +
 +        argc -= optind;
 +	argv += optind;
 +
 +	if (argc)
 +		usage(argv[0]);
  
 -	(void) time(&tt);
 -	GMT = gmtime(&tt);
 -	days = (GMT->tm_yday + 1) + ((GMT->tm_hour +
 -	    (GMT->tm_min / 60.0) + (GMT->tm_sec / 3600.0)) / 24.0);
 -	for (cnt = EPOCH; cnt < GMT->tm_year; ++cnt)
 +	/* Adjust based on users preferences */
 +	time(&tt);
 +	if (otime != NULL || odate != NULL) {
 +		/* Save today in case -d isn't specified */
 +		localtime_r(&tt, &tmd);
 +
 +		if (odate != NULL) {
 +			tmd.tm_year = strtol(odate, NULL, 10) - 1900;
 +			tmd.tm_mon = strtol(odate + 5, NULL, 10) - 1;
 +			tmd.tm_mday = strtol(odate + 8, NULL, 10);
 +			/* Use midnight as the middle of the night */
 +			tmd.tm_hour = 0;
 +			tmd.tm_min = 0;
 +			tmd.tm_sec = 0;
 +		}
 +		if (otime != NULL) {
 +			tmd.tm_hour = strtol(otime, NULL, 10);
 +			tmd.tm_min = strtol(otime + 3, NULL, 10);
 +			tmd.tm_sec = strtol(otime + 6, NULL, 10);
 +		}
 +		tt = mktime(&tmd);
 +	}
 +
 +	gmtime_r(&tt, &GMT);
 +	days = (GMT.tm_yday + 1) + ((GMT.tm_hour +
 +	    (GMT.tm_min / 60.0) + (GMT.tm_sec / 3600.0)) / 24.0);
 +	for (cnt = EPOCH; cnt < GMT.tm_year; ++cnt)
  		days += isleap(1900 + cnt) ? 366 : 365;
  	today = potm(days) + .5;
  	(void)printf("The Moon is ");
 @@ -160,6 +206,7 @@ potm(double days)
  static double
  dtor(double deg)
  {
 +
  	return(deg * PI / 180);
  }
  
 @@ -170,6 +217,7 @@ dtor(double deg)
  static void
  adj360(double *deg)
  {
 +
  	for (;;)
  		if (*deg < 0)
  			*deg += 360;
 @@ -178,3 +226,11 @@ adj360(double *deg)
  		else
  			break;
  }
 +
 +static void
 +usage(char *progname)
 +{
 +
 +	fprintf(stderr, "Usage: %s [-d yyyy.mm.dd] [-t hh:mm:ss]\n", progname);
 +	exit(EX_USAGE);
 +}
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
