[comp.bugs.4bsd] bug in cal

dce@mips.UUCP (David Elliott) (01/18/87)

In article <21173@styx.UUCP> carlson@styx.UUCP (John Carlson) writes:
>Here's a calendar not to use:
>
>% /usr/bin/cal 1 87
>   January 87
...

Well folks, I guess it's time to add code to cal to make it work
like this for all 2-digit year specifications:

	% cal 1 87
	January 87
	(NOTE: This is the year 87A.D., not the 87th year of your current
	 century)
	 ...

I guess we'd also need a -f option to say "I know what I'm doing, so don't
give me that line about what year you are giving me the calendar for".
-- 
			David Elliott

UUCP: 	{decvax,ucbvax,ihnp4}!decwrl!mips!dce, DDD:  	408-720-1700

jordan@ucbarpa.Berkeley.EDU.UUCP (01/19/87)

John Carlson <carlson@styx.UUCP> writes before thinking:

	Here's a calendar not to use:

	% /usr/bin/cal 1 87
	   January 87
	 S  M Tu  W Th  F  S
	    1  2  3  4  5  6
	 7  8  9 10 11 12 13
	14 15 16 17 18 19 20
	21 22 23 24 25 26 27
	28 29 30 31

Hmmm.  That looks okay, but if you were looking for, say, January
of *this* year, this might be more appropriate:

% /usr/bin/cal 1 1987
   January 1987
 S  M Tu  W Th  F  S
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

/jordan

guy@gorodish.UUCP (01/19/87)

	> Here's a calendar not to use:
	> 
	> % /usr/bin/cal 1 87
	>    January 87
	>  S  M Tu  W Th  F  S
	>     1  2  3  4  5  6
	>  7  8  9 10 11 12 13
	> 14 15 16 17 18 19 20
	> 21 22 23 24 25 26 27
	> 28 29 30 31

Is that not the correct calendar for January in the year 87 A.D.?  What
should the calendar for that year be?

gordon@cae780.UUCP (Brian Gordon) (01/19/87)

In article <21173@styx.UUCP> carlson@styx.UUCP (John Carlson) writes:
>Here's a calendar not to use:
>
>% /usr/bin/cal 1 87
>   January 87
> S  M Tu  W Th  F  S
>    1  2  3  4  5  6
>	[...]

Why not, if you want a calendar from that far (~1900 years ago) back?  A more
recent one is '% /usr/bin/cal 1 1987'

FROM:   Brian G. Gordon, CAE Systems Division of Tektronix, Inc.
UUCP:   tektronix!cae780!gordon [or gordon@cae780.CAE.TEK.COM]

oster@lapis.berkeley.edu (David Phillip Oster) (01/20/87)

Cal is documented to behave this way. Read your man page!  By the way,
it is an interesting question what cal should do if you ask for a year
before 1752. Different calendars were adopted in different places at
different times. I have a few references about the early calendar see:

Knuth, Art of Computer Programming, Vol 1., p .155
See CACM, 5 (1962) p. 209 - 210 for Easter < 1582
see also, Puzzles and Paradoxes, T. H. O'Beirne 
London:Oxford U. Press, 1965, Chap. 10

Anybody have any good references for early calendars?

devine@vianet.UUCP (Bob Devine) (01/20/87)

>  "Bug" with cal(1) giving calendar info for year 87 instead of 1987.

In article <11624@sun.uucp>, guy%gorodish@Sun.COM (Guy Harris) writes:
> Is that not the correct calendar for January in the year 87 A.D.?  What
> should the calendar for that year be?

  It depends.  There is historical evidence showing that the Celtic
calendar had 8-day weeks.  That is despite what 'cal' says about the
output only being good for the UK and its colonies, if you go back that
far in history dates get hard to deal with.  The Emporor Constantine created
the 7-day week by fiat in about the 4th century AD (if I remember right).

Bob Devine

rbutterworth@watmath.UUCP (Ray Butterworth) (01/20/87)

In article <125@vianet.UUCP>, devine@vianet.UUCP (Bob Devine) writes:
> ...  The Emporor Constantine created
> the 7-day week by fiat in about the 4th century AD (if I remember right).

Gee.  I thought God created the 7-day week in about the 40th century BC.
"Fiat Lux" and all that.  (Or at least there are existing texts written
long before the 4th century AD referring to the event.)

carlson@styx.UUCP (John Carlson) (01/21/87)

Well, I hoped it wouldn't cause too much of a stir, but it looks
like people are having fun with it.  I typed 'C' in 'rn' on my
machine about 3 minutes after posting the orginal article, but
I must not have caught it in time.  Have fun!

John Carlson

amos@instable.UUCP (Amos Shapir) (01/21/87)

Proposed changes to cal in the next edition:
- Add a -j flag to do Julian, rather than the standard Gregorian calendar;
 possibly make it default before 1582.
- if y<100 add 1900 unless -j is on. (or something more sophisticated
if you dont want to re-fix it in 13 years).

I'd rather make it useful for everyday use, rather than precise, especially
when the extra precision is wrong - as has been pointed out, the 1st century
dates computed by cal are not exactly what the Romans had used, and thus are
useless even for historians. (Please keep the historical calendar discussion
to rec.history)
-- 
	Amos Shapir
National Semiconductor (Israel)
6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel
(011-972) 52-522261  amos%nsta@nsc 34.48'E 32.10'N

devine@vianet.UUCP (Bob Devine) (01/21/87)

In article <2265@jade.BERKELEY.EDU>, oster@lapis.berkeley.edu (David Phillip Oster) writes:
> By the way,
> it is an interesting question what cal should do if you ask for a year
> before 1752. Different calendars were adopted in different places at
> different times. 
> 
> Anybody have any good references for early calendars?

  Now that mod.sources has started to spout forth articles again,
you can check for my submission that deals with early calendars
from different countries.

Bob Devine

devine@vianet.UUCP (Bob Devine) (01/22/87)

> In article <125@vianet.UUCP>, devine@vianet.UUCP (Bob Devine) writes:
> > ...  The Emporor Constantine created
> > the 7-day week by fiat in about the 4th century AD.

In article <4521@watmath.UUCP>, rbutterworth@watmath.UUCP (Ray Butterworth) writes:
> Gee.  I thought God created the 7-day week in about the 40th century BC.

  What happened is that Constantine converted to Christianity and
ordered that everyone under his dominion use the 7 day week.  The
Catholic church used 7 days cuz the Jews did cuz Moses set up that
convention when he left Egypt cuz it was used there cuz the 
Babylonians did (Egyptians used 10 days) cuz ...

Bob Devine

mcdaniel@uicsrd.UUCP (01/23/87)

>   It depends.  There is historical evidence showing that the Celtic
> calendar had 8-day weeks.  That is despite what 'cal' says about the
> output only being good for the UK and its colonies, if you go back that
> far in history dates get hard to deal with.
> Bob Devine

But "the UK" means "the United Kingdom [of Great Britain and Northern
Ireland]".  I'm not sure when the UK, as a political title and entity,
was created.  It was surely not earlier than the accession to the
throne of England of King James the 6th of Scotland, who became King
James the 1st of England, the first Stewart King of England.  Since
this was about 1603, the "cal" man page is correct on that point.

     :-)

(P. S.  Anybody know the exact date and manner of the UK's formation?
How about Great Britain?  Mail me, please.)

--
Tim McDaniel; CSRD at the Silicon Prairie
(Center for Supercomputing Research and Development
at the University of Illinois at Urbana-Champaign)

UUCP:	 {ihnp4,seismo,pur-ee,convex}!uiucdcs!uicsrd!mcdaniel
ARPANET: mcdaniel%uicsrd@a.cs.uiuc.edu
CSNET:	 mcdaniel%uicsrd@uiuc.csnet
BITNET:	 mcdaniel@uicsrd.csrd.uiuc.edu

evp@lewey.AIT.COM (Ed Post) (01/24/87)

 In article <21173@styx.UUCP> carlson@styx.UUCP (John Carlson) writes:
>Here's a calendar not to use:
>
>% /usr/bin/cal 1 87
>   January 87
> ...


I've posted (to net.sources) a version of cal that (among other things)
folds the years 13 thru 99 into the twentieth century. I never had much
need for calendars in the first century anyway.
-- 
Ed Post -- hplabs!lewey!evp
American Information Technology    (408)252-8713

ed@mtxinu.UUCP (01/30/87)

>> That is despite what 'cal' says about the
>> output only being good for the UK and its colonies, if you go back that
>> far in history dates get hard to deal with.
>
>But "the UK" means "the United Kingdom [of Great Britain and Northern
>Ireland]".  I'm not sure when the UK, as a political title and entity,
>was created.

The man page for cal - on 4.3 BSD and as far back as I can remember -
says "for England and her colonies," not for the UK.

Nonetheless, I find difficult to accept the notion that the well-documented
behavior of a program is a bug.  Perhaps it is badly designed, but
it is not wrong.  (There may well be a bug in the output cal produces for
years before 1752, but this is not what the original poster cited.)

-- 
Ed Gould                    mt Xinu, 2560 Ninth St., Berkeley, CA  94710  USA
{ucbvax,decvax}!mtxinu!ed   +1 415 644 0146

"A man of quality is not threatened by a woman of equality."

craigb@ipso.OZ (Craig Bevins) (03/15/87)

In article <143@quacky.mips.UUCP> dce@quacky.UUCP (David Elliott) writes:

>   Well folks, I guess it's time to add code to cal ...
>   	 ...
>   I guess we'd also need a -f option to say "I know what I'm doing, so don't
>   give me that line about what year you are giving me the calendar for".

Hear, hear.  Or you could use this script that I've had floating around
for yonks.  Can't remember where it came from ...


# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by craigb@ipso.OZ on Sun Mar 15 16:03:18 AEST 1987
# Contents:  cal
 
echo x - cal.sh
sed 's/^@//' > "cal.sh" <<'@//E*O*F cal.sh//'

# cal: nicer interface to /usr/bin/cal

echo

case $# in
	0)	set `date`; m=$2; y=$6;;	# no args - use today
	1)	m=$1; set `date`; y=$6;;	# 1 arg - use this year
	*)	m=$1; y=$2;;			# 2 args - month and year
esac

case $m in
	ja*|Ja*)	m=1;;
	f*|F*)		m=2;;
	mar*|Mar*)	m=3;;
	ap*|Ap*)	m=4;;
	may*|May*)	m=5;;
	jun*|Jun*)	m=6;;
	jul*|Jul*)	m=7;;
	au*|Au*)	m=8;;
	s*|S*)		m=9;;
	o*|O*)		m=10;;
	n*|N*)		m=11;;
	d*|D*)		m=12;;
	[1-9]|10|11|12)	;;		# numeric month
	*)		y=$m; m="";;	# plain year
esac

/usr/bin/cal $m $y			# run the real one

@//E*O*F cal.sh//
chmod u=rwx,g=rx,o=rx cal.sh
 
exit 0
-- 

Craig Bevins.
IPS Radio and Space Services.  Sydney, Australia.

ACSnet: craigb@ipso			CSNET:	craigb@ipso.oz
ARPA:	craigb%ipso.oz@seismo.css.gov	JANET:  ipso.oz!craigb@ukc
UUCP:	{enea,hplabs,mcvax,prlb2,seismo,ubc-vision,ukc}!munnari!ipso.oz!craigb

rbutterworth@watmath.UUCP (03/17/87)

Rather than messing with the input to cal, the problem with "cal 87"
could probably be solved, or at least made more obvious, if the output
was changed so that instead of displaying the year as "1987" or "87"
it displayed it as "1987 AD" or "87 AD".  It is very unlikely that
anyone would bother to add "AD" to a date and then abbreviate the
century away.

Then anyone requesting "cal 87" will get the "87 AD" and will probably
realize what he did wrong.