[Bps-public-commit] r14143 - in sd/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Wed Jul 16 00:06:04 EDT 2008


Author: sartak
Date: Wed Jul 16 00:06:03 2008
New Revision: 14143

Modified:
   sd/trunk/   (props changed)
   sd/trunk/lib/App/SD/Model/Ticket.pm

Log:
 r64350 at onn:  sartak | 2008-07-16 00:04:28 -0400
 Color overdue tickets' due dates red


Modified: sd/trunk/lib/App/SD/Model/Ticket.pm
==============================================================================
--- sd/trunk/lib/App/SD/Model/Ticket.pm	(original)
+++ sd/trunk/lib/App/SD/Model/Ticket.pm	Wed Jul 16 00:06:03 2008
@@ -45,10 +45,45 @@
     return colored($value, $color);
 }
 
+sub color_prop_due {
+    my ($self, $due) = @_;
+
+    return colored($due, 'red') if $self->is_overdue($due);
+    return $due;
+}
+
 sub props_to_show {
     ('id', 'summary', 'status', 'owner', 'due', 'creator', 'reported_by', 'CF-Broken in', 'CF-Severity')
 }
 
+# this expects ISO dates. we should improve it in the future to require
+sub is_overdue {
+    my $self = shift;
+    my $date = shift || $self->prop('due');
+
+    return 0 if !$date;
+
+    if ($date !~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)$/) {
+        warn "Unknown date format '$date'";
+        return 0;
+    }
+
+    my $dt = eval { DateTime->new(
+            year      => $1,
+            month     => $2,
+            day       => $3,
+            hour      => $4,
+            minute    => $5,
+            second    => $6,
+            time_zone => 'UTC',
+    ) };
+    warn $@ if $@;
+    return 0 if !$dt;
+
+    my $now = DateTime->now(time_zone => 'UTC');
+    return $now > $dt;
+}
+
 __PACKAGE__->register_reference( comments => 'App::SD::Collection::Comment', by => 'ticket');
 __PACKAGE__->register_reference( attachments => 'App::SD::Collection::Attachment', by => 'ticket');
 



More information about the Bps-public-commit mailing list