Created
April 14, 2013 00:01
-
-
Save pjf/5380694 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use 5.010; | |
use strict; | |
use warnings; | |
use autodie qw( :all ); | |
use WebService::Beeminder; | |
use Config::Tiny; | |
# use Smart::Comments; | |
# Get our beeminder auth token. | |
my $config = Config::Tiny->read("$ENV{HOME}/.rtbmrc"); | |
$config or die "Can't read ~/.rtbmrc config file"; | |
my $token = $config->{Beeminder}{auth_token}; | |
my $bee = WebService::Beeminder->new( token => $token ); | |
my $goals = $bee->user( | |
skinny => 1, goals_filter => 'frontburner', diff_since=>1, | |
)->{goals}; | |
my $now = time(); | |
foreach my $goal (sort { $a->{losedate} <=> $b->{losedate} } @$goals) { | |
my $timeleft = timeleft($goal->{losedate} - $now); | |
say "[$timeleft] $goal->{slug}"; | |
} | |
sub timeleft { | |
my ($sec) = @_; | |
my $days = int($sec / 86400); | |
my $hrs = int( ($sec - ($days * 86400))/3600); | |
return "${days}d ${hrs}hrs"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment