diff --git a/lib/Synergy/Reactor/TimeClock.pm b/lib/Synergy/Reactor/TimeClock.pm index 829d47ca..236115bd 100644 --- a/lib/Synergy/Reactor/TimeClock.pm +++ b/lib/Synergy/Reactor/TimeClock.pm @@ -11,7 +11,7 @@ use experimental qw(signatures lexical_subs); use namespace::clean; use Synergy::Logger '$Logger'; -use Synergy::Util qw(bool_from_text); +use Synergy::Util qw(bool_from_text describe_business_hours); use IO::Async::Timer::Periodic; use List::Util qw(max); @@ -35,7 +35,7 @@ sub listener_specs { exclusive => 1, predicate => sub ($self, $e) { return unless $e->was_targeted; - return $e->text =~ /\Ahours(\s+for)?\s+/; + return $e->text =~ /\Ahours(\s+for)?\s+/i; } }, { @@ -185,11 +185,12 @@ sub handle_hours_for ($self, $event) { my $tz = $target->time_zone; my $tz_nick = $self->hub->env->time_zone_names->{ $tz } // $tz; + return $event->reply( - sprintf "%s's usual hours: %s, %s", + sprintf "%s's usual hours (%s): %s", $target->username, - $self->hub->user_directory->describe_user_preference($target, 'business-hours'), $tz_nick, + describe_business_hours($target->business_hours, $target), ); } diff --git a/lib/Synergy/Util.pm b/lib/Synergy/Util.pm index 3f1bb120..90fdccb9 100644 --- a/lib/Synergy/Util.pm +++ b/lib/Synergy/Util.pm @@ -518,7 +518,7 @@ sub validate_business_hours ($value) { return \%week_struct; } -sub describe_business_hours ($value) { +sub describe_business_hours ($value, $user = undef) { my @wdays = qw(mon tue wed thu fri); my @wends = qw(sat sun); @@ -526,6 +526,12 @@ sub describe_business_hours ($value) { ? ($_ => "$value->{$_}{start}-$value->{$_}{end}") : ($_ => '') } (@wdays, @wends); + if ($user) { + for my $dow (keys %desc) { + $desc{$dow} .= $user->is_wfh_on($dow) ? " \N{HOUSE WITH GARDEN}" : ''; + } + } + return "None" unless any { length $_ } values %desc; if ($desc{mon} && 7 == grep {; $desc{$_} eq $desc{mon} } (@wdays, @wends)) {