Skip to content

Commit aa949d7

Browse files
authored
correct current month value
* When running cal with no arguments the month number is determined from localtime(), which returns 0 for Jan * Function fmt_month() needs 1 for Jan, so adjust the value passed in * Patch tested on Linux * test1: perl cal 0 2025 ---> invalid month * test2: perl cal ---> now shows current month (5) * test3: perl cal 5 2025 ---> same output as test2
1 parent 60b6a3d commit aa949d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bin/cal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $cal::num_args = scalar( @ARGV );
2828
if( $cal::num_args == 0 ) {
2929
my @tm = localtime(time);
3030
$cal::year = $tm[5] + 1900;
31-
$cal::month = $tm[4] unless $opts{'y'};
31+
$cal::month = $tm[4] + 1 unless $opts{'y'};
3232
} elsif( $cal::num_args == 1 ) {
3333
$cal::year = &get_year( $ARGV[ 0 ] );
3434
} elsif( $cal::num_args == 2 ) {

0 commit comments

Comments
 (0)