[Cpan-forum-commit] rev 302 - in trunk: . lib/CPAN www

svn at pti.co.il svn at pti.co.il
Sun Jul 22 07:04:52 EEST 2007


Author: gabor
Date: 2007-07-22 07:04:52 +0300 (Sun, 22 Jul 2007)
New Revision: 302

Modified:
   trunk/
   trunk/lib/CPAN/Forum.pm
   trunk/www/style.css
Log:
show ellapsed time since post instead of date of post



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4309
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752
   + 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4310
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752

Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm	2007-07-22 04:04:36 UTC (rev 301)
+++ trunk/lib/CPAN/Forum.pm	2007-07-22 04:04:52 UTC (rev 302)
@@ -749,13 +749,36 @@
             thread_id    => $post->thread,
             thread_count => $thread_count-1,
             #date         => POSIX::strftime("%e/%b", localtime $post->date),
-            date         => scalar localtime $post->date,
+            #date         => scalar localtime $post->date,
+            date         => _ellapsed($post->date),
             postername   => $post->uid->username,
             };
     }
     return \@resp;
 }
 
+sub _ellapsed {
+    my ($t) = @_;
+    my $now = time;
+    my $diff = $now-$t;
+    return  'now' if not $diff;
+
+    my $sec = $diff % 60;
+    $diff = ($diff -$sec) / 60;
+    return  sprintf(" %s sec ago", $sec) if not $diff;
+
+    my $min = $diff % 60;
+    $diff = ($diff-$min)/60;
+    return  sprintf("%s min ago", $min) if not $diff;  
+
+    my $hours = $diff % 24;
+    $diff = ($diff - $hours) / 24;
+    return  sprintf("%s hours ago", $hours ) if not $diff;  
+
+    return  sprintf("%s days ago", $diff );  
+}
+
+
 sub error {
     my ($self) = @_;
     $self->log->critical($@) if $@;
@@ -1176,8 +1199,6 @@
                 $self->session->param("uid"));
                 
     my $button = $q->param("button");
-    # BUG: we are putting in the usernames instead of the user ids in the uid field of the posts
-    # but for this reason we'll have to use the username in every other place
     if (not @errors and $button eq "Submit") {
         my ($last_post) = CPAN::Forum::DB::Posts->search(uid => $self->session->param("username"), {order_by => 'id DESC', limit => 1});
         if ($last_post) {

Modified: trunk/www/style.css
===================================================================
--- trunk/www/style.css	2007-07-22 04:04:36 UTC (rev 301)
+++ trunk/www/style.css	2007-07-22 04:04:52 UTC (rev 302)
@@ -141,7 +141,7 @@
 }
 
 .col2 {
-	width: 40%;
+	width: 50%;
 }
 
 .col3 {
@@ -149,7 +149,7 @@
 }
 
 .col4 {
-	width: 20%;
+	width: 10%;
 }
 
 .col5 {



More information about the Cpan-forum-commit mailing list