[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] mktime not working?



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 12:00 PM -0700 8/19/98, Jonathan Hurshman wrote:

}
} Does anyone have any idea what's causing this? It's really a pain.
} I've tried reinstalling MacPerl 5.20r4, but that didn't change anything.

It's because the number returned by mktime is an integer > 2^31, and you
have to convince Perl not to treat it as a signed integer.  If it gets
interpred a signed integer, it's negative, and localtime goes back as far
as it can, the Mac zero of time.  The following slight change to your
script makes it work:

use POSIX;

$CalMonth = 8;
$CalYear = 1998;

($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime();
print "$sec, $min, $hour, $mday, $month, $year, $wday, $yday, $isdst\n";
($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) =
localtime(mktime (0, 0, 12, 1, $CalMonth - 1, $CalYear - 1900, '' , ''
, -1) | 0);  #note the | 0, which forces Perl to treat the answer as unsigned

print "$sec, $min, $hour, $mday, $month, $year, $wday, $yday, $isdst\n";

}
} Thanks!
}
} - Jonathan
}
} ===
} +----------------------------------->
} + Jonathan Hurshman
} + http://home.att.net/~J-M.Hurshman/
} +----------------------------------->
} _________________________________________________________
} DO YOU YAHOO!?
} Get your free @yahoo.com address at http://mail.yahoo.com


- -----
Paul J. Schinder
schinder@pobox.com

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBNdtZ7FZaVc52j0XhEQLVgwCgwFNf0J+CKGuWxuJv5JOYCJVhrsoAniOa
y9H7NgbcUqis4QD4dzW53Tcy
=WPXY
-----END PGP SIGNATURE-----

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch