From andrew@chi.coffs.key.net.au  Mon Dec 29 15:51:01 1997
Received: from chi.coffs.key.net.au (root@chi.coffs.key.net.au [203.35.4.17])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id PAA25202
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 Dec 1997 15:50:55 -0800 (PST)
          (envelope-from andrew@chi.coffs.key.net.au)
Received: (from andrew@localhost)
	by chi.coffs.key.net.au (8.8.8/8.8.8) id KAA02390;
	Tue, 30 Dec 1997 10:38:50 +1100 (EST)
	(envelope-from andrew)
Message-Id: <199712292338.KAA02390@chi.coffs.key.net.au>
Date: Tue, 30 Dec 1997 10:38:50 +1100 (EST)
From: Andrew <andrew@ugh.net.au>
Reply-To: andrew@ugh.net.au
To: FreeBSD-gnats-submit@freebsd.org
Subject: leave(1) wont accept 0145 as an argument
X-Send-Pr-Version: 3.2

>Number:         5395
>Category:       bin
>Synopsis:       leave(1) wont accept 0145 as an argument
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 29 16:00:01 PST 1997
>Closed-Date:    Tue Jan 6 09:27:39 PST 1998
>Last-Modified:  Tue Jan  6 09:30:33 PST 1998
>Originator:     Andrew
>Release:        FreeBSD 2.2.5-STABLE i386
>Organization:
UgH!
>Environment:

	

>Description:

I may have just misunderstood the man page but...

The man page for leave(1) says you can specify all times in either 24
or 12 hour time and they are assumed to be in the next 12 hours.

However...

leave will not accept 0145 (ie 1.45 am) as an argument (time is
currently 22xx). It runs into problems at leave.c:108
(As 01 is < t->tm_hour). This argument should be accepted however
as it is within 12 hours.

It also appears as though I should be able to specify 1345 and still
mean 0145 (as the man page states all times are converted to 12 hour
time and then assumed to be in the next 12 hours).

>How-To-Repeat:

set time to after 1345

/usr/bin/leave 0145

>Fix:
	
I think this should work...it allowed me to set the alarm at 0145 anyway :-)

*** leave.c.orig	Tue Dec 30 10:14:29 1997
--- leave.c	Tue Dec 30 01:33:41 1997
***************
*** 71,77 ****
  	register char c, *cp;
  	struct tm *t, *localtime();
  	time_t now, time();
! 	int plusnow;
  	char buf[50];
  
  	if (argc < 2) {
--- 71,77 ----
  	register char c, *cp;
  	struct tm *t, *localtime();
  	time_t now, time();
! 	int plusnow, t_12_hour;
  	char buf[50];
  
  	if (argc < 2) {
***************
*** 105,114 ****
  	if (plusnow)
  		secs = hours * 60 * 60 + minutes * 60;
  	else {
! 		if (hours > 23 || t->tm_hour > hours ||
! 		    (t->tm_hour == hours && minutes <= t->tm_min))
  			usage();
! 		secs = (hours - t->tm_hour) * 60 * 60;
  		secs += (minutes - t->tm_min) * 60;
  	}
  	doalarm(secs);
--- 105,133 ----
  	if (plusnow)
  		secs = hours * 60 * 60 + minutes * 60;
  	else {
! 		if (hours > 23) {
  			usage();
! 		}
! 
! 		/* Convert tol to 12 hr time (0:00...11:59) */
! 		if (hours > 11) {
! 			hours -= 12;
! 		}
! 
! 		/* Convert tm to 12 hr time (0:00...11:59) */
! 		if (t->tm_hour > 11) {
! 			t_12_hour = t->tm_hour - 12;
! 		} else {
! 			t_12_hour = t->tm_hour;
! 		}
! 
! 		if ( (hours < t_12_hour) ||
! 				((hours == t_12_hour) && (minutes <= t->tm_min)) ) {
! 			/* Leave time is in the past so we add 12 hrs */
! 			hours += 12;
! 		}
! 
! 		secs = (hours - t_12_hour) * 60 * 60;
  		secs += (minutes - t->tm_min) * 60;
  	}
  	doalarm(secs);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: helbig 
State-Changed-When: Tue Jan 6 09:27:39 PST 1998 
State-Changed-Why:  
Suggested fix (with style(9) changes) applied, thanks Andrew. 
>Unformatted:
