Gossamer Forum
Home : Products : Links 2.0 : Customization :

Print Date Error

Quote Reply
Print Date Error
I have MOD password in my Links. v.2
I get this error message when I try to modify
my codes.
Code:
Error Message : fatal error: invalid date format: 31-Dec-1969 - parsed as (day: 31, month: 11, year: 69). Reason: Can't handle date (0, 0, 0, 31, 11, 69) at /myserver/link/admin/links.cfg line 158
I tried to look at the line under links.cfg
and this is the code.
Code:
require Time::Local;
my $time = 0;
eval {
$time = &Time::Local::timelocal(0,0,0, $day, $months{$mon}, $year);
};
if ($@) { die "invalid date format: $date - parsed as (day: $day, month: $months{$mon}, year: $year). Reason: $@"; }
return $time;
}
How do I solve this problem?
any advice deeply appreciated.
*Eliot thanks for the many help you've given.

------------------
Be Dynamic nOt Static......

Quote Reply
Re: Print Date Error In reply to
How have you changed the date format?

Please post the changes you've made.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Print Date Error In reply to
I've not modified anything in the date format. The most modified change is the modify.cgi. Minor changes done to built_html_template, links.def.
I think the problem should be in modify.cgi. Can you help me take a look at this script and see if the modify.cgi is fine?
Here's the URL to the text format.
www.ryanosure.com/test/modify.txt

Really appreciate your help Eliot.

[This message has been edited by rynax (edited May 11, 2000).]
Quote Reply
Re: Print Date Error In reply to
When I said post the changes you've made, I meant to be specific and provide exact details. "I changed modify.cgi script" doesn't help me to help you.

How did you change the modify.cgi script? How did you change the date format in your links.cfg file?

Please post all your date routines in your links.cfg file and also the sub get_date routine in the db_utils.pl file in this Topic.

The problem is NOT with your modify.cgi file.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Print Date Error In reply to
Okie.
here are the codes, but i dun think i've changed that. please take alook Eliot...

The code to links.cfgSubroutine unix date...
Code:
sub date_to_unix {
# --------------------------------------------------------
# This routine must take your date format and return the time a la UNIX time().
# Some things to be careful about..
# timelocal does not like to be in array context, don't do my($time) = timelocal (..)
# int your values just in case to remove spaces, etc.
# catch the fatal error timelocal will generate if you have a bad date..
# don't forget that the month is indexed from 0!
#
my $date = shift; my $i;
my %months = map { $_ => $i++ } qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
my ($day, $mon, $year) = split(/-/, $date);

exists $months{$mon} or return undef;
$day = int($day); $year = $year - 1900;

require Time::Local;
my $time = 0;
eval {
$time = &Time::Local::timelocal(0,0,0, $day, $months{$mon}, $year);
};
if ($@) { die "invalid date format: $date - parsed as (day: $day, month: $months{$mon}, year: $year). Reason: $@"; }
return $time;
}

sub unix_to_date {
# --------------------------------------------------------
# This routine must take a unix time and return your date format
# A much simpler routine, just make sure your format isn't so complex that
# you can't get it back into unix time.
#
my $time = shift;
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $tz) = localtime $time;
my @months = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
$year = $year + 1900;
return "$day-$months[$mon]-$year";
}

sub long_date {
# --------------------------------------------------------
# This routine is for printing a nicer date format on the what's new page. It should
# take in a date in your current format and return a new one.
my $time = shift;
$time = &date_to_unix ($time);
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $tz) = localtime $time;
my @months = qw!January February March April May June July August September October November December!;
my @days = qw!Sunday Monday Tuesday Wednesday Thursday Friday Saturday!;
$year = $year + 1900;
return "$days[$dweek], $months[$mon] $day $year";
}

The Code to db_utils.pl Subroutine getdate
Code:
sub get_date {
# --------------------------------------------------------
# Returns the current date.
#
my ($time) = shift;
$time | |= time();

exists $DATE_CACHE{$time} or ($DATE_CACHE{$time} = &unix_to_date($time));
return $DATE_CACHE{$time};
}



------------------
Be Dynamic nOt Static......
http://www.ryanosure.com

Quote Reply
Re: Print Date Error In reply to
I'm stumped....
Can someone please take a look at the Unix print codes ?
i really have no idea why it's not working....
Users can add links but the print error occurs when they want to modify.
I've only modified my script with the print sub category and password script....

--------Ryanosuren Dynamic Design--------
Be Dynamic n@t Static!
Quote Reply
Re: Print Date Error In reply to
In Reply To:
Users can add links but the print error occurs when they want to modify.
Okay...well then, the problem could be with your modify.cgi script....

Make sure that you have the following codes in your modify.cgi script:

Code:
$in{$db_cols[$db_modified]} = &get_date;
Also, you need to have hidden fields for the Date field in ALL your modify template files (including modify.html and modify_error.html files)...

Code:
<input type="hidden" name="Date" value="<Úte%>">
You should NOT activate this field for people to modify themselves because the margin of error is great and users will continually get the Invalid Format error because they most likely will not input the correct date format.

Regards,


Eliot Lee
Anthro TECH, L.L.C
Web: http://www.anthrotech.com/
Quote Reply
Re: Print Date Error In reply to
Hi Eliot,
thanks again for the respond.
but i know i have $in{$db_cols[$db_modified]} = &get_date;
in the modify.cgi file. and i have included the hidden fields for the print date.
but it still appear the exact print date error.
I dun understand why does it report this error.
Code:
fatal error: invalid date format: 31-Dec-1969 - parsed as (day: 31, month: 11, year: 69). Reason: Can't handle date (0, 0, 0, 31, 11, 69) at /myserver/link/admin/links.cfg line 158
Is there a Links Y2K bug fix?
woes......

--------Ryanosuren Dynamic Design--------
Be Dynamic n@t Static!
Quote Reply
Re: Print Date Error In reply to
No...this is not a Y2K bug...but a weird bug in the sense that the date works fine in the add form, but not in the modify forms, right? Very weird.

I would contact your hosting company and ask if they have made any changes to their Perl lib files.

Regards,

Eliot Lee
Anthro TECH, L.L.C
Web: http://www.anthrotech.com/
Quote Reply
Re: Print Date Error In reply to
I think of the possibilities of the error is because i'm trying to write to the links.db directly from the modify.cgi without writing to the validate.db file first.
This result in the error as the dates did not match.....
Do you think that could the reason?

--------Ryanosuren Dynamic Design--------
Be Dynamic n@t Static!
Quote Reply
Re: Print Date Error In reply to
In Reply To:
I think of the possibilities of the error is because i'm trying to write to the links.db directly from the modify.cgi without writing to the validate.db file first.
Could be...try using the default settings to write to the validate.db file.

Regards,

Eliot Lee
Anthro TECH, L.L.C
Web: http://www.anthrotech.com/
Quote Reply
Re: Print Date Error In reply to
I've tried to modify back to work on writing to validate.db
But it seems to have the same problem again....
I'm baffled again......
i changed "<$db_modified_name" in modify.cgi to:
Code:
open (DB, "<$db_file_name") or &cgierr("error in validate_records. unable to open db file: $db_file_name. Reason: $!");
Would there be anything wrong?

--------Ryanosure Dynamic Design--------
Be Dynamic n@t Static!
Quote Reply
Re: Print Date Error In reply to
Uh...you have not changed it back to the validate.db setting.

You need to change:

Code:
$db_file_name
to the following:

Code:
$db_modified_name
Regards,

Eliot Lee
Anthro TECH, L.L.C
Web: http://www.anthrotech.com/
Quote Reply
Re: Print Date Error In reply to
Sorry for the mistake.....
i meant the $db_file_name i have changed back to $db_modified_name.

--------Ryanosure Dynamic Design--------
Be Dynamic n@t Static!
Quote Reply
Re: Print Date Error In reply to
Welp...here are two suggestions...

1) Show me the link to your modify.cgi script.
2) Uninstall the Mod you added.

Regards,

Eliot Lee
Anthro TECH, L.L.C
Web: http://www.anthrotech.com/
Quote Reply
Re: Print Date Error In reply to
Here is the link to the codes.
http:www.ryanosure.com/test/modify.txt
This is the lastest modified version.
Sorry for all the trouble guys...... Blush

--------Ryanosure Dynamic Design--------
Be Dynamic n@t Static!
Quote Reply
Re: Print Date Error In reply to
1) You gave the wrong URL...it should look like the following:

<A HREF="http://http:www.ryanosure.com/test/modify.txt" target="_new">http://http:www.ryanosure.com/test/modify.txt</A>

2) You have NOT changed the appropriate codes that I suggested before. *sigh*

Okay...

The following codes:

<pre># Print out the modified record to a "modified database" where it is stored until
# the admin decides to add it into the real database.
open (MOD, ">>$db_links_name") or &cgierr("error in modify.cgi. unable to open modification database: $db_modified_name. Reason: $!");
flock(MOD, $LOCK_EX) unless (!$db_use_flock);
print MOD &join_encode(%in);
close MOD; # automatically removes file lock
</pre><p>NEED to be changed to the following:

<pre># Print out the modified record to a "modified database" where it is stored until
# the admin decides to add it into the real database.
open (MOD, ">>$db_modified_name") or &cgierr("error in modify.cgi. unable to open modification database: $db_modified_name. Reason: $!");
flock(MOD, $LOCK_EX) unless (!$db_use_flock);
print MOD &join_encode(%in);
close MOD; # automatically removes file lock
</pre><p>Regards,

Eliot Lee
Anthro TECH, L.L.C
Web: http://www.anthrotech.com/
Quote Reply
Re: Print Date Error In reply to
No..... no...... no
i did change it to the requested code.
juz that i changed it back to show you what are the changes since the print data error has happened......
But if you look at the code.....
there's not much modified from the original modify.cgi

--------Ryanosure Dynamic Design--------
Be Dynamic n@t Static!
Quote Reply
Re: Print Date Error In reply to
Welp...I have provided all the suggestions I have at this time...Read my replies carefully and apply the suggested codes I have given you...If they do not solve the problem, I would recommend using the original modify.cgi and then apply ONLY the codes listed in the Mods that you want to add.

Best of luck!

Regards,

Eliot Lee
Anthro TECH, L.L.C
Web: http://www.anthrotech.com/