File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ use experimental qw(signatures lexical_subs);
1111use namespace::clean;
1212
1313use Synergy::Logger ' $Logger' ;
14- use Synergy::Util qw( bool_from_text) ;
14+ use Synergy::Util qw( bool_from_text describe_business_hours ) ;
1515
1616use IO::Async::Timer::Periodic;
1717use List::Util qw( max) ;
@@ -35,7 +35,7 @@ sub listener_specs {
3535 exclusive => 1,
3636 predicate => sub ($self , $e ) {
3737 return unless $e -> was_targeted;
38- return $e -> text =~ / \A hours(\s +for)?\s +/ ;
38+ return $e -> text =~ / \A hours(\s +for)?\s +/i ;
3939 }
4040 },
4141 {
@@ -185,11 +185,12 @@ sub handle_hours_for ($self, $event) {
185185 my $tz = $target -> time_zone;
186186 my $tz_nick = $self -> hub-> env-> time_zone_names-> { $tz } // $tz ;
187187
188+
188189 return $event -> reply(
189- sprintf " %s 's usual hours: %s , %s " ,
190+ sprintf " %s 's usual hours ( %s ): %s " ,
190191 $target -> username,
191- $self -> hub-> user_directory-> describe_user_preference($target , ' business-hours' ),
192192 $tz_nick ,
193+ describe_business_hours($target -> business_hours, $target ),
193194 );
194195}
195196
Original file line number Diff line number Diff line change @@ -518,14 +518,20 @@ sub validate_business_hours ($value) {
518518 return \%week_struct ;
519519}
520520
521- sub describe_business_hours ($value ) {
521+ sub describe_business_hours ($value , $user = undef ) {
522522 my @wdays = qw( mon tue wed thu fri) ;
523523 my @wends = qw( sat sun) ;
524524
525525 my %desc = map {; keys ($value -> {$_ }-> %*)
526526 ? ($_ => " $value ->{$_ }{start}-$value ->{$_ }{end}" )
527527 : ($_ => ' ' ) } (@wdays , @wends );
528528
529+ if ($user ) {
530+ for my $dow (keys %desc ) {
531+ $desc {$dow } .= $user -> is_wfh_on($dow ) ? " \N{HOUSE WITH GARDEN} " : ' ' ;
532+ }
533+ }
534+
529535 return " None" unless any { length $_ } values %desc ;
530536
531537 if ($desc {mon } && 7 == grep {; $desc {$_ } eq $desc {mon } } (@wdays , @wends )) {
You can’t perform that action at this time.
0 commit comments