]> git.donarmstrong.com Git - deb_pkgs/libhtml-calendarmonth-perl.git/blobdiff - lib/HTML/CalendarMonth.pm
the firstDayofWeek for ga_IE is now Monday in glibc
[deb_pkgs/libhtml-calendarmonth-perl.git] / lib / HTML / CalendarMonth.pm
index 425f9c7518706c5bc72788453570e1124411b1b0..20cb8ea02260e7e51959205595cfce9fff8086c0 100644 (file)
@@ -1,14 +1,12 @@
 package HTML::CalendarMonth;
-BEGIN {
-  $HTML::CalendarMonth::VERSION = '1.25';
+{
+  $HTML::CalendarMonth::VERSION = '2.04';
 }
 
 use strict;
 use warnings;
 use Carp;
 
-BEGIN { $HTML::CalendarMonth::VERSION = 1.25 }
-
 use HTML::ElementTable 1.18;
 use HTML::CalendarMonth::Locale;
 use HTML::CalendarMonth::DateTool;
@@ -53,7 +51,6 @@ my %Calmonth_Attrs = (
   _ctoih    => {},
   _caltool  => undef,
   _weeknums => undef,
-  _today    => undef,
 
   dow1st   => undef,
   lastday  => undef,
@@ -241,17 +238,15 @@ sub _gencal {
   $self->item($self->year)->replace_content($self->item_alias($self->year));
 
   if ($self->_head_my) {
-    if ($self->head_m) {
-      $self->item($self->month)->attr('colspan',$width - $self->year_span);
+    if ($self->head_m && $self->head_y) {
+      $self->item($self->year) ->attr('colspan', $self->year_span);
+      $self->item($self->month)->attr('colspan', $width - $self->year_span);
     }
-    else {
+    elsif ($self->head_y) {
       $self->item($self->month)->mask(1);
       $self->item($self->year)->attr('colspan', $width);
     }
-    if ($self->head_y) {
-      $self->item($self->year)->attr('colspan',$self->year_span);
-    }
-    else {
+    elsif ($self->head_m) {
       $self->item($self->year)->mask(1);
       $self->item($self->month)->attr('colspan', $width);
     }
@@ -307,11 +302,14 @@ sub _gencal {
 
   # css classes
   if ($self->enable_css) {
-    $self                             ->push_attr(class => 'hcm-table'     );
-    $self->item_row($self->dayheaders)->push_attr(class => 'hcm-day-head'  );
-    $self->item    ($self->year)      ->push_attr(class => 'hcm-year-head' );
-    $self->item    ($self->month)     ->push_attr(class => 'hcm-month-head');
-    $self->item    ($self->week_nums) ->push_attr(class => 'hcm-week-head' )
+    $self->push_attr(class => 'hcm-table');
+    $self->item_row($self->dayheaders)->push_attr(class => 'hcm-day-head')
+      if $self->head_dow;
+    $self->item($self->year)->push_attr(class => 'hcm-year-head')
+      if $self->head_y;
+    $self->item($self->month)->push_attr(class => 'hcm-month-head')
+      if $self->head_m;
+    $self->item($self->week_nums) ->push_attr(class => 'hcm-week-head')
       if $self->head_week;
   }
 
@@ -597,7 +595,7 @@ sub first_week_row { FWR };
 
 sub past_days {
   my $self  = shift;
-  my $today = $self->_today;
+  my $today = $self->today;
   if ($today < 0) {
     return $self->days;
   }
@@ -609,7 +607,7 @@ sub past_days {
 
 sub future_days {
   my $self  = shift;
-  my $today = $self->_today;
+  my $today = $self->today;
   if ($today < 0) {
     return;
   }
@@ -908,8 +906,7 @@ sub new {
 
   my $dom_now = defined $attrs{today} ? $dt->_dom_now(delete $attrs{today})
                                       : $dt->_dom_now;
-  $self->_today($dom_now);
-  $self->today($dom_now) if $dom_now > 0;
+  $self->today($dom_now);
 
   my $alias = $attrs{alias} || {};
   if ($self->full_days < 0) {
@@ -972,14 +969,10 @@ HTML::CalendarMonth - Generate and manipulate HTML calendar months
  my $c2 = HTML::CalendarMonth->new(
    month  => 8,
    year   => 2010,
-   locale => 'zu_ZA'
+   locale => 'zu-ZA'
  );
  print $c2->as_HTML;
 
- # Full locale support via DateTime::Locale
- $c3 = HTML::CalendarMonth->new( month => 8, year => 79, locale => 'fr' );
- print $c3->as_HTML
-
  # HTML-Tree integration
  my $tree = HTML::TreeBuilder->parse_file('cal.html');
  $tree->find_by_attribute(class => 'hcm-calendar')->replace_with($c);
@@ -1008,7 +1001,7 @@ E<gt>item(2010)> would return the cell representing the year. Since
 years and particular months change frequently, it is probably more
 useful to take advantage of the C<month()> and C<year()> methods, which
 return their respective values. The following is therefore the same as
-explicitly referencing the year: C<$c-E<gt>item($c- E<gt>year())>.
+explicitely referencing the year: C<$c-E<gt>item($c- E<gt>year())>.
 
 Multiple cells of the calendar can be manipulated as if they were a
 single element. For instance, C<$c-E<gt>item(15)-E<gt>attr(class =E<gt>
@@ -1080,14 +1073,19 @@ Specifies whether to display the year header. Default 1.
 
 Specifies whether to display days of the week header. Default 1.
 
+=item head_week
+
+Specifies whether to display the week-of-year numbering. Default 0.
+
 =item locale
 
 Specifies the id of the locale in which to render the calendar. Default
-is 'en_US'. By default, this will also control determine which day is
+is 'en-US'. By default, this will also control determine which day is
 considered to be the first day of the week. See
 L<HTML::CalendarMonth::Locale> for more information. If for some reason
 you prefer to use different labels than those provided by C<locale>, see
-the C<alias> attribute below.
+the C<alias> attribute below. NOTE: DateTime::Locale versions 0.92 and
+earlier use underscores rather than dashes, e.g. 'en_US'.
 
 =item full_days
 
@@ -1108,10 +1106,6 @@ custom label you prefer. Lookups, such as C<day('Sun')>, will still use
 the locale string, but when the calendar is rendered the aliased value
 will appear.
 
-=item head_week
-
-Specifies whether to display the week-of-year numbering. Default 0.
-
 =item week_begin
 
 Specify first day of the week, which can be 1..7, starting with Sunday.
@@ -1123,11 +1117,11 @@ is determined based on the locale.
 Set some handy CSS class attributes on elements, enabled by default.
 Currently the classes are:
 
-  hcm-table       Set on the <lt>table<gt> tag of the calendar
-  hcm-day-head    Set on the day-of-week <lt>tr<gt> or <lt>td<gt> tags
-  hcm-year-head   Set on the <lt>td<gt> tag for the year
-  hcm-month-head  Set on the <lt>td<gt> tag for the month
-  hcm-week-head   Set on the <lt>td<gt> tags for the week-of-year
+  hcm-table       Set on the E<lt>tableE<gt> tag of the calendar
+  hcm-day-head    Set on the day-of-week E<lt>trE<gt> or E<lt>tdE<gt> tags
+  hcm-year-head   Set on the E<lt>tdE<gt> tag for the year
+  hcm-month-head  Set on the E<lt>tdE<gt> tag for the month
+  hcm-week-head   Set on the E<lt>tdE<gt> tags for the week-of-year
 
 =item semantic_css
 
@@ -1136,9 +1130,9 @@ default. The notion of 'today' is taken either from the system clock
 (default) or from the 'today' parameter as provided to new(). Currently
 these classes are:
 
-  hcm-today    Set on the <lt>td<gt> tag for today, if present
-  hcm-past     Set on the <lt>td<gt> tags for prior days, if present
-  hcm-future   Set on the <lt>td<gt> tags for subsequent days, if present
+  hcm-today    Set on the E<lt>tdE<gt> tag for today, if present
+  hcm-past     Set on the E<lt>tdE<gt> tags for prior days, if present
+  hcm-future   Set on the E<lt>tdE<gt> tags for subsequent days, if present
 
 =item today
 
@@ -1394,7 +1388,7 @@ Matthew P. Sisk, E<lt>F<sisk@mojotoad.com>E<gt>
 
 =head1 COPYRIGHT
 
-Copyright (c) 1998-2010 Matthew P. Sisk. All rights reserved. All wrongs
+Copyright (c) 1998-2015 Matthew P. Sisk. All rights reserved. All wrongs
 revenged. This program is free software; you can redistribute it and/or
 modify it under the same terms as Perl itself.