Raise a Glass — Time(2) Turns 40 Tonight 114
ddt writes "Raise your glasses of champagne in a toast at midnight. The time(2) system call turns 40 tonight, and is now officially 'over the hill.' It's been dutifully keeping track of time for clueful operating systems since January 1, 1970." And speaking of time, if you don't have a *nix system handy, or just want a second opinion, an anonymous reader points out this handy way to check just how far it is after local midnight in Unix time. Updated 10:03 GMT by timothy: The Unix-time-in-a-browser link has been replaced by a Rick Astley video; you have been warned.
Give it 28 years (Score:5, Insightful)
Re: (Score:2, Interesting)
Re: (Score:3, Interesting)
Especially when the 32-bit time_t overflows. The good news is that most 64-bit OSes already uses a 64-bit time_t, but there still is the issue of truncation to 32-bit.
Shouldn't the 32 bit time_t expire in 2106 [wolframalpha.com]?
Re: (Score:2, Informative)
Re: (Score:3, Interesting)
'fraid not. The 32-bit time_t is signed (I'm assuming so you can expression times less than the epoch, but that's just a guess). As such, it actually overflows in 2038 [wolframalpha.com].
Re:Give it 28 years (Score:4, Informative)
Indeed.
Some binary blobs do require the use of a signed integer for calculating differences in time which is much of the apparent hesitancy to convert to a 32 bit unsigned integer time system. More here. [wikipedia.org]
Re: (Score:2)
Apparently, at least some implementations define time_t as a signed integer. [wolframalpha.com]
Re:Give it 28 years (Score:5, Informative)
Nope, the maximum value for 32-bit time_t is 2147483647. Increment that by 1, and the time_t value becomes -2147483648.
Although time_t is a 32-bit value, the 1st bit is the sign bit.
Jan 18 21:14:07, 2038
For 64-bit time_t it should be 9223372036854775807. But I don't believe the standard time functions can handle this value...
While it may be a perfectly valid 64-bit time_t value, if gmtime/localtime/strftime/ctime don't work with the maximum value, it's not a usable value, really
Re: (Score:1, Informative)
Although time_t is a 32-bit value, the 1st bit is the sign bit.
The 1st bit is not a sign bit! Signed integer coding uses two's complement arithmetic [wikipedia.org].
Re: (Score:1)
It doesn't matter that 2's complement is the encoding format used to represent a negative number on certain architectures, or if sign magnitude encoding is used, the MSB is still called a sign bit, if a "1" in that position indicates negative numbers regardless of the encoding format represented by the other bits.
Re: (Score:1)
I'm not disagreeing with you about shooting implementors, necessarily.
But I actually tried using the time functions on 64-bit Linux, Redhat Enterprise Linux 5.4 64-bit.
Some 64-bit values seemed to work, others did not. ex:
# perl -e 'printf "[%d]\n", int(1099511627776)'
[1099511627776]
# perl -e 'use POSIX "ctime"; printf "[%s]\n", ctime(int(1099511627776))'
[]
# perl -e 'use POSIX "ctime"; printf "[%s]\n", ctime(int(2147483648))'
[Mon Jan 18 21:14:08 2038
]
Re: (Score:1)
So when people say "32-bit time_t", what they actually mean is "the effectively 31-bit time_t that is used on most 32-bit systems". Hence, 2038.
Re: (Score:2)
I believe modern 32-bit OSes also have a 64-bit time_t. Especially glibc based ones.
64-bit integers isn't the exclusive realm of 64-bit OSes. It's just 32-bit processors are less efficient when calculating with 64-bit integers (takes multiple instructions). But most modern compilers for 32-bit processors understand 64-bit types natively, inclu
Re: (Score:2)
First Post! (Score:5, Informative)
There is a rickroll in article. Beware to click!
Re: (Score:3, Funny)
Beware what? Seeing in the new year with Rick Astley seems like a pretty good thing to me. Then again, I am easily amused!
Re: (Score:2)
What's wrong with Rick Astley? I've heard worse songs.
It's not April 1 yet (Score:3, Informative)
Did you even check it?
Re: (Score:2)
Re: (Score:2)
The first link took me to a Rick Astley youtube video. Thankfully I was browsing with the sound muted.
Re: (Score:2)
Either the link has been changed, or you're hitting the absinthe a little hard this New Year's.
Re: (Score:2)
See below. It seems there is a bit of messing around with localtime in a flash application on the page. It can't show the number of seconds to 2010 during 2010.
Re: (Score:2)
The first link took me to a Rick Astley youtube video. Thankfully I was browsing with the sound muted.
It's the millennium bug!
Re: (Score:1)
Thankfully my browser sound doesn't work while I'm listening to music. Thanks Ubuntu.
Only a rickroll after midnight (Score:5, Informative)
Re: (Score:2)
Okay its 1524 on the 1st for me. I got the video.
Re: (Score:2)
test
Re: (Score:2)
Re: (Score:2)
I looked after midnight (10/01/01 03:30am local). I got a white page flash up, with some numbers I think, and then youtube. It appears to be controlled by their newYear.swf. Makes you wonder, was there anything more nefarious in that? What a lovely way to start the new year. 10,000 Slashdotters infected with a nice fresh trojan.
Re: (Score:1)
Re:It's not April 1 yet (Score:5, Funny)
You should install the RickBlockPlus [functionalperfection.com] browser addon to prevent this sort of thing happening.
Re: (Score:1)
Re: (Score:2, Funny)
Oh, you people. It's just an alternative to the usual UNIX epoch [wikipedia.org].
time_rickroll(2) Unix Programmer's Manual time_rickroll(2)
NAME
time_rickroll - get time since 16 November, 1987 [wikipedia.org].
SYNOPSIS
#include
time_t time_rickroll(time_t *t);
DESCRIPTION
time_rickroll returns the time since the Astley Epoch (00:00:00 UTC, November 26, 1987 [wikipedia.org]) measured in seconds.
Unix epoch? (Score:3, Interesting)
Why didn't we restart it at 2000 amidst the Y2K mess?
Re:Unix epoch? (Score:5, Interesting)
Putting it in 1970 is a pain. VMS at least put their zero date in 1858, where it is less likely to conflict with real dates. If course, VMS had 64 put support from the word go. Rebasing time_t would have created a horrible mess. Better to start again with a proper date type.
Re: (Score:2)
Why is putting it in 1970 a pain? Because time_t is signed, that gives us the range of 1901 December 13 20:45:52 UTC to 2038 January 19 03:14:07 UTC.
That's 136 or so years from a 32-bit value.
Re: (Score:2)
Because time_t is signed, that gives us the range of 1901 December 13 20:45:52 UTC to 2038 January 19 03:14:07 UTC.
Damn - if only those 6th Century monks had thought of that we wouldn't now be arguing over whether today is the start of a new decade!
Re: (Score:1)
Re: (Score:2)
Isn't the sign bit only used to indicate error? ((time_t)-1) isn't a valid time but perhaps some other negative values are.
Sorry, what are you talking about?
$ echo -1 |awk '{print strftime("%c",$1,0)}'
Wed 31 Dec 1969 04:59:59 PM MST
$ echo -1 |awk '{print strftime("%c",$1,1)}'
Wed 31 Dec 1969 11:59:59 PM GMT
$ echo -1 |awk '{print strftime("%s",$1,0)}'
-1
Seems to work fine for me.
Re:Unix epoch? (Score:5, Funny)
Why didn't we restart it at 2000 amidst the Y2K mess?
You have a promising career in middle management ahead of you!
Re: (Score:2, Insightful)
No, no, middle management does all the work. Such a decision is usually done by top management.
Re: (Score:1, Informative)
Re: (Score:2)
Why was the epoch chosen to be 00:00:00 UTC on 1 January 1970?
I know the epoch was changed around a bit because early versions of the unix time system functioned at rates greater then 1hz, and hence would run out of room in the 32bit space really really fast. I'm not sure why that particular date was the one they settled on, hopefully someone else can fill in.
Why didn't we restart it at 2000 amidst the Y2K mess?
I'm not 100% on this, but I believe the Y2K mess didn't effect Unix-y systems at all. The way Unix time works, if you're not familiar, is that it just counts the seconds after the epoch. Whether the year is re
Re: (Score:2)
I'm not 100% on this, but I believe the Y2K mess didn't effect Unix-y systems at all. The way Unix time works, if you're not familiar, is that it just counts the seconds after the epoch. Whether the year is represented as two of four digits doesn't matter, and doesn't cause problems.
Yes, assuming well-behaved programs. But it is a fact that Y2K doesn't affect this particular interface at all.
Re: (Score:2)
> I'm not 100% on this, but I believe the Y2K mess didn't effect Unix-y systems at all. The way Unix time works,
> if you're not familiar, is that it just counts the seconds after the epoch. Whether the year is represented as two
> of four digits doesn't matter, and doesn't cause problems.
Remember all of the Perl-based CGI wishing you a Happy New Year on January 1, 19100? I have old books in a box somewhere from *1997* with sample code telling users to print "19" then append the year value. It affect
Damn you Slashdot! (Score:5, Funny)
Re: (Score:1)
"So x" is so 200x.
Re: (Score:1)
Re: (Score:1)
It's actually a rollover joke.
Over the hill? (Score:2)
I turn 45 this year you insensitive clod! Passing the top of the hill just means I am gaining momentum for the next climb, anyway.
BTW why does the summary point to a page which returns
(54) Connection reset by peer
Maybe the server is over the hill.
Re: (Score:2)
I don't know what special relationship with mortality you have, Sisyphus, but when most of us crest the hill, it's a smooth coast to the bottom.
Re: (Score:2)
I don't know what special relationship with mortality you have
I am a hacker. Many things are possible.
Re: (Score:2)
Re: (Score:3, Insightful)
I reject your reality and substitute my own.
Re:Over the hill? (Score:5, Interesting)
Re: (Score:3, Informative)
Perl version? (Score:2)
Cool. But would someone please translate this obfuscated Ruby into some readable Perl?
Re: (Score:2)
import time
for i in range(0,31):
print "0"*(30-i) + "1" + "0"*i + " " + time.strftime("%a %b %d %H:%M:%S +0000 %Y",time.gmtime(2**i))
for i in reversed(range(0,31)):
print "1"*(31-i) + "0"*i + " " + time.strftime("%a %b %d %H:%M:%S +0000 %Y",time.gmtime(2**31 - 2**i))
print "$"
Re: (Score:2)
Indeed, that was much more readable. And helped writing this Perl version, despite the Python trap (for a Python-illiterate) of "range(0,31)" apparently meaning "from 0 to 30":
for (0..30) {
print "0"x(30-$_), 1, "0"x$_, " ", scalar gmtime(2**$_), "\n";
}
for (reverse 0..29) {
print "1"x(31-$_), "0"x$_, " ", scalar gmtime(2**31 - 2**$_), "\n";
}
Now, maybe someone can condense it into a smarter one-liner, with some clever use of printf and/or pack/unpack.
Re: (Score:2)
import time
for i in range(0,61): print str((i>30)*1) * abs(i-30) + "1" + "0" * (30 - abs(i-30)) + " " + time.strftime("%a %b %d %H:%M:%S +0000 %Y",time.gmtime((2**(30 - abs(i-30))) * ((i <= 30) * 2 - 1) + 2 ** 31 * (i > 30)))
Re: (Score:2)
And here is the one-liner Perl version, using printf's %b:
$ perl -e 'for (0..30) {printf "%031b %s\n", 2**$_, scalar gmtime(2**$_)} for (reverse 0..29) {printf "%031b %s\n", 2**31-2**$_, scalar gmtime(2**31-2**$_)}'
Beware of parent's bomb! (Score:2)
Beware! The parent's code is the well-known Bash fork bomb [cyberciti.biz].
Windows (Score:2, Funny)
The Windows clock starts the second Gates stiffed IBM out of the DOS market.
Why is there a link to this guy's blog? (Score:3, Interesting)
Why is there a link in the summary to some guy's blog which says exactly what I've pasted above? I mean really, just put the information in the summary without the link....
Re: (Score:3, Insightful)
More important, why is the guy with the blog still wearing a face mullet, in 2010?
And have you ever met an "independent game producer" with such a neatly trimmed beard?
Re: (Score:2)
I use the day as my "birthday" on public websites in tribute.
Wow. He is hardcore!
Some of us ... (Score:2)
That's funny,... (Score:5, Funny)
My clock says today is Setting Orange, Day 73 of the Aftermath in the Year of Our Lady of Discord 3175.
Re: (Score:1)
I want a copy of your clock. Where might such a thing be acquired?
Note: I am too drunk to use Google properly at this juncture.
Re: (Score:2)
Telecommando is obviously a time traveller.
Re: (Score:1)
...oops ;-)
Re: (Score:3, Informative)
Re: (Score:2)
Not a clock, it's a calender [wikipedia.org].
Problem with this (Score:2)
This isn't really a valid birthday unless time() was actually compiled and run for the first time immediately after midnight on January 1, 1970. I mean, c'mon, are we supposed to also be celebrating the 190th birthday of perl's localtime()?
Re: (Score:2)
... er, make that 110th - sorry about that. Darn Slashdot and its lack of an edit function...
Re:Problem with this (Score:5, Insightful)
I don't know about you, but I'm ready to drink to that.
My wife and I opened a bottle of champagne a few hours ago, and she's fallen asleep after two glasses, the lightweight. I had a double espresso with my pecan pie and now I'm ready to friggin' rawk!
After I submit this, I'm gonna go show some Borderlands weaklings who's boss. Either that or finish the champagne and go watch the fireworks from my rooftop, naked. It's -2 degrees F outside though, so maybe I ought to pull out the thermal merkin first. I mean, subzero temperatures, nudity and high blood-alcohol level - what could possibly go wrong?
Re: (Score:2)
go watch the fireworks from my rooftop, naked.
I had similar plans but then our 38 degree C [wolframalpha.com] day turned into really serious thunder and lightening so I decided to give the naked roof standing a miss. The roof is steel and quite well grounded.
Re: (Score:2)
Yeah, the fireworks will be all washed out from the lightening anyway. Was the lightening caused by lightning, perhaps? Meteors? Or was it just fog and ordinary street-lams?
Flash? Seriously? (Score:3, Insightful)
Just for showing the epoch time?
Re: (Score:1, Funny)
It makes sense when the time hits midnight.
This is not true (Score:5, Informative)
Epoch starts at January 1st, 1970, but the system call itself was not around in 1970 [wikipedia.org].
Am I the only one? (Score:3, Insightful)
Who is almost exactly as old as *nix time?
Re: (Score:2)
Some of us are already "on the other side".
No I don't mean Windows. %-P
Rgds
Damon
Re: (Score:2)
Is %-P a legal printf() format?
Re: (Score:2)
When you're older than UNIX, you get to choose...
It's also how you look when trying to read the sprintf() man page on a mobile device.
Rgds
Damon
Re: (Score:2)
I am also "as old as time".
I turned 40 on 9-9-9.
Re: (Score:2)
Hey, we're birthday-brothers. I turned 22 on 999.
Hmm... (Score:2)
Apparently Slashdot's version of time_t had a year 2010 problem!
Happy new year anyway!
date +%s (Score:1)
On a *nix system, type "date +%s" to see the number of seconds since the Unix epoch started.
Re: (Score:2)
That is, on GNU systems. Not all Unix systems support %s, and it isn't in the standard, either.
Re: (Score:2)
Never gonna do that again
Never gonna do what again?
a) Give you up
b) Let you down
c) Run around and desert you
d) All of the above