Fixed up timezone in Perl and formated time more consistently
[clearscm.git] / maps / bin / MAPSUtil.pm
index 2298d77..82f7bc7 100644 (file)
@@ -17,6 +17,10 @@ package MAPSUtil;
 use strict;
 use vars qw (@ISA @EXPORT);
 
+BEGIN {
+  $ENV{TZ}='America/Los_Angeles';
+} # BEGIN
+
 @ISA = qw (Exporter);
 
 @EXPORT = qw (
@@ -33,15 +37,18 @@ sub Today2SQLDatetime;
 sub FormatDate {
   my ($date) = @_;
 
-  return substr $date, 5, 2  . '/' .
-         substr $date, 8, 2  . '/' .
-         substr $date, 0, 4;
+  return substr ($date, 5, 2)  . '/' .
+         substr ($date, 8, 2)  . '/' .
+         substr ($date, 0, 4);
 } # FormatDate
 
 sub FormatTime {
   my ($time) = @_;
 
   my $hours   = substr $time, 0, 2;
+
+  $hours = substr $hours, 1, 1 if $hours < 10;
+
   my $minutes = substr $time, 3, 2;
   my $seconds = substr $time, 6, 2;
   my $AmPm    = $hours > 12 ? 'Pm' : 'Am';
@@ -141,9 +148,9 @@ sub SubtractDays {
     $month = '0' . $month;
   } # if
 
-  # Prefix days with  0 if necessary
-  if ($days eq 0) { 
-      $days = '01';
+  # Prefix days with 0 if necessary
+  if ($days == 0) { 
+     $days = '01';
   } elsif ($days < 10) {
     $days = '0' . $days;
   } # if