[Bps-public-commit] r9711 - in Net-Hiveminder: lib/Net

sartak at bestpractical.com sartak at bestpractical.com
Tue Nov 20 18:30:06 EST 2007


Author: sartak
Date: Tue Nov 20 18:30:06 2007
New Revision: 9711

Modified:
   Net-Hiveminder/   (props changed)
   Net-Hiveminder/lib/Net/Hiveminder.pm

Log:
 r45438 at onn:  sartak | 2007-11-20 18:30:00 -0500
 Use the correct queries for 'todo'
 Use DateTime for starts-date comparisons


Modified: Net-Hiveminder/lib/Net/Hiveminder.pm
==============================================================================
--- Net-Hiveminder/lib/Net/Hiveminder.pm	(original)
+++ Net-Hiveminder/lib/Net/Hiveminder.pm	Tue Nov 20 18:30:06 2007
@@ -3,6 +3,7 @@
 use Moose;
 extends 'Net::Jifty';
 
+use DateTime;
 use Number::RecordLocator;
 my $LOCATOR = Number::RecordLocator->new;
 
@@ -59,15 +60,16 @@
     my $self = shift;
     my @out;
 
+    my $now = DateTime->now;
+
     for my $task (@_) {
         my $locator = $LOCATOR->encode($task->{id});
         my $display = "#$locator: $task->{summary}";
 
         # don't display start date if it's <= today
-        # XXX: use DateTime here
-        my ($y, $m, $d) = (localtime)[5,4,3]; $y += 1900; ++$m;
         delete $task->{starts}
-            if $task->{starts} && $task->{starts} le "$y-$m-$d";
+            if $task->{starts}
+            && $self->load_date($task->{starts}) < $now;
 
         $display .= " [$task->{tags}]" if $task->{tags};
         for my $field (qw/due starts group/) {
@@ -104,10 +106,12 @@
     my $self = shift;
 
     $self->get_tasks(
-        complete_not  => 1,
-        owner         => 'me',
-        starts_before => 'tomorrow',
-        # XXX: there are other queries here
+        complete_not     => 1,
+        accepted         => 1,
+        owner            => 'me',
+        starts_before    => 'tomorrow',
+        depends_on_count => 0,
+
         # XXX: this is one place to improve the API
 
         @_
@@ -156,6 +160,30 @@
     return $self->read('Task', $key => $value);
 }
 
+=head2 load_date Date
+
+Loads a yyyy-mm-dd date into a L<DateTime> object.
+
+=cut
+
+sub load_date {
+    my $self = shift;
+    my $ymd  = shift;
+
+    # XXX: remove me when HM is pulled live and gets the Jifty REST changes
+    $ymd =~ s/ 00:00:00$//;
+
+    my ($y, $m, $d) = $ymd =~ /^(\d\d\d\d)-(\d\d)-(\d\d)$/
+        or confess "Invalid date passed to load_date: $ymd. Expected yyyy-mm-dd.";
+
+    return DateTime->new(
+        time_zone => 'floating',
+        year      => $y,
+        month     => $m,
+        day       => $d,
+    );
+}
+
 =head1 SEE ALSO
 
 L<Jifty>, L<Net::Jifty>



More information about the Bps-public-commit mailing list