summaryrefslogtreecommitdiff
path: root/FS/FS/sched_avail.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-04-05 16:46:29 -0700
committerIvan Kohler <ivan@freeside.biz>2014-04-05 16:46:29 -0700
commitac127e9cc71ed1cfebb159095dd59b3507e54e98 (patch)
treec1e741cfbe7a64567202b48e7b4a6725a67f6896 /FS/FS/sched_avail.pm
parenta57c537ff9ef2a57de3225fbd49772be4b81e74c (diff)
installers, RT#16584
Diffstat (limited to 'FS/FS/sched_avail.pm')
-rw-r--r--FS/FS/sched_avail.pm34
1 files changed, 34 insertions, 0 deletions
diff --git a/FS/FS/sched_avail.pm b/FS/FS/sched_avail.pm
index 62b1a5d..245c69f 100644
--- a/FS/FS/sched_avail.pm
+++ b/FS/FS/sched_avail.pm
@@ -111,6 +111,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