view release on metacpan or search on metacpan
[ENHANCEMENTS]
- Add 'sort' argument.
0.09 2011-11-11 Released-By: SHARYANTO
[BUG FIXES]
- DateTime croaks if we supply time_zone => undef, so we always provide
a default (UTC) when $ENV{TZ} is not set.
0.08 2011-11-10 Released-By: SHARYANTO
[BUG FIXES]
- By default don't show done todos.
"Data::Sah::Compiler::perl::TH::array" : "0.914",
"Data::Sah::Compiler::perl::TH::bool" : "0.914",
"Data::Sah::Compiler::perl::TH::code" : "0.914",
"Data::Sah::Compiler::perl::TH::int" : "0.914",
"Data::Sah::Compiler::perl::TH::obj" : "0.914",
"Data::Sah::Compiler::perl::TH::re" : "0.914",
"Data::Sah::Compiler::perl::TH::str" : "0.914",
"Data::Sah::Filter::perl::Path::expand_tilde_when_on_unix" : "0",
"Data::Sah::Filter::perl::Path::strip_slashes_when_on_unix" : "0",
"Data::Sah::Filter::perl::Str::replace_dashes_with_underscores" : "0",
"DateTime" : "0",
"Digest::MD5" : "0",
"Exporter" : "5.57",
"File::Slurper" : "0",
"File::Slurper::Dash" : "0",
"File::Temp" : "0.2307",
"Function::Fallback::CoreOrPP" : "0",
"IPC::System::Options" : "0.339",
"Lingua::EN::Numbers::Ordinate" : "0",
"List::MoreUtils" : "0",
"List::Util" : "1.54",
Data::Sah::Compiler::perl::TH::array: '0.914'
Data::Sah::Compiler::perl::TH::bool: '0.914'
Data::Sah::Compiler::perl::TH::code: '0.914'
Data::Sah::Compiler::perl::TH::int: '0.914'
Data::Sah::Compiler::perl::TH::obj: '0.914'
Data::Sah::Compiler::perl::TH::re: '0.914'
Data::Sah::Compiler::perl::TH::str: '0.914'
Data::Sah::Filter::perl::Path::expand_tilde_when_on_unix: '0'
Data::Sah::Filter::perl::Path::strip_slashes_when_on_unix: '0'
Data::Sah::Filter::perl::Str::replace_dashes_with_underscores: '0'
DateTime: '0'
Digest::MD5: '0'
Exporter: '5.57'
File::Slurper: '0'
File::Slurper::Dash: '0'
File::Temp: '0.2307'
Function::Fallback::CoreOrPP: '0'
IPC::System::Options: '0.339'
Lingua::EN::Numbers::Ordinate: '0'
List::MoreUtils: '0'
List::Util: '1.54'
Makefile.PL view on Meta::CPAN
"Data::Sah::Compiler::perl::TH::array" => "0.914",
"Data::Sah::Compiler::perl::TH::bool" => "0.914",
"Data::Sah::Compiler::perl::TH::code" => "0.914",
"Data::Sah::Compiler::perl::TH::int" => "0.914",
"Data::Sah::Compiler::perl::TH::obj" => "0.914",
"Data::Sah::Compiler::perl::TH::re" => "0.914",
"Data::Sah::Compiler::perl::TH::str" => "0.914",
"Data::Sah::Filter::perl::Path::expand_tilde_when_on_unix" => 0,
"Data::Sah::Filter::perl::Path::strip_slashes_when_on_unix" => 0,
"Data::Sah::Filter::perl::Str::replace_dashes_with_underscores" => 0,
"DateTime" => 0,
"Digest::MD5" => 0,
"Exporter" => "5.57",
"File::Slurper" => 0,
"File::Slurper::Dash" => 0,
"File::Temp" => "0.2307",
"Function::Fallback::CoreOrPP" => 0,
"IPC::System::Options" => "0.339",
"Lingua::EN::Numbers::Ordinate" => 0,
"List::MoreUtils" => 0,
"List::Util" => "1.54",
Makefile.PL view on Meta::CPAN
"Data::Sah::Compiler::perl::TH::array" => "0.914",
"Data::Sah::Compiler::perl::TH::bool" => "0.914",
"Data::Sah::Compiler::perl::TH::code" => "0.914",
"Data::Sah::Compiler::perl::TH::int" => "0.914",
"Data::Sah::Compiler::perl::TH::obj" => "0.914",
"Data::Sah::Compiler::perl::TH::re" => "0.914",
"Data::Sah::Compiler::perl::TH::str" => "0.914",
"Data::Sah::Filter::perl::Path::expand_tilde_when_on_unix" => 0,
"Data::Sah::Filter::perl::Path::strip_slashes_when_on_unix" => 0,
"Data::Sah::Filter::perl::Str::replace_dashes_with_underscores" => 0,
"DateTime" => 0,
"Digest::MD5" => 0,
"Exporter" => "5.57",
"File::Slurper" => 0,
"File::Slurper::Dash" => 0,
"File::Spec" => 0,
"File::Temp" => "0.2307",
"Function::Fallback::CoreOrPP" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"IPC::System::Options" => "0.339",
[Prereqs]
perl= 5.010001
experimental=0
open=0
strict=0
warnings=0
Browser::Open=0
Complete::Util=0.619
Cwd=0
DateTime=0
Digest::MD5=0
Exporter=5.57
File::Slurper=0
File::Slurper::Dash=0
File::Temp=0.2307
Function::Fallback::CoreOrPP=0
IPC::System::Options=0.339
Lingua::EN::Numbers::Ordinate=0
List::MoreUtils=0
List::Util=1.54
lib/App/ListOrgAnniversaries.pm view on Meta::CPAN
package App::ListOrgAnniversaries;
use 5.010;
use strict;
use warnings;
use Log::ger;
use App::OrgUtils;
use Cwd qw(abs_path);
use DateTime;
use Digest::MD5 qw(md5_hex);
use Exporter 'import';
use Lingua::EN::Numbers::Ordinate;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2024-01-09'; # DATE
our $DIST = 'App-OrgUtils'; # DIST
our $VERSION = '0.487'; # VERSION
our @EXPORT_OK = qw(list_org_anniversaries);
lib/App/ListOrgAnniversaries.pm view on Meta::CPAN
unless ($v =~ /^\s*(\d{4})-(\d{2})-(\d{2})\s*$/) {
log_warn("Invalid date format $v, ".
"must be YYYY-MM-DD");
next;
}
if ($k =~ $args->{reminded_field_pattern} && @annivs) {
$annivs[-1][2] = $el->datetime;
} else {
push @annivs, [
lc $k,
DateTime->new(year=>$1, month=>$2, day=>$3,
time_zone=>$tz),
];
}
return;
}
}
}
);
if (!@annivs) {
lib/App/ListOrgAnniversaries.pm view on Meta::CPAN
my $date_ny = $date->clone; $date_ny->add(years => $y+1);
DATE:
for my $d ($date_ly, $date_ty, $date_ny) {
my $days = ($d < $today ? -1:1) * $d->delta_days($today)->in_units('days');
next if defined($args->{due_in}) &&
$days > $args->{due_in};
next if defined($args->{max_overdue}) &&
-$days > $args->{max_overdue};
next if !defined($args->{due_in}) &&
!defined($args->{max_overdue}) &&
DateTime->compare($d, $today) < 0;
REMINDED: {
if ($date_reminded) {
my $days_reminded;
$days_reminded = ($date_reminded < $today ? -1:1) *
$date_reminded->delta_days($today)->in_units('days');
last REMINDED if defined($args->{due_in}) &&
$days_reminded > $args->{due_in};
last REMINDED if defined($args->{max_overdue}) &&
-$days_reminded > $args->{max_overdue};
last REMINDED if !defined($args->{due_in}) &&
!defined($args->{max_overdue}) &&
DateTime->compare($date_reminded, $today) < 0;
#log_debug("Anniversary already reminded, skipped");
next DATE;
}
}
my $pl = abs($days) > 1 ? "s" : "";
my $hide_age = $date->year == 1900;
my $msg = sprintf(
"%s (%s): %s of %s (%s)",
$days == 0 ? "today" :
lib/App/ListOrgAnniversaries.pm view on Meta::CPAN
'in this number of days',
schema => ['int'],
},
max_overdue => {
summary => 'Don\'t show dates that are overdue '.
'more than this number of days',
schema => ['int'],
},
today => {
summary => 'Assume today\'s date',
schema => [obj => isa=>'DateTime'],
description => <<'_',
You can provide Unix timestamp or DateTime object. If you provide a DateTime
object, remember to set the correct time zone.
_
},
sort => {
summary => 'Specify sorting',
schema => [any => {
of => [
['str*' => {in=>['due_date', '-due_date']}],
'code*',
],
default => 'due_date',
}],
description => <<'_',
If string, must be one of 'date', '-date' (descending).
If code, sorting code will get [REC, DUE_DATE] as the items to compare, where
REC is the final record that will be returned as final result (can be a string
or a hash, if 'detail' is enabled), and DUE_DATE is the DateTime object.
_
},
},
};
sub list_org_anniversaries {
require Org::Parser;
my %args = @_;
my $sort = $args{sort};
my $tz = $args{time_zone} // $ENV{TZ} // "UTC";
my $files = $args{files};
$args{field_pattern} //= qr/(?:birthday|anniversary)/i;
$args{reminded_field_pattern} //= qr/reminded/i;
$today = $args{today} // DateTime->today(time_zone => $tz);
$yest = $today->clone->add(days => -1);
my $orgp = Org::Parser->new;
my @res;
my %docs = App::OrgUtils::_load_org_files(
$files, {time_zone=>$tz});
for my $file (keys %docs) {
my $doc = $docs{$file};
lib/App/ListOrgAnniversaries.pm view on Meta::CPAN
});
}
if ($sort) {
if (ref($sort) eq 'CODE') {
@res = sort $sort @res;
} elsif ($sort =~ /^-?due_date$/) {
@res = sort {
my $dt1 = $a->[1];
my $dt2 = $b->[1];
my $comp = DateTime->compare($dt1, $dt2);
($sort =~ /^-/ ? -1 : 1) * $comp;
} @res;
}
}
[200, "OK", [map {$_->[0]} @res],
{result_format_opts=>{list_max_columns=>1}}];
}
1;
lib/App/ListOrgAnniversaries.pm view on Meta::CPAN
(No description)
=item * B<sort> => I<str|code> (default: "due_date")
Specify sorting.
If string, must be one of 'date', '-date' (descending).
If code, sorting code will get [REC, DUE_DATE] as the items to compare, where
REC is the final record that will be returned as final result (can be a string
or a hash, if 'detail' is enabled), and DUE_DATE is the DateTime object.
=item * B<time_zone> => I<date::tz_name>
Will be passed to parser's options.
If not set, TZ environment variable will be picked as default.
=item * B<today> => I<obj>
Assume today's date.
You can provide Unix timestamp or DateTime object. If you provide a DateTime
object, remember to set the correct time zone.
=back
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status code
(200 means OK, 4xx caller error, 5xx function error). Second element
($reason) is a string containing error message, or something like "OK" if status is
lib/App/ListOrgHeadlines.pm view on Meta::CPAN
package App::ListOrgHeadlines;
use 5.010001;
use strict;
use warnings;
use Log::ger;
use App::OrgUtils;
use Cwd qw(abs_path);
use DateTime;
use Digest::MD5 qw(md5_hex);
use Exporter 'import';
use List::MoreUtils qw(uniq);
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2024-01-09'; # DATE
our $DIST = 'App-OrgUtils'; # DIST
our $VERSION = '0.487'; # VERSION
our @EXPORT_OK = qw(list_org_headlines);
lib/App/ListOrgHeadlines.pm view on Meta::CPAN
} elsif ($unit eq 'w') {
$dt->subtract(weeks => $wp);
} elsif ($unit eq 'm') {
$dt->subtract(months => $wp);
} elsif ($unit eq 'y') {
$dt->subtract(years => $wp);
} else {
die "Can't understand unit '$unit' in timestamp's ".
"warning period: " . $ats->as_string;
}
$met++ if DateTime->compare($dt, $today) <= 0;
}
if (!$met && !$ats->_warning_period && !defined($args->{due_in})) {
# try the default 14 days
$met = $days <= 14;
}
return unless $met;
}
my $r;
my $date;
lib/App/ListOrgHeadlines.pm view on Meta::CPAN
Relevant only when used with `minimum_priority` and/or `maximum_priority`.
If this option is turned on, todo items that does not have any priority or have
unknown priorities will *still* be included. Otherwise they will not be
included.
_
links => ['minimum_priority', 'maximum_priority'],
},
today => {
schema => [obj => isa=>'DateTime'],
summary => 'Assume today\'s date',
description => <<'_',
You can provide Unix timestamp or DateTime object. If you provide a DateTime
object, remember to set the correct time zone.
_
},
sort => {
schema => [any => {
of => [
['str*' => {in=>['due_date', '-due_date']}],
'code*',
],
default => 'due_date',
}],
summary => 'Specify sorting',
description => <<'_',
If string, must be one of 'due_date', '-due_date' (descending).
If code, sorting code will get [REC, DUE_DATE, HL] as the items to compare,
where REC is the final record that will be returned as final result (can be a
string or a hash, if 'detail' is enabled), DUE_DATE is the DateTime object (if
any), and HL is the Org::Headline object.
_
tags => ['format'],
},
},
};
sub list_org_headlines {
my %args = @_;
my $sort = $args{sort};
my $tz = $args{time_zone} // $ENV{TZ} // "UTC";
my $files = $args{files};
$args{_raw} //= 1;
$today = $args{today} // DateTime->today(time_zone => $tz);
$yest = $today->clone->add(days => -1);
my @res;
my %docs = App::OrgUtils::_load_org_files(
$files, {time_zone=>$tz});
for my $file (keys %docs) {
my $doc = $docs{$file};
$doc->walk(
lib/App/ListOrgHeadlines.pm view on Meta::CPAN
my $dt1 = $a->[1];
my $dt2 = $b->[1];
my $comp;
if ($dt1 && !$dt2) {
$comp = -1;
} elsif (!$dt1 && $dt2) {
$comp = 1;
} elsif (!$dt1 && !$dt2) {
$comp = 0;
} else {
$comp = DateTime->compare($dt1, $dt2);
}
($sort =~ /^-/ ? -1 : 1) * $comp;
} @res;
}
}
my $res;
if ($args{group_by_tags}) {
my %seen;
lib/App/ListOrgHeadlines.pm view on Meta::CPAN
Only show todo items that have this priority.
=item * B<sort> => I<str|code> (default: "due_date")
Specify sorting.
If string, must be one of 'due_date', '-due_date' (descending).
If code, sorting code will get [REC, DUE_DATE, HL] as the items to compare,
where REC is the final record that will be returned as final result (can be a
string or a hash, if 'detail' is enabled), DUE_DATE is the DateTime object (if
any), and HL is the Org::Headline object.
=item * B<state> => I<str>
Only show todo items that have this state.
=item * B<time_zone> => I<date::tz_name>
Will be passed to parser's options.
If not set, TZ environment variable will be picked as default.
=item * B<to_level> => I<int>
Only show headlines having this level as the maximum.
=item * B<today> => I<obj>
Assume today's date.
You can provide Unix timestamp or DateTime object. If you provide a DateTime
object, remember to set the correct time zone.
=item * B<todo> => I<bool>
Only show headlines that are todos.
=item * B<with_unknown_priority> => I<bool>
Also show items with noE<sol>unknown priority.
lib/App/ListOrgTodos.pm view on Meta::CPAN
Only show todo items that have this priority.
=item * B<sort> => I<str|code> (default: "due_date")
Specify sorting.
If string, must be one of 'due_date', '-due_date' (descending).
If code, sorting code will get [REC, DUE_DATE, HL] as the items to compare,
where REC is the final record that will be returned as final result (can be a
string or a hash, if 'detail' is enabled), DUE_DATE is the DateTime object (if
any), and HL is the Org::Headline object.
=item * B<state> => I<str>
Only show todo items that have this state.
=item * B<time_zone> => I<date::tz_name>
Will be passed to parser's options.
If not set, TZ environment variable will be picked as default.
=item * B<to_level> => I<int>
Only show headlines having this level as the maximum.
=item * B<today> => I<obj>
Assume today's date.
You can provide Unix timestamp or DateTime object. If you provide a DateTime
object, remember to set the correct time zone.
=item * B<with_unknown_priority> => I<bool>
Also show items with noE<sol>unknown priority.
Relevant only when used with C<minimum_priority> and/or C<maximum_priority>.
If this option is turned on, todo items that does not have any priority or have
unknown priorities will I<still> be included. Otherwise they will not be
script/list-org-anniversaries view on Meta::CPAN
Specify sorting.
Default value:
"due_date"
If string, must be one of 'date', '-date' (descending).
If code, sorting code will get [REC, DUE_DATE] as the items to compare, where
REC is the final record that will be returned as final result (can be a string
or a hash, if 'detail' is enabled), and DUE_DATE is the DateTime object.
=item B<--time-zone>=I<s>
Will be passed to parser's options.
If not set, TZ environment variable will be picked as default.
=item B<--today-json>=I<s>
Assume today's date (JSON-encoded).
See C<--today>.
=item B<--today>=I<s>
Assume today's date.
You can provide Unix timestamp or DateTime object. If you provide a DateTime
object, remember to set the correct time zone.
=back
=head2 Configuration options
=over
=item B<--config-path>=I<s>, B<-c>
script/list-org-headlines view on Meta::CPAN
=item B<--today-json>=I<s>
Assume today's date (JSON-encoded).
See C<--today>.
=item B<--today>=I<s>
Assume today's date.
You can provide Unix timestamp or DateTime object. If you provide a DateTime
object, remember to set the correct time zone.
=back
=head2 Configuration options
=over
=item B<--config-path>=I<s>, B<-c>
script/list-org-headlines view on Meta::CPAN
Specify sorting.
Default value:
"due_date"
If string, must be one of 'due_date', '-due_date' (descending).
If code, sorting code will get [REC, DUE_DATE, HL] as the items to compare,
where REC is the final record that will be returned as final result (can be a
string or a hash, if 'detail' is enabled), DUE_DATE is the DateTime object (if
any), and HL is the Org::Headline object.
=item B<--state>=I<s>
Only show todo items that have this state.
=item B<--to-level>=I<s>
Only show headlines having this level as the maximum.
script/list-org-todos view on Meta::CPAN
=item B<--today-json>=I<s>
Assume today's date (JSON-encoded).
See C<--today>.
=item B<--today>=I<s>
Assume today's date.
You can provide Unix timestamp or DateTime object. If you provide a DateTime
object, remember to set the correct time zone.
=back
=head2 Configuration options
=over
=item B<--config-path>=I<s>, B<-c>
script/list-org-todos view on Meta::CPAN
Specify sorting.
Default value:
"due_date"
If string, must be one of 'due_date', '-due_date' (descending).
If code, sorting code will get [REC, DUE_DATE, HL] as the items to compare,
where REC is the final record that will be returned as final result (can be a
string or a hash, if 'detail' is enabled), DUE_DATE is the DateTime object (if
any), and HL is the Org::Headline object.
=item B<--state>=I<s>
Only show todo items that have this state.
=item B<--to-level>=I<s>
Only show headlines having this level as the maximum.