Skip to content

Instantly share code, notes, and snippets.

@bessarabov
Created January 6, 2017 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bessarabov/be47a6739a8fbcbf049124c6015feefc to your computer and use it in GitHub Desktop.
Save bessarabov/be47a6739a8fbcbf049124c6015feefc to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
=encoding UTF-8
=cut
=head1 DESCRIPTION
=cut
# common modules
use strict;
use warnings FATAL => 'all';
use feature 'say';
use utf8;
use open qw(:std :utf8);
use Moment;
use Date::Holidays::RU qw(is_holiday is_business_day);
# global vars
# subs
# main
sub main {
my $start = Moment->new( dt => '2016-12-29 00:00:00');
my $end = Moment->new( dt => '2017-01-31 23:59:59');
my $format = "%10s %-10s %-20s %-20s";
say sprintf
$format,
'',
'',
'is_holiday',
'is_business_day',
;
my $current = $start;
while ( $current->cmp($end) == -1 ) {
say sprintf
$format,
$current->get_d(),
($current->is_saturday() or $current->is_sunday()) ? $current->get_weekday_name() : '' ,
is_holiday($current->get_year(), $current->get_month(), $current->get_day()) ? '1' : '',
is_business_day($current->get_year(), $current->get_month(), $current->get_day()) ? '1' : '',
;
$current = $current->plus( day => 1 );
}
say '#END';
}
main();
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment