Gossamer Forum
Home : Products : Links 2.0 : Customization :

Re: Date Modification - I found!!!

Quote Reply
Re: Date Modification - I found!!! In reply to
tmoretti,

did you also find how to change the date format to 1999-Apr-30?

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


when I change every order of $day, $mon, $year in link.cfg to $year, $mon, $day,
it gives me just wrong year and day.

I know that many of you do not have any interest to change the date mode since you live with western culture. However, think about the others...

If anybody knows how to change it, please share the idea.

[This message has been edited by sofine (edited April 30, 1999).]
Subject Author Views Date
Thread Date Modification - I found!!! tmoretti 2942 Apr 29, 1999, 9:14 PM
Post Re: Date Modification - I found!!!
Alex 2892 Apr 30, 1999, 1:58 PM
Post Re: Date Modification - I found!!!
sofine 2871 Apr 30, 1999, 4:16 PM
Post Re: Date Modification - I found!!!
Bobsie 2877 Apr 30, 1999, 7:04 PM
Post Re: Date Modification - I found!!!
almas 2898 May 1, 1999, 6:57 PM
Post Re: Date Modification - I found!!!
tmoretti 2868 May 2, 1999, 5:04 AM
Post Re: Date Modification - I found!!!
Bobsie 2868 May 2, 1999, 11:49 AM
Post Re: Date Modification - I found!!!
sofine 2885 May 2, 1999, 9:31 PM
Post Re: Date Modification - I found!!!
YellowKard 2862 May 9, 2000, 2:10 PM
Post Re: Date Modification - I found!!!
Stealth 2860 May 9, 2000, 5:23 PM
Post Re: Date Modification - I found!!!
YellowKard 2890 May 11, 2000, 4:45 PM
Post Re: Date Modification - I found!!!
webmaster33 2866 May 12, 2000, 3:41 AM