<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># Copyright 1999-2006, Fred Steinberg, Brown Bear Software

package Title;
use strict;

sub new {
  my $class = shift;
  my ($operation, $amount, $type, $startDate, $endDate) = @_;
  my $self = {};
  bless $self, $class;

  my $title;

  $self-&gt;{_op} = $operation;
  my $prefs = $operation-&gt;prefs;
  my $i18n  = $operation-&gt;I18N;

  my $comma = ' ';              # change to ', ' if you do want a comma

  # If condensed, always show something like "1 Jan 1999 - 28 Feb 1999"
  if ($type =~ /condensed/i) {
      $title = $startDate-&gt;day . ' ' . $i18n-&gt;get ($startDate-&gt;monthName)
               . ' ' . $startDate-&gt;year . ' - '
               . $endDate-&gt;day . ' ' . $i18n-&gt;get ($endDate-&gt;monthName)
               . ' ' . $endDate-&gt;year;
  # If Approval, no dates a'tall
  } elsif ($type =~ /approv/i) {
      $title = $i18n-&gt;get ('Events Pending Approval');
  } elsif ($amount =~ /year/i) {
      if ($amount !~ /fyear/i) {
          $title = $startDate-&gt;year;
      } else {
          my $start = $startDate-&gt;startOfYear;
          my $end   = $start + 364;
          if ($start-&gt;year eq $end-&gt;year) {
              $title = $start-&gt;year;
          } else {
              $title = $start-&gt;year . ' / ' . $end-&gt;year;
          }
      }
  } elsif ($amount =~ /day/i) {
      # just use the date
      $title = $startDate-&gt;day . ' ' . $i18n-&gt;get ($startDate-&gt;monthName) .
               ' ' . $startDate-&gt;year . '&lt;br&gt;' .
               $i18n-&gt;get ($startDate-&gt;dayName);
  } elsif ($amount =~ /week/i) {
      # If &gt; 1 month visible, use something like "March/April, 1999"
      if ($startDate-&gt;month != $endDate-&gt;month) {
          my $start = $i18n-&gt;get ($startDate-&gt;monthName) .
                     ($startDate-&gt;year == $endDate-&gt;year ? ''
                         : $comma . $startDate-&gt;year);
          $title = $start . '/' . $i18n-&gt;get ($endDate-&gt;monthName) . $comma .
                   $endDate-&gt;year;
      } else {
          $title = $i18n-&gt;get ($endDate-&gt;monthName) . $comma . $endDate-&gt;year;
      }
  } elsif ($amount =~ /period/i) {
      $title = $startDate-&gt;periodName ($i18n, 'year'); # must be Date::Fiscal
  } elsif ($amount =~ /quarter/i) {
      $title = $startDate-&gt;quarterName ($i18n, 'year');
  } else {  # Month View
      # If the 1st of the month is in the first week, just use that month.
      # Otherwise, use something like "April/May, 1999"
      if ($startDate-&gt;day &lt;= 7) {
          $title = $i18n-&gt;get($startDate-&gt;monthName) . $comma .
                                                          $startDate-&gt;year();
      } else {
          my $start = $i18n-&gt;get ($startDate-&gt;monthName) .
                             ($startDate-&gt;year == $endDate-&gt;year ? ''
                                 : $comma . $startDate-&gt;year);
          $title = $start . '/' . $i18n-&gt;get ($endDate-&gt;monthName) . $comma .
                   $endDate-&gt;year;
      }
  }

  $self-&gt;{html} = $title;
  $self;
}

sub getHTML {
  my $self = shift;
  return qq (&lt;div class="DateHeader"&gt;$self-&gt;{html}&lt;/div&gt;);
}

sub cssDefaults {
    my ($self, $prefs) = @_;

    my $css;
    my $op = $self-&gt;{_op};

    my $fg = $prefs-&gt;color ('MainPageFG') || 'black';
    my ($face, $size) = $prefs-&gt;font ('MonthYear');
    $size ||= '+3';
    $css .= $op-&gt;cssString ('.DateHeader', {color =&gt; $fg,
                                            'font-size'   =&gt; $size,
                                            'font-family' =&gt; $face,
                                            'font-weight' =&gt; 'bold',
                                            'text-align'  =&gt; 'center'});
    $css;
}

1;
</pre></body></html>