Bday code incapable of recording dates before 1969 [message #3031] |
Fri, 07 June 2002 19:50 |
tgaastra
Messages: 90 Registered: June 2002
Karma: 0
|
Member |
|
|
I've noticed that the birthday code in 2.0 is incapable of recording dates before 1969, which is probably due to using some of the timestamping functions in PHP.
When I used 1.2.7, I eventually ended up gutting the bday code and replacing it with new code based on the DATE type structure in SQL... Is there a reason why a packed integer continues to be used for dates in 2.0?
|
|
|
|
Re: Bday code incapable of recording dates before 1969 [message #3034 is a reply to message #3032] |
Fri, 07 June 2002 21:28 |
tgaastra
Messages: 90 Registered: June 2002
Karma: 0
|
Member |
|
|
Are you sure? Have you gone back and looked?
I can put the number as (for instance) March 15 1955, but when I read the profile in again its March 15 1969.
Checking an actual query of the entry in fud2_users comes back with bday being 19690315.
Without digging too much into things, if I had to hazard a guess, I'd say its the fmt_year function in register.php.
It uses mktime passed into date to return a formated year, but mktime returns a timestamp, which is incapable (at least under RedHat 7.3 Linux) of representing a date earlier than the epoch.
Take this little snippet of php:
<html>
<head><title>Foo</title></head>
<body>
<?php
print(date("Y", mktime(1,1,1,1,1,1955)));
?>
</body>
</html>
On my system, this prints 1969.
Probably what needs to happen is that fmt_year is going to have to do a little guess work on its own rather than rely on mktime.
If people just use two digits, assume that just like the YEAR format does in SQL that its between 1970 and 2069.
Of course, if you used the DATE format, it would do that for you.
|
|
|
Re: Bday code incapable of recording dates before 1969 [message #3035 is a reply to message #3031] |
Fri, 07 June 2002 21:47 |
hackie
Messages: 177 Registered: January 2002
Karma: 0
|
Senior Member Core Developer |
|
|
Well, the problem is that I'm unable to replicate the bug here :).. You try it here? I've entered my bday as 1950 and it worked fine, that is obviously well before the epoh.
Trying this:
<?
echo date("Y", mktime(1,1,1,1,1,1920))."\n";
?>
:
on my computer which is linux-2.4.18 with glibc 2.2.4 produces:
1920
so it seems to work fine, the limits appear to be 1902-2039.
The same behavior was also observed by me on FreeBSD 3.3.
cc intelligence.c -o intelligence
$ ./intelligence
Segmentation fault
[Updated on: Fri, 07 June 2002 21:47] Report message to a moderator
|
|
|
|
|
|
|
|
|