Gossamer Forum
Home : Products : Links 2.0 : Customization :

New links page problem (developing international date mod...)

Quote Reply
New links page problem (developing international date mod...)
I'm working on an international date mod, but I've runned into a problem.
I use separate date formats for db_date_format, date_display_format, date_file_format (for new links files & backup files), date_whatsnew_format.
Db date format is: yyyy.mm.dd. HH:MM.SS
Display format is: yyyy.mm.dd. HH:MM
Date file format is: yyyy-mm-dd

On my new links page each link with the same date (but different time) appear separately instead to be collected under the same day.
It looks like this:
2000. January 28. Friday (1)
2000. January 28. Friday (1)
2000. January 27. Thursday (1)

It may occured because the db date format & display format is different...???
I don't know exactly where could I correct the problem above within sub build_new_page.
(the span pages mod & the nonenglish mod is installed)

Please, somebody, show me the point & or at least give me ideas, where should I correct the codes within sub build_new_page (nph-build.cgi)?

Thanks in advance,
Webmaster33
P.S.: Of course this international date mod will be released after I successfully finish it.

[This message has been edited by webmaster33 (edited February 20, 2000).]
Quote Reply
Re: New links page problem (developing international date mod...) In reply to
In your date Mod, have you included a "short date" format that does not include spaces?

All you have to do is replace the following codes in the sub build_new_page routine with the date routines you've written for the short date:

Code:
DATE: foreach $date (sort { &date_to_unix($b) <=> &date_to_unix($a) } keys %
link_output) {

You will see later in the codes:

Code:
open (NEW, ">$build_new_path/$date$build_extension") or cgierr ("una
ble to open what's new page: $build_new_path/$build_index. Reason: $!");

All you have to do is associate the new sub-routine for the short date in the foreach loop and replace &date_to_unix with the short date routine that you've written.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: New links page problem (developing international date mod...) In reply to
Thanks Eliot, for your quick answer. Hmm, maybe that's the part I have to modify.
As for the short date format, I planned to use short date format in the db, like this:
$db_date_format = "yyyymmddHHMMSS";

The current db date format is: yyyy.mm.dd. HH:MM:SS, but I don't think it matters in the link sorting, does it?
My problem is, that the new links are separated on the same day into more parts, instead of joining them to this day.

Are you sure this code part is responsible to put together the links posted on the same day?
Code:
DATE: foreach $date (sort { &date_to_unix($b) <=> &date_to_unix($a) } keys %link_output) {
I'm not sure in this...

Webmaster33
Quote Reply
Re: New links page problem (developing international date mod...) In reply to
YES it is....

Quote:
The current db date format is: yyyy.mm.dd. HH:MM:SS, but I don't think it matters in the link sorting, does it?

You should keep the date format in the same format as the date_to_unix or you will also have to edit the sub build_sorthit routine in the db_utils.pl file.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: New links page problem (developing international date mod...) In reply to
ok-ok Wink I trust you
Quote:
You should keep the date format in the same format as the date_to_unix or you will also have to edit the sub build_sorthit
routine in the db_utils.pl file.
This is not so easy question. Same format as the date_to_unix? You mean the format of date as it's displayed?
To be more clear, I explain the date formats used by me:
Db date format: yyyy.mm.dd. HH:MM.SS - date as it's stored in the db. I can even use the yyyymmddHHMMSS format
Display format: yyyy.mm.dd. HH:MM - the link dates are displayed in this format on the site
Whatsnew format: yyyy. mmmm dd. dddd - the format I use to display day collector links
Date file format: yyyy-mm-dd - date for file names on new page or backup

I modified date_to_unix & unix_to_date to convert the Display format from/to unix format.
The Whatsnew format is used only to display the link in Whatsnew page, but the date from the db is used in the sort code you mentioned.

Well, I posted this above just FYI.
Otherwise I will try tomorrow to solve the problem based on your suggestions.
But if you have comments, you can post it now (I will still be here for about 30-60 minutes, then I hybernate myself for tomorrow Smile ).

Webmaster33
Quote Reply
Re: New links page problem (developing international date mod...) In reply to
Oops..I meant the sub unix_to_date, which is the short version of the date. This is what you will need to work with in terms of appropriately defining the $date variable, which is used to build the New pages.

Hope this helps.

One thing you can experiment with is removing the $date in the following codes:

Code:
$build_new_path/$date$build_extension

and change it to the following:

Code:
$build_new_path/$shortdate$build_extension

Then you will have to define $shortdate differently like the following:

Code:
$shortdate = &unix_to_date

You will then have to incorporate this variable into the codes I provided before.

Hope this helps.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums



[This message has been edited by AnthroRules (edited February 20, 2000).]
Quote Reply
Re: New links page problem (developing international date mod...) In reply to
Well, I think you meant sub date_to_unix correctly first time, since it converts the display date format to unix date(which is in seconds since 1st Jan, 1970) so unix date is the result and that's what we need for the sort code.
Yes, it's clear now, sorting is done based on this unix date.
(however, I still don't see how the sort will join together the links posted on the same day, but I'll try to figure it out Smile )

I will play around with the things you suggested Smile

Thanks & see you tomorrow,
Webmaster33

[This message has been edited by webmaster33 (edited February 20, 2000).]
Quote Reply
Re: New links page problem (developing international date mod...) In reply to
Uh...NO...Look at the standard sub unix_to_date....

Code:
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";
}

See the return line...that is what is used to build the short date.

Anyway...good luck figuring out a solution...I have provided all I can think of at this point.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: New links page problem (developing international date mod...) In reply to
Yes, thanks, very much. Tomorrow, this time I can tell you, if I successfully corrected it.
Quote Reply
Re: New links page problem (developing international date mod...) In reply to
You're welcome.

BTW: Don't forget to look at the date routines, like sub get_date in the db_utils.pl file. You may have to re-write those as well.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: New links page problem (developing international date mod...) In reply to
Nope. Luckily, it seems, I will not have to touch sub get_date Smile. I solved it by modifying only date_to_unix & unix_to_date, because sub get_date uses calls to there.
However I will have a lot work to check functions of each $date variable, then change them to the appropiate date variable used by me, e.g $date_file or $db_date_format.
Quote Reply
Re: New links page problem (developing international date mod...) In reply to
Eliot: I solved the What's New page problem Smile
Unfortunately you had no right, at least partially...
Here's how I solved:
Code:
LINK: for ($i = 0; $i < ($#{$new_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$new_links{$category}});
my $tmp = &convert_date ($tmp{'Date'}, $db_date_format, $date_file_format);
${$link_output{$tmp}}{$category} .= &site_html_link (%tmp) . "\n";
$span_totals{$tmp}++;
}

.
.

DATE: foreach $date (sort { &date_to_unix($b) <=> &date_to_unix($a)} keys %link_output) {
$date_file = $date;
my $whatsnew_date = &convert_date ($date, $date_file_format, $date_whatsnew_format);
As you see I use date_to_unix. The real solution was in the hash, changing the 'Date' which was in db format, to display format.
Now I can continue implementing this mod into Links.

Regards,
Webmaster33

[This message has been edited by webmaster33 (edited February 25, 2000).]
Quote Reply
Re: New links page problem (developing international date mod...) In reply to
 
Quote:
Unfortunately you had no right, at least partially...

I think you meant you were not right.

Wink

Well, at least you figured it out.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: New links page problem (developing international date mod...) In reply to
You are right Wink