Pigheadedness (was Re: Newbie; Perl/Tk Event models)
Author Message
Pigheadedness (was Re: Newbie; Perl/Tk Event models)

Quote:

> : my \$update = sub {

> : (\$sec,\$min,\$hour,\$mday,\$mon,\$year,\$wday,\$yday,\$isdst) = localtime(time);
> : \$day=(Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday)[\$wday];
> : \$month=(January,February,March,April,May,June,July,August,September,
> :  October,November,December)[\$mon];

Barewords galore!

Quote:
> : \$century = \$year - 99 ? 20 : 19;
> : \$string = sprintf <<"eop", \$year, \$hour, \$min, \$sec;
> : It is \$day, \$month \$mday, \$century%02d %02d:%02d:%02d
> : eop

> : };

> It is obvious that the person who wrote this code read the documentation
> for localtime(), as he's obviously learned that the year field will
> contain a value greater than 99 in the next century.  But why didn't he
> make the obvious connection and simply add 1900 to the year rather than
> trying to simulate a fortran arithmetic IF statement?  I can only guess
> that he had a presupposition that century-handling *had* to be more
> complex than it really is, and dutifully wrote needlessly complicated code.

Needlessly complicated and remarkably wrong!  The years that code would
report are 2097 2098 1999 20100 20101 .

That godforsaken code *could* be:

\$century = \$year > 99 ? 20 : 19;
\$string = sprintf <<"eop", \$year % 100, \$hour, \$min, \$sec;
It is \$day, \$month \$mday, \$century%02d %02d:%02d:%02d
eop

And we all know what it *should* be.

--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.*-*-*.com/

Fri, 09 Nov 2001 03:00:00 GMT
Pigheadedness (was Re: Newbie; Perl/Tk Event models)
: my \$update = sub {

: (\$sec,\$min,\$hour,\$mday,\$mon,\$year,\$wday,\$yday,\$isdst) = localtime(time);
: \$day=(Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday)[\$wday];
: \$month=(January,February,March,April,May,June,July,August,September,
:       October,November,December)[\$mon];

: \$century = \$year - 99 ? 20 : 19;
: \$string = sprintf <<"eop", \$year, \$hour, \$min, \$sec;
: It is \$day, \$month \$mday, \$century%02d %02d:%02d:%02d
: eop

: };

It is obvious that the person who wrote this code read the documentation
for localtime(), as he's obviously learned that the year field will
contain a value greater than 99 in the next century.  But why didn't he
make the obvious connection and simply add 1900 to the year rather than
trying to simulate a Fortran arithmetic IF statement?  I can only guess
complex than it really is, and dutifully wrote needlessly complicated code.

Sat, 10 Nov 2001 03:00:00 GMT
Pigheadedness (was Re: Newbie; Perl/Tk Event models)

Quote:

> That godforsaken code *could* be:

>     \$century = \$year > 99 ? 20 : 19;
>     \$string = sprintf <<"eop", \$year % 100, \$hour, \$min, \$sec;
>     It is \$day, \$month \$mday, \$century%02d %02d:%02d:%02d
>     eop

> And we all know what it *should* be.

Definitely starting to fall into the

"How hard can we possibly make things?"

Category...
-Sneex-  :]
______________________________________________________________________
Bill Jones  Data Security Specialist  http://www.fccj.org/cgi/mail?dss
______________________________________________________________________
...Resistance is futile...

Jacksonville Perl Mongers
http://jacksonville.pm.org

Sat, 10 Nov 2001 03:00:00 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages