fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-08-31 05:12 am

[dw-free] Entries show as being posted at the current time when they are backdated to the beginning

[commit: http://hg.dwscoalition.org/dw-free/rev/b068031869cf]

http://bugs.dwscoalition.org/show_bug.cgi?id=2985

Beginning of time (January 1, 1970) == 0, so we need to check whether the
time is defined, not whether it is 0.

Patch by [personal profile] exor674.

Files modified:
  • cgi-bin/ljtimeutil.pl
--------------------------------------------------------------------------------
diff -r 4dc0abe1fabe -r b068031869cf cgi-bin/ljtimeutil.pl
--- a/cgi-bin/ljtimeutil.pl	Tue Aug 31 12:54:57 2010 +0800
+++ b/cgi-bin/ljtimeutil.pl	Tue Aug 31 13:12:21 2010 +0800
@@ -145,7 +145,7 @@ sub mysql_time
 sub mysql_time
 {
     my ($time, $gmt) = @_;
-    $time ||= time();
+    $time = time() unless defined $time;
     my @ltime = $gmt ? gmtime($time) : localtime($time);
     return sprintf("%04d-%02d-%02d %02d:%02d:%02d",
                    $ltime[5]+1900,
@@ -160,7 +160,7 @@ sub mysql_time
 # returns: date in ISO format
 sub mysql_date {
     my ( $time, $gmt ) = @_;
-    $time ||= time();
+    $time = time() unless defined $time;
     my @ltime = $gmt ? gmtime( $time ) : localtime( $time );
     return sprintf( "%04d-%02d-%02d",
                     $ltime[5]+1900, $ltime[4]+1, $ltime[3] );
--------------------------------------------------------------------------------
pne: A picture of a plush toy, halfway between a duck and a platypus, with a green body and a yellow bill and feet. (Default)

[personal profile] pne 2010-09-01 06:24 am (UTC)(link)
I was going to suggest $time //= time();, but I think that only works in fairly new perls, which Dreamwidth probably doesn't want to require for their code.