On 2009-Dec-13 16:27:41 +0000, "Dr. David Kirkby" <[email protected]> wrote: >If you have a system with the GNU version of date, then > >date -u +%s > >will give the seconds since the Epoch. Unfortunately, it only works with GNU >date, and so will not work on Solaris, HP-UX or no doubt many other Unix >systems.
FWIW, '%s' _does_ work with FreeBSD. >For every system I am able to check this on, the following script >gives exactly the same output as the GNU date command, but in a more >portable manner. It works on FreeBSD/amd64 and FreeBSD/i386. It probably needs some more rigorous checking than "it works today". Where did you find this particular algorithm - it's somewhat simpler than the one I use. ># $5 = seconds (0-59) Whilst we're being pedantic, this should be (0..60) to allow for leap seconds. On 2009-Dec-13 17:05:25 +0000, "Dr. David Kirkby" <[email protected]> wrote: >The code takes leap years into account, and is said to work until >2100, in which case, we will all be dead. (or 2034 unless unix time >is changed to a 64-bit number). A few comments: - The 32-bit Unix epoch rolls over in 2038. - This also depends on the type expr(1) uses for integer math. - I wouldn't bet on everyone currently working on Sage being dead in 2100: If you're in your early 20's now, you'll be less that 115 then - which is not impossible today and will only become more common in future (assuming advances in medical science continue and aren't offset by a worsening environment). -- Peter Jeremy
pgp7U3Zu8wcFY.pgp
Description: PGP signature
