#!/usr/bin/perl

# Copyright (c) 2007-2019 by Martin Becker, Blaubeuren.
# This package is free software; you can distribute it and/or modify it
# under the terms of the Artistic License 2.0 (see LICENSE file).

# today - is today a business day in New York?
#
# This example uses DateTime to find out the current date and time.

use strict;
use warnings;
use DateTime;
use Date::Gregorian::Business;

my $now  = DateTime->now(time_zone => 'America/New_York');
my $date = Date::Gregorian::Business->new('us')->set_datetime($now);

print
    join(' / ',
        'New York', $now->ymd, $now->hms,
        !$date->is_businessday?  'closed all day':
        $now->hour < 9?          'still closed':
        17 <= $now->hour?        'already closed':
        'open'
    ), "\n";

__END__
