Skip to content

Commit

Permalink
If no date passed, use current date
Browse files Browse the repository at this point in the history
  • Loading branch information
pudge committed Sep 15, 2003
1 parent 8661066 commit 9a91710
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Slash/Utility/Data/Data.pm
Expand Up @@ -334,7 +334,8 @@ Format time strings using user's format preference.
=item DATE
Raw date from database.
Raw date/time to format.
Supply a false value here to get the current date/time.
=item FORMAT
Expand Down Expand Up @@ -367,13 +368,19 @@ sub timeCalc {

$off_set = $user->{off_set} unless defined $off_set;

# massage data for YYYYMMDDHHmmSS or YYYYMMDDHHmm
$date =~ s/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})?$/"$1-$2-$3 $4:$5:" . ($6 || '00')/e;
if ($date) {
# massage data for YYYYMMDDHHmmSS or YYYYMMDDHHmm
$date =~ s/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})?$/"$1-$2-$3 $4:$5:" . ($6 || '00')/e;

# find out the user's time based on personal offset in seconds
$date = str2time($date) + $off_set;
# find out the user's time based on personal offset in seconds
$date = str2time($date) + $off_set;
} else {
# use current time (plus offset) if no time provided
$date = time() + $off_set;
}

# set user's language
# set user's language; we only use this if it is defined,
# so it's not a performance hit
my $lang = getCurrentStatic('datelang');

# convert the raw date to pretty formatted date
Expand Down

0 comments on commit 9a91710

Please sign in to comment.