X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fsched_avail.pm;h=912ad543db54639123faed3be739e1206753d91c;hp=5d9f8dfba2855a64642fbc6525108b2f7774dc80;hb=08669c947afaeb4ac355e9cbd68ee82567d32f42;hpb=2b6e316202d647312a479b72e95aaea373628d3f diff --git a/FS/FS/sched_avail.pm b/FS/FS/sched_avail.pm index 5d9f8dfba..912ad543d 100644 --- a/FS/FS/sched_avail.pm +++ b/FS/FS/sched_avail.pm @@ -112,6 +112,40 @@ sub check { $self->SUPER::check; } +=item stime_pretty + +=item etime_pretty + +=cut + +sub stime_pretty { shift->_time_pretty('stime', @_); } +sub etime_pretty { shift->_time_pretty('etime', @_); } + +sub _time_pretty { + my( $self, $field ) = @_; + + pretty_time( $self->$field() ); +} + +#helper sub +sub pretty_time { + my $t = shift; + + return 'Midnight' if $t == 0 || $t == 1440; + return 'Noon' if $t == 720; + + my $h = int( $t / 60 ); + my $m = $t % 60; + + my $ap = 'AM'; + if ( $h == 0 || $h == 24 ) { $h = 12; } + elsif ( $h == 12 ) { $ap = 'PM'; } + elsif ( $h > 12 ) { $ap = 'PM'; $h -= 12; } + + sprintf('%02d:%02d'." $ap", $h, $m); + +} + =back =head1 BUGS