Calendar-Schedule

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

Makefile.PL        # Makefile generator
META.yml           # Meta-information
LICENSE
Schedule.pm        # Main module
bin/cal2html       # a CLI program
t/test-lib.pl	   # Helpful testing functions
t/01.t             # Test case 01
t/01-example1      # Test input
t/01-example1.html # Test expected output
t/02.t             # Test case 02, CLI cal2html
t/02-calendar      # Test 02 input
t/02-calendar.html # Test 02 output
META.json                                Module JSON meta-data (added by MakeMaker)

META.json  view on Meta::CPAN

{
   "abstract" : "manage calendar schedules",
   "author" : [
      "Vlado Keselj vlado@dnlp.ca http://vlado.ca"
   ],
   "dynamic_config" : 1,
   "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.json  view on Meta::CPAN

         }
      },
      "runtime" : {
         "requires" : {}
      }
   },
   "release_status" : "stable",
   "resources" : {
      "repository" : {
         "type" : "git",
         "url" : "https://github.com/vkeselj/calendar-schedule.git",
         "web" : "https://github.com/vkeselj/calendar-schedule"
      }
   },
   "version" : "1.21"
}

META.yml  view on Meta::CPAN

---
abstract: 'manage calendar schedules'
author:
  - 'Vlado Keselj vlado@dnlp.ca http://vlado.ca'
build_requires:
  ExtUtils::MakeMaker: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: Calendar-Schedule
no_index:
  directory:
    - t
    - inc
requires: {}
resources:
  repository: https://github.com/vkeselj/calendar-schedule.git
version: '1.21'

Makefile.PL  view on Meta::CPAN

   ($] >= 5.005 ?    ## Add these new keywords supported since 5.005
    (ABSTRACT_FROM => $name, # retrieve abstract from module
     AUTHOR     => 'Vlado Keselj vlado@dnlp.ca http://vlado.ca') : 
    ()
   ),
   (eval { ExtUtils::MakeMaker->VERSION(6.46) } ? (META_MERGE => {
     'meta-spec' => { version => 2} ,
     resources => {
       repository => {
         type => 'git',
	 url => 'https://github.com/vkeselj/calendar-schedule.git',
         web => 'https://github.com/vkeselj/calendar-schedule',
	 }}}):() ));

open(M, ">>Makefile") or die;

if ( -f 'priv.make' ) { print M &getfile('priv.make') }

close(M);

sub getfile($) {
    my $f = shift;

README  view on Meta::CPAN

Calendar::Schedule version 1.21
===============================
Note: The above lines are generated based on the following code:
<? read_starfish_conf(); &set_readme_line1; !>

This is a Perl module for handling calendar schedules.  Documentation
is a part of Schedule.pm in the pod format.  To convert it into manual
page format, type something like the following:

	  pod2html Schedule.pm

INSTALLATION

To install this module type the following:

   perl Makefile.PL

Schedule.pm  view on Meta::CPAN

# Calendar::Schedule - Manage calendar schedules
# (c) 2002-2020 Vlado Keselj http://web.cs.dal.ca/~vlado vlado@dnlp.ca
#               and contributing authors
#
# Some parts are updated with Starfish during development, such as the version
# number: <? read_starfish_conf !>

package Calendar::Schedule;
use strict;
require Exporter;
use POSIX;

Schedule.pm  view on Meta::CPAN

our $VERSION = '1.21';#-

# non-exported package globals
use vars qw( $REweekday3 $REmonth3 $RE1st );
$RE1st = qr/first|second|third|fourth|fifth|last|1st|2nd|3rd|4th|5th/;
$REweekday3 = qr/Mon|Tue|Wed|Thu|Fri|Sat|Sun/;
$REmonth3 = qr/Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/;

=head1 NAME

Calendar::Schedule - manage calendar schedules

=head1 SYNOPSIS

    use Calendar::Schedule qw/:all/;

    my $TTable = Calendar::Schedule->new();

    # manually adding an entry
    $TTable->add_entry('2003-09-09 Tue 18-20 Some meeting');
                              
    # reading entries from a file
    $TTable->add_entries_from("$ENV{'HOME'}/.calendar");

    # producing entries in HTML tables, one table per week
    $TTable->set_first_week('now');
    print "<p>\n" . $TTable->generate_table();
    print "<p>\n" . $TTable->generate_table();
    print "<p>\n" . $TTable->generate_table();

    # for more examples, see EXAMPLES section

The file .calendar may look like this:

  # comments can start with #
  * lines starting with * are treated as general todo entries ...
  # empty lines are acceptable and ignored:

  Mon 9:00-10:00 this is a weekly entry
  Mon 13-14 a biweekly entry :biweekly :start Mar 8, 2004
  Mon,Wed,Fri 15:30-16:30 several-days-a-week entry
  Wed :biweekly garbage collection

Schedule.pm  view on Meta::CPAN

        weekday is entered).  BTW, an entry can go for several lines as\
        long as there is a backslash at the end of each line.

  May   6      birthday (yearly entry)

  # more examples in "Example entries" section

=head1 DESCRIPTION

The module is created with a purpose to provide functionality for handling a
personal calendar schedule in a transparent and simple way.  The calendar
data is assumed to be kept in a plain file in a format easy to edit and
understand.  It was inspired by the C<calendar> program on older Unix-like
systems, which used C<~/.calendar> file to produce entries for each day
and send them in the morning by email.

Inspired by the C<~/.calendar> file, the format for recording scheduled
events is very simple, mostly contained in one line of text.

The module currently supports generation of HTML weekly tables with visual
representation of scheduled events.  The generated table is generated in
a simple HTML table, with a use of C<colspan> and C<rolspan> attributes to
represent overlapping events in parallel in the table.

=head2 Planned Future Work

In the development of the recording format for the event, there is an attempt

Schedule.pm  view on Meta::CPAN

First example:

    use Calendar::Schedule qw/:all/;

    my $TTable = Calendar::Schedule->new();

    # manually adding an entry
    $TTable->add_entry('2003-09-09 Tue 18-20 Some meeting');
                              
    # reading entries from a file
    $TTable->add_entries_from("$ENV{'HOME'}/.calendar");

    # producing entries in HTML tables
    $TTable->set_first_week('2003-12-15');
    print "<p>\n" . $TTable->generate_table();
    print "<p>\n" . $TTable->generate_table();
    print "<p>\n" . $TTable->generate_table();

Example with generating a weekly schedule (example2):

    use Calendar::Schedule;

Schedule.pm  view on Meta::CPAN

    { $starttime -= 60 }

    while ((localtime($starttime))[0] != 0)
    { $starttime -- }

    return $starttime;
}

=item parse_time(time_specification[,prefix])

Parses time specification and returns the calendar time (see mktime in
Perl).  The functions dies if the time cannot be completely recognized.
If prefix is set to true (1), then only a prefix of the string can be
a time specification.  If prefix is set to 1, then in an array context
it will return a 2-element list: the calendar time and the
remainder of the string.  Format examples:

  2004-03-17
  now
  Mar 8, 2004
  1-Jul-2005

=cut
#mktime(sec,min,hour,mday,mon,year,wday=0,yday=0,isdst=0)
#mon,wday,yday start with 0,wday starts with Sun,year starts with 1900

Schedule.pm  view on Meta::CPAN


This script is provided "as is" without expressed or implied warranty.
This is free software; you can redistribute it, modify it, or both under
the same terms as Perl itself.

The latest version can be found at
L<http://vlado.ca/srcperl/Calendar-Schedule/>.

=head1 SEE ALSO

There are some Perl modules for different types of calendar, and
likely may more in other programming languages.  I could not find any
existing calendars including the particular features that I needed, so
this module was created.  Below are some modules with similar
functionality:

=over 4

=item [HTML::CalendarMonthSimple] - Perl Module for Generating HTML Calendars

The module is written as a simplifed version of HTML::CalendarMonth.
The intention for this, Calendar::Schedule module, is not to tie it essentially
for HTML.  The events specification is described in a simple textual format.

=item [HTML::CalendarMonth] - Generate and manipulate HTML calendar months

The module HTML::CalendarMonth is a subclass of HTML::ElementTable,
which makes it a part of larger project--the Date-Time Perl project at
F<http://datetime.perl.org>.

=back

=cut

bin/cal2html  view on Meta::CPAN

#!/usr/bin/perl
# cal2html - generate HTML from a calendar schedule
# Part of the Calendar::Schedule module package
use Calendar::Schedule qw/:all/;
my $TTable = Calendar::Schedule->new();

# Check for command-line options
my @tmp; for $a (@ARGV) {
  if ($a =~ /^--ColLabel=/) { $TTable->{ColLabel} = $'; }
  else { push @tmp, $a; } }
@ARGV = @tmp;

while (<>) { $TTable->add_entries($_); }
$TTable->set_first_week('now');
print "<html><body>\n<p>\n" . $TTable->generate_table();

exit 0;
__END__ # Documentation

=head1 NAME

cal2html - generate HTML from a calendar schedule

=head1 SYNOPSIS

 $ cal2html  # to process standard input into standard output
 $ cal2html --ColLabel='weekday %w' cal-file > cal.html

=head1 DESCRIPTION

The command C<cal2html> is a part of C<Calendar::Schedule> Perl package.
It reads calendar schedule specification from the standard input, or given
files, and produces an HTML table with the events.

=cut

t/02.t  view on Meta::CPAN

#!/usr/bin/perl
use Test::More;
use lib '.';
require "t/test-lib.pl";

my $o = `perl -I. -- ./bin/cal2html --ColLabel=weekday_%w t/02-calendar`;
is($o, getfile('t/02-calendar.html'), '02.t');

done_testing();



( run in 0.559 second using v1.01-cache-2.11-cpan-c333fce770f )