App-dateseq
view release on metacpan or search on metacpan
script/dateseq view on Meta::CPAN
=item B<--business6>
Only list business days (Mon-Sat), or non-business days.
=item B<--exclude-dow-json>=I<s>
Do not show dates with these day-of-weeks (JSON-encoded).
See C<--exclude-dow>.
=item B<--exclude-dow>=I<s@>
Do not show dates with these day-of-weeks.
Can be specified multiple times.
=item B<--exclude-month-json>=I<s>
Do not show dates with these month numbers (JSON-encoded).
See C<--exclude-month>.
=item B<--exclude-month>=I<s@>
Do not show dates with these month numbers.
Can be specified multiple times.
=item B<--include-dow-json>=I<s>
Only show dates with these day-of-weeks (JSON-encoded).
See C<--include-dow>.
=item B<--include-dow>=I<s@>
Only show dates with these day-of-weeks.
Can be specified multiple times.
=item B<--include-month-json>=I<s>
Only show dates with these month numbers (JSON-encoded).
See C<--include-month>.
=item B<--include-month>=I<s@>
Only show dates with these month numbers.
Can be specified multiple times.
=back
=head2 Formatting options
=over
=item B<--format-class-attrs-json>=I<s>
Arguments to pass to constructor of DateTime::Format::* class (JSON-encoded).
See C<--format-class-attrs>.
=item B<--format-class-attrs>=I<s>
Arguments to pass to constructor of DateTime::Format::* class.
=item B<--format-class>=I<s>
Use a DateTime::Format::* class for formatting.
By default, L<DateTime::Format::Strptime> is used with pattern set from the
<strftime> option.
=item B<--strftime>=I<s>, B<-f>
strftime() format for each date.
Default is C<%Y-%m-%d>, unless when hour/minute/second is specified, then it is
C<%Y-%m-%dT%H:%M:%S>.
C<dateseq> actually uses L<DateTimeX::strftimeq>, so you can embed Perl code
for flexibility. For example:
% dateseq 2019-11-19 2019-11-25 -f '%Y-%m-%d%( $_->day_of_week == 7 ? "su" : "" )q'
will print something like:
2019-11-19
2019-11-20
2019-11-21
2019-11-22
2019-11-23
2019-11-24su
2019-11-25
=back
=head2 Output options
=over
=item B<--eval>=I<s>, B<-e>
Run perl code for each date.
Specified perl code will receive the date as DateTime object in C<$_>and expected
to return result to print.
=item B<--format>=I<s>
Choose output format, e.g. json, text.
Default value:
undef
Output can be displayed in multiple formats, and a suitable default format is
chosen depending on the application and/or whether output destination is
interactive terminal (i.e. whether output is piped). This option specifically
chooses an output format.
=item B<--json>
Set output format to json.
=item B<--naked-res>
When outputing as JSON, strip result envelope.
Default value:
0
By default, when outputing as JSON, the full enveloped result is returned, e.g.:
[200,"OK",[1,2,3],{"func.extra"=>4}]
The reason is so you can get the status (1st element), status message (2nd
element) as well as result metadata/extra result (4th element) instead of just
the result (3rd element). However, sometimes you want just the result, e.g. when
you want to pipe the result for more post-processing. In this case you can use
C<--naked-res> so you just get:
[1,2,3]
=item B<--page-result>
Filter output through a pager.
This option will pipe the output to a specified pager program. If pager program
is not specified, a suitable default e.g. C<less> is chosen.
=item B<--view-result>
View output using a viewer.
This option will first save the output to a temporary file, then open a viewer
program to view the temporary file. If a viewer program is not chosen, a
suitable default, e.g. the browser, is chosen.
=back
script/dateseq view on Meta::CPAN
=head2 Show dates (except Mondays) after 2015-01-01 and 2015-02-28
% dateseq 2015-01-01 2015-02-28 --exclude-dow Mo -f "%Y-%m-%d(%a)"
=head2 Generate a CSV data
% dateseq 2010-01-01 2015-01-31 -f "%Y,%m,%d" --header "year,month,day"
year,month,day
2010,01,01
... 1854 more lines ...
2015,01,30
2015,01,31
=head2 Generate periods (YYYY-MM)
% dateseq 2010-01-01 2015-12-31 -i P1M -f "%Y-%m"
2010-01
2010-02
... 68 more lines ...
2015-11
2015-12
=head2 List non-holidays in 2015 (using Indonesian holidays)
% setop --diff <(dateseq 2015-01-01 2015-12-31) <(list-idn-holidays --year 2015)
2015-01-02
2015-01-04
2015-01-05
2015-01-06
2015-01-07
... 336 more lines ...
2015-12-28
2015-12-29
2015-12-30
2015-12-31
See also L<dateseq-idn> as alternative.
=head2 List non-holidays business days in 2015 (using Indonesian holidays)
% setop --diff <(dateseq 2015-01-01 2015-12-31 --business) <(list-idn-holidays --year 2015)
2015-01-02
2015-01-05
2015-01-06
2015-01-07
2015-01-08
... 236 more lines ...
2015-12-28
2015-12-29
2015-12-30
2015-12-31
See also L<dateseq-idn> as alternative.
=head2 Use with fsql
% dateseq 2010-01-01 2015-12-01 -f "%Y,%m" -i P1M --header "year,month" | fsql --add-csv - --add-csv data.csv -F YEAR -F MONTH 'SELECT year, month, data1 FROM stdin WHERE YEAR(data.date)=year AND MONTH(data.date)=month'
=head2 Use %q (see DateTimeX::strftimeq)
% dateseq 2020-12-24 2021-01-15 -f '%Y-%m-%d%( $_->day_of_week == 7 ? "su" : "" )q'
2020-12-24
2020-12-25
2020-12-26
2020-12-27su
2020-12-28
... 14 more lines ...
2021-01-12
2021-01-13
2021-01-14
2021-01-15
=head2 Print first and last days of each month of 2021
% dateseq 2021-01-01 2021-12-01 --increment '1 month' -e 'my $dt2 = $_->clone; $dt2->add(months=>1); $dt2->add(days => -1); $_->ymd . " " . $dt2->ymd'
2021-01-01 2021-01-31
2021-02-01 2021-02-28
2021-03-01 2021-03-31
2021-04-01 2021-04-30
2021-05-01 2021-05-31
... 3 more lines ...
2021-09-01 2021-09-30
2021-10-01 2021-10-31
2021-11-01 2021-11-30
2021-12-01 2021-12-31
=head2 Retrieve MetaCPAN releases data for 2020, saved in monthly JSON files
% dateseq 2020-01-01 2020-12-01 --increment '1 month' -e 'my $dt2 = $_->clone; $dt2->add(months=>1); $dt2->add(days => -1); sprintf "list-metacpan-releases --from-date %sT00:00:00 --to-date %sT23:59:59 --json > %04d%02d.json", $_->ymd, $dt2->ymd, $_...
=head2 Generate 100 random dates between a certain range
% dateseq --random --from "1 year ago" --to "1 year from now" --limit 100
2022-09-08T14:55:06
2022-03-20T12:07:01
... 96 more lines ...
2022-01-02T07:23:33
2022-12-31T03:43:00
=head1 HOMEPAGE
Please visit the project's homepage at L<https://metacpan.org/release/App-dateseq>.
=head1 SOURCE
Source repository is at L<https://github.com/perlancar/perl-App-dateseq>.
=head1 SEE ALSO
L<durseq>. Produce sequence of date durations.
L<dateseq-idn>. A wrapper for dateseq, with built-in support for Indonesian holidays.
L<seq>.
L<seq-pl>. Perl variant of seq.
=head1 AUTHOR
( run in 0.565 second using v1.01-cache-2.11-cpan-39bf76dae61 )