Gossamer Forum
Home : Products : Links 2.0 : Customization :

Date Modification - I found!!!

Quote Reply
Date Modification - I found!!!
       Hey, i found out how to "manipulate" dates on Links 2. I need it because I live in a
country and my server is in another, so I need to change the date to my country system.
If you have a similar problem you should know how many hours you want to add or
take out from the real date on the server.
For example. In your country is 15:00 pm, and your server date is 18:00 pm, so you want
to take out 3 hours from the serverīs date. Now, you need to calculate how many seconds you does
this hours meand. If 1 hour is 3600 seconds, so 3 hours are 10800 seconds.
Now, go to the file links.cfg and change
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 Fev Mar Abr Maio Jun Jul Ago Set Out Nov Dez!;
$year = $year + 1900;
return "$day-$months[$mon]-$year";
}

to

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 -10800));
my @months = qw!Jan Fev Mar Abr Maio Jun Jul Ago Set Out Nov Dez!;
$year = $year + 1900;
return "$day-$months[$mon]-$year";
}

Noticed the changes? Now, the localtime calls the $time less 10800 seconds. Ok, this is for
the date. For the time, you should go to db_utils.pl and change

Code:
sub get_time {
# --------------------------------------------------------
# Returns the time in the format "hh-mm-ss".
#
my $time = shift;
$time | |= time();
my ($sec, $min, $hour, @junk) = localtime $time;
($sec < 10) and ($sec = "0$sec");
($min < 10) and ($min = "0$min");
($hour < 10) and ($hour = "0$hour");

return "$hour:$min:$sec";
}

to

Code:
sub get_time {
# --------------------------------------------------------
# Returns the time in the format "hh-mm-ss".
#
my $time = shift;
$time &#0124; &#0124;= time();
my ($sec, $min, $hour, @junk) = (localtime ($time-10800));
($sec < 10) and ($sec = "0$sec");
($min < 10) and ($min = "0$min");
($hour < 10) and ($hour = "0$hour");

return "$hour:$min:$sec";
}

If you need to add a certain number of seconds, just change - to +. Ie. If you need
to add four hours, you change my "- 10800" to "+ 14400".

Isnīt it right Alex???


Thiago Moretti
Webmaster Busca BR
http://www.buscabr.com
webmaster@buscabr.com



Busca BR,
O nosso sistema de busca no Brasil
Subject Author Views Date
Thread Date Modification - I found!!! tmoretti 2889 Apr 29, 1999, 9:14 PM
Post Re: Date Modification - I found!!!
Alex 2841 Apr 30, 1999, 1:58 PM
Post Re: Date Modification - I found!!!
sofine 2820 Apr 30, 1999, 4:16 PM
Post Re: Date Modification - I found!!!
Bobsie 2826 Apr 30, 1999, 7:04 PM
Post Re: Date Modification - I found!!!
almas 2848 May 1, 1999, 6:57 PM
Post Re: Date Modification - I found!!!
tmoretti 2817 May 2, 1999, 5:04 AM
Post Re: Date Modification - I found!!!
Bobsie 2817 May 2, 1999, 11:49 AM
Post Re: Date Modification - I found!!!
sofine 2835 May 2, 1999, 9:31 PM
Post Re: Date Modification - I found!!!
YellowKard 2812 May 9, 2000, 2:10 PM
Post Re: Date Modification - I found!!!
Stealth 2810 May 9, 2000, 5:23 PM
Post Re: Date Modification - I found!!!
YellowKard 2839 May 11, 2000, 4:45 PM
Post Re: Date Modification - I found!!!
webmaster33 2816 May 12, 2000, 3:41 AM