--- mencal-2.3.orig/debian/control +++ mencal-2.3/debian/control @@ -0,0 +1,24 @@ +Source: mencal +Section: utils +Priority: optional +Maintainer: Debian Med Packaging Team +DM-Upload-Allowed: yes +Uploaders: Andreas Tille +Build-Depends: debhelper (>= 7), quilt +Standards-Version: 3.8.4 +Homepage: http://www.kyberdigi.cz/projects/mencal/english.html +Vcs-Browser: http://svn.debian.org/wsvn/debian-med/trunk/packages/mencal/trunk/?rev=0&sc=0 +Vcs-Svn: svn://svn.debian.org/svn/debian-med/trunk/packages/mencal/trunk/ + +Package: mencal +Architecture: all +Depends: ${perl:Depends}, ${misc:Depends} +Description: A menstruation calendar + Mencal is a menstruation calendar written in Perl. + . + It is a simple variation of the well-known Unix command cal. The main + difference is that you can have some periodically repeating days highlighted + in color. This can be used to track menstruation (or other) cycles + conveniently. + . + Author: C. McCohy --- mencal-2.3.orig/debian/install +++ mencal-2.3/debian/install @@ -0,0 +1 @@ +mencal usr/bin --- mencal-2.3.orig/debian/mencal.1 +++ mencal-2.3/debian/mencal.1 @@ -0,0 +1,90 @@ +.TH mencal "1" "Menstruation calendar" "mencal" "1" +.SH NAME +mencal \- menstruation calendar +.SH SYNOPSIS +.B mencal +[\fIoptions\fR] [\fIfile1 file2 \fR... \fI\-c CONF1 \-c CONF2 \fR...] +.SH DESCRIPTION + +.SS "Display options:" +.TP +\fB\-m\fR, \fB\-\-monday\fR +draw monday as first weekday (sunday is default) +.TP +\fB\-1\fR +current month (default) +.TP +\fB\-3\fR +previous, current and next month +.TP +\fB\-y\fR [YYYY] +all-year calendar (default YYYY is current year) +.TP +\fB\-q\fR, \fB\-\-quiet\fR +no top information will be printed +.TP +\fB\-n\fR, \fB\-\-nocolor\fR +noncolored output +.TP +\fB\-i\fR, \fB\-\-icolor\fR COLOR +intersection color (default red) +.IP +available colors: red, green, blue, yellow, violet, cyan, shiny, bold +.SS "mencal configuration:" +.TP +\fB\-c\fR, \fB\-\-config\fR +s=[YYYY]MMDD,l=LL,d=DD,n=NAME,f=FILE,c=COLOR +.IP +The second argument is a comma separated list of options. No spaces are +allowed in this list. If no name is specified, 'Unknown' is used. +Various \fB\-c\fR options or filenames can be set. +.TP +s,start=[YYYY]MMDD +start day of period (default current day) +.TP +l,length=LL +length of period in days (default 28) +.TP +d,duration=D +duration of menstruation in days (default 4) +.TP +n,name=NAME +name of subject +.TP +f,file=FILE +filename to save configuration to (see section FILES) +.IP +only menstruation related variables will be saved +.TP +c,color=COLOR +color used for menstruation days +.IP +available colors: red, green, blue, yellow, violet, cyan, shiny, bold +default color is red, with '\-n' switch color settings are ignored +.SS "Info options:" +.TP +\fB\-h\fR, \fB\-\-help\fR +print help +.TP +\fB\-V\fR, \fB\-\-version\fR +print version information +.SH FILES: +\fB$HOME/.mencalrc\fR +\- the default configuration file that is automatically loaded +.SH AUTHOR: +.I (C) 2002 C. McCohy +.br +e\-mail: +.br +Word\-Wide\-Web: http://www.kyberdigi.cz/projects/mencal/english +.PP +This manual page was written for the Debian GNU/Linux distribution because the +original program does not have a manual page (but may be used by others). +.SH HISTORY +22 March 2002 \- Originally written by Amaya Rodrigo . +.br +24 Apr 2002 \- New manpage contributed by Pablo S. Torralba . +.br +Amaya Rodrigo is now responsible for developing and +maintaining this manual page. Comments and suggestions are greatly wellcome. + --- mencal-2.3.orig/debian/watch +++ mencal-2.3/debian/watch @@ -0,0 +1,5 @@ +version=3 +http://www.kyberdigi.cz/projects/mencal/english.html mencal-(.*)\.tar\.gz + +# Other suggestion by Raphael Geissert (#449949) +# http://www.kyberdigi.cz/projects/mencal/mencal-(.*)\.tar\.gz --- mencal-2.3.orig/debian/manpages +++ mencal-2.3/debian/manpages @@ -0,0 +1 @@ +debian/mencal.1 --- mencal-2.3.orig/debian/docs +++ mencal-2.3/debian/docs @@ -0,0 +1,3 @@ +README +debian/mencalrc_example +debian/readme.html --- mencal-2.3.orig/debian/rules +++ mencal-2.3/debian/rules @@ -0,0 +1,3 @@ +#!/usr/bin/make -f +%: + dh $@ --with quilt --- mencal-2.3.orig/debian/README.source +++ mencal-2.3/debian/README.source @@ -0,0 +1 @@ +This package uses a patch system, see /usr/share/doc/quilt/README.source. --- mencal-2.3.orig/debian/changelog +++ mencal-2.3/debian/changelog @@ -0,0 +1,184 @@ +mencal (2.3-9) unstable; urgency=low + + * Team upload. + * Removed Matthew Wilcox from the uploaders list (Closes: #572505). + * Added a description to the patches in debian/patches, façon DEP-3. + * Incremented Standards-Version to reflect conformance with Policy 3.8.4 + (debian/control, no changes needed). + * Switched to Debhelper 7: debian/(compat, control, rules, install, manpages) + * Updated homepage in the manpage (debian/mencal.1). + * Point at version 2 of the GPL in debian/copyright. + + -- Charles Plessy Sun, 07 Mar 2010 23:46:45 +0900 + +mencal (2.3-8) unstable; urgency=low + + * New Maintainer Debian-Med Packaging Team + + * Group maintenance by Debian Med Team + * debian/control: + - DM-Upload-Allowed: yes + - Added myself to Uploaders + - Added Homepage + - Addef Vcs fields + - Removed version from debhelper + - New Build-Depends: quilt + * debian/rules: + - quilt to handle patch for executable + - DH_COMPAT=5 -> debian/compat + * Standards-Version: 3.8.0 (no changes needed) + * Fixed watch file (thanks to Raphael Geissert + for alternate suggestion) + Closes: #449949 + * Applied patch for daylightsaving (Thanks to Scott Barker + ) + Closes: #489203 + + -- Andreas Tille Mon, 21 Jul 2008 22:27:50 +0200 + +mencal (2.3-7) unstable; urgency=low + + * Upgraded to DH_COMPAT 5. + * Improved copyright and watch files + + -- Amaya Rodrigo Sastre Sun, 30 Jul 2006 01:59:57 +0200 + +mencal (2.3-6) unstable; urgency=low + + * Added myself to Uploaders, as requested by Amaya + * Updated Standards version to 3.7.2 + * Merge mencal and mencalnreg, incorporate updated patch. Closes: #344550 + * Switch from dh_installmanpges to dh_installman + * Fix lintian error by switching debhelper from Build-Depends-Indep to + Build-Depends + + -- Matthew Wilcox Mon, 10 Jul 2006 20:03:34 -0400 + +mencal (2.3-5) unstable; urgency=low + + * The "I love your patches" Release! + * Switch off color output when piping, patch by Sam Hocevar. + (Closes: #194322). + * Support having ~/.mencalrc read by default if such file exists. Patch by + Toni Timonen and manpage patch from Christian Hammers. (Closes: #312452) + * Include a special mencal for irregular cycles: mencalnreg. Patch from + Matthew Wilcox (Closes: #274722). + * Updated the example mencalrc provided. + * Updated Standards version, no changes needed. + + -- Amaya Rodrigo Sastre Fri, 4 Nov 2005 11:53:26 +0100 + +mencal (2.3-4) unstable; urgency=low + + * Removed Ian Murdock from Uploaders + + -- Amaya Rodrigo Sastre Sun, 19 Dec 2004 01:43:48 +0100 + +mencal (2.3-3) unstable; urgency=low + + * Updated DH_COMPAT=4 + + -- Amaya Rodrigo Sastre Fri, 27 Aug 2004 16:57:12 +0200 + +mencal (2.3-2) unstable; urgency=low + + * The "I am housekeeping" release. + * Updated Standards version. + * Added Ian Murdock to the Uploaders field. + * Manpage already fixed (Closes: #215747). + * Properly close bug fixed in NMU long, long time ago (Closes: #199892). + + -- Amaya Rodrigo Sastre Fri, 27 Aug 2004 04:44:58 +0200 + +mencal (2.3-1) unstable; urgency=low + + * New upstream release. + * The "my upstream is faster than me" release. + + -- Amaya Rodrigo Sastre Thu, 17 Jul 2003 14:12:07 +0200 + +mencal (2.2-1.1) unstable; urgency=low + + * NMU + * fix displaying problem on locales with one-letter daynames + (closes: #199892) + * Upgraded Standards version. Thanks lintian!!! + * Sponsored by Amaya herself. This is the "I'll sponsor your NMU" release. + + -- Uli Martens Wed, 17 Jul 2003 00:46:03 +0200 + +mencal (2.2-1) unstable; urgency=low + + * New upstream release. + * Improved manpage (Closes: #194288). + * Updated Standards-Version to 3.5.10 and Build-Depends on latest debhelper. + + -- Amaya Rodrigo Sastre Thu, 22 May 2003 14:39:27 +0200 + +mencal (2.1-4) unstable; urgency=low + + * Fix spelling (Closes: #193793) + + -- Amaya Rodrigo Sastre Wed, 21 May 2003 13:29:09 +0200 + +mencal (2.1-3) unstable; urgency=low + + * Something's definitely wrong with me today. Fixed the orig.tgz issue. + * Fixed readme.html fucked by Telefonica's "transparent" surfing proxy. + + -- Amaya Rodrigo Sastre Sat, 25 Jan 2003 04:48:42 +0100 + +mencal (2.1-2) unstable; urgency=low + + * Updated Standards-Version to 3.5.8. Oops! + + -- Amaya Rodrigo Sastre Sat, 25 Jan 2003 04:45:55 +0100 + +mencal (2.1-1) unstable; urgency=low + + * New upstream release. + * Improved description. + * Updated man page. Added a conf example by request of Héctor + . This is the "now everyone knows when I get my period" + release. + * Honored Developer's Reference "6.3.2 Upstream home" page and Author. + * Fixed minor Lintian warning. + + -- Amaya Rodrigo Sastre Sat, 25 Jan 2003 03:48:52 +0100 + +mencal (2.0-2) unstable; urgency=low + + * New manpage contributed by Pablo S. Torralba + (Closes: #142591). Many thanks. + + -- Amaya Rodrigo Sastre Wed, 24 Apr 2002 16:01:29 +0200 + +mencal (2.0-1) unstable; urgency=low + + * New upstream release. + * You can now keep track of multiple menstrual cycles (Closes: #139795). + * Updated manual page. + + -- Amaya Rodrigo Sastre Fri, 29 Mar 2002 20:26:03 +0100 + +mencal (1.1-3) unstable; urgency=low + + * Really closing #139794 now. How did I miss that? + + -- Amaya Rodrigo Sastre Thu, 28 Mar 2002 22:05:12 +0100 + +mencal (1.1-2) unstable; urgency=low + + * Forgot: Initial Release (Closes: #139420). + * Corrected typos in debian/readme.html. + * Changed arch to all (Closes: #139794). + * Corrected manual page (Closes: #139775). + + -- Amaya Rodrigo Sastre Thu, 28 Mar 2002 02:31:42 +0100 + +mencal (1.1-1) unstable; urgency=low + + * Added a manual page. + + -- Amaya Rodrigo Sastre Fri, 22 Mar 2002 02:11:02 +0100 + --- mencal-2.3.orig/debian/readme.html +++ mencal-2.3/debian/readme.html @@ -0,0 +1,354 @@ + + + + + + Menstruation calendar + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ Kyberdigi Labs + +

Menstruation calendar

+ by C. McCohy <mccohy@kyberdigi.cz>
+ Actual version: 2.3 +
+ + + + + +
+ Use your computer for superb timing of all your activities + + cz + en +
+
+ + + + + + + +
+ Kyberdigi Labs
+ Projects
+ Mencal
+ + Requirements
+ License
+ Download
+ Installation
+ Running mencal
+ Examples
+ Known bugs
+ Changelog
+ Archive
+ Misc
+ +

+ Visitors
+ Counter +

+ +

+ +

Menstruation calendar

+ + Mencal is a simple variation of the well-known unix command cal. The main difference is that you can have some periodically repeating days highlighted in color. This can be used to track menstruation (or other) cycles conveniently. + +
+ +

Requirements

+ + This program is written in the perl language. It also uses the unix locales and the system commands strftime and mktime. + I don't know which systems have all those, + but at least any linux distribution should provide you with everything necessary for running mencal. + +
+ +

License

+ + The software may be freely distributed under the terms of the GPL.
+ You can read the license here. +

+ + +


+ +

Download

+ + You can download the complete tarball via HTTP right here. +

+ + mencal-2.3.tar.gz

+ size: 19169 bytes
MD5: e0fa5665b8f7772521bb95379bfdec20
+

+ +


+ +

Installation

+ + First: unpack the archive +
$ tar xzf mencal-2.3.tar.gz
+ + Now enter the directory mencal-2.3 that was created. +
$ cd mencal-2.3
+ + And that's about all. This directory also contains a tiny README file, + a copy of the license and the most important file mencal. + You can run this program even as an unprivileged user with the command + ./mencal. You can copy the file to wherever it's convenient for you and run it from there. +

+ +


+ +

Running mencal

+ + You run the program like this: +
$ mencal [options] [file1 file2 ... -c CONF1 -c CONF2 ... ]
+ + Display options: +
    +
  • -m or --monday - take monday as the first day of the week + (sunday is the default) +
  • -1 - print the current month (default) +
  • -3 - print the previous, current and next month +
  • -y [yyyy] - print a calendar for the whole year yyyy. + If the year is not given, the current year is used. +
  • -q or --quiet - don't print the introduction +
  • -n or --nocolor - don't use color in the output +
  • -i COLOR or --icolor COLOR - intersection color + (the default is red, other possible are green, blue, yellow, violet, + cyan, shiny (intense white) and bold (not really a color)) +
+

+ + Menstruation options:
+ -c or --config s=[YYYY]MMDD,l=DD,d=T,n=NAME,f=FILE,c=COLOR +

+ The second argument is a comma separated list of options. No spaces are + allowed in this list. If no name is specified, 'Unknown' is used. + Various -c options or filenames can be set. +

    +
  • s,start=[YYYY]MMDD - zaèátek cyklu (standardnì aktuální den) +
  • l,length=DD - length of period in days (default 28) +
  • d,duration=T - duration of menstruation in days (default 4) +
  • n,name=NAME - name of subject +
  • f,file=FILE - filename to save configuration to + (only menstruation related variables will be saved) +
  • c,color=COLOR - color used for menstruation days of subject + (available colors are the same as with --icolor, + the switch -n will cause this color setting to be ignored) +
+

+ + Informational options: +

    +
  • -h or --help - prints help on options +
  • -V or --version - prints version information +
+

+ +


+ +

Examples

+ +
    +
  • Example 1 - a simple example of three current months +
  • Example 2 - an example of a full setting of a particular mentruation cycle in an unusual yellow color +
  • Example 3 - a calendar for a whole year for two persons, the settings for one are taken from the file maruskarc, + the days, when both persons are menstruating, are marked red +
  • Example 4 - + the same settings as example 3, no colors (suitable for printing or for some monochrome terminals), without the starting info +
  • Example 5 a Example 6 + - a bit over-done ... +
+

+ +


+ +

Known bugs

+ + Incorrect day names displaying
+ In some cases of special locales setings the day names are displayed incorrectly. + For example if one uses hu_HU, some day names have only one character, which + can cause table damage. Thank to Peter Gervai for bug info.
+ Solved: upgrade to version 2.3.

+ + Error message typo
+ Micah Anderson wrote about a typo in one of error messages you can see + after bad parameter settings.
+ Solved: upgrade to version 2.2.

+ + The 'more' command
+ The only real problem occurs when you are using the command more on + the colored output, e.g. $ mencal -y -c c=red | more ... it all gets + messed up
+ Solved: use more -f or less -R. + Thanks to Peter K. Gale for this hint. +

+ + The year must be greater than 1900
+ Regrettably you can't use years below 1900. The cause is that perl + works with years decremented by 1900. So if you use the year 2002, perl + has to convert it to 102. And it of course refuses to use negative numbers. If you have any ideas how to work around this, please tell me.

+ + Localisation
+ The names of days and months are taken from locales, so it would probably be nice to localize the help and program messages. + There are not that many messages, in fact. Well, next time. ;-) +

+ + Color printing
+ I have some messages, that it is impossible to print the colored output on + a printer ($ mencal | lpr), that the output on the paper looks really bad. + It's possible. I'm sorry, but I don't have any printer to look at it and take + care about. Use the -n switch for non-colored output. +

$ mencal -n | lpr
+

+ + Year change
+ While using the -3 switch for printing of three actual months + (i.e. november, december, january) some month is not printed.
+ Solved: upgrade to version 2.1, where this bug is already fixed. + Thanks to Jára Altmann for bugreport.

+ + Bugs from version 1.1
+ There's only a few lines left from 1.0 and the rest was completely rewritten. + The old bugs seem to be gone. The configuration doesn't become invalid after one year and you don't have to set it up again. + The brain-damage of the old configuration files has also been eliminated. +

+ + If you think you found a bug, don't hesitate to use your favourite mail client + and mail me. +

+ + +


+ +

Changelog

+ +
+
+2.3 (Jul 17th, 2003)
+
+- fixed incorrect displaying of some day names
+
+2.2 (May 22nd, 2003)
+
+- fixed error message typo
+
+2.1 (December 9th, 2002)
+
+- bugfix: some months are not printed if '-3' is used
+- optimization of counting menstruation days
+
+2.0 (March 29th, 2002)
+
+- initial primitive version total rewrited
+- more configurations available
+- merging of configurations
+- other program switches
+- non-colored output
+- actual three months can be printed
+
+1.1 (October 25th, 2000)
+
+- configuration can be saved
+- some minor bugfixes
+- localization (use of locales)
+
+1.0 (mesozoic era)
+
+- initial primitive version
+
+ +
+ +

Archive

+ + +

+ + +


+ +

Misc

+ + I thank Vinil for the his intensive cooperation, inspiration and propagation + (the quote about timing is from him too) and JD for testing, moral backing + and correction.

+ + And here's an inspiring response from the maintainer of the mencal debian package:

+ + + I really love this script, because nobody but you ever bothered writing it :-) + I am very proud of you because you wrote this for your girlfriend and + I guess that was an act of love :-) + +

+ +

+ +
+ + + + + +
Valid HTML 4.01Kyberdigi Labs
+
+
+ +
+ + + --- mencal-2.3.orig/debian/copyright +++ mencal-2.3/debian/copyright @@ -0,0 +1,14 @@ +This package was debianized by Amaya Rodrigo Sastre on +Fri, 22 Mar 2002 02:11:02 +0100. + +It was downloaded from http://mencal.kyberdigi.cz/english.html + +Upstream Author: C. McCohy + +Copyright: (C) 2001-2003 C. McCohy + +License: +This program is free software, under the GPLv2. + +On Debian systems, the complete text of the GNU General Public License +version 2 can be found in `/usr/share/common-licenses/GPL-2'. --- mencal-2.3.orig/debian/README.Debian +++ mencal-2.3/debian/README.Debian @@ -0,0 +1,10 @@ +mencal for Debian +----------------- + +It turned out that the author has not issued a new version since +2003. There is an extensive patch applied in the Debian package +which was done by former maintainers. If you think this program +is useful and you would like to add some enhancements you should +probably think about becoming upstream maintainer yourself. + + -- Andreas Tille Mon, 21 Jul 2008 22:27:50 +0200 --- mencal-2.3.orig/debian/compat +++ mencal-2.3/debian/compat @@ -0,0 +1 @@ +7 --- mencal-2.3.orig/debian/mencalrc_example +++ mencal-2.3/debian/mencalrc_example @@ -0,0 +1,41 @@ +start 20051027 +duration 7 +color red +name Amaya +start 20050911 +duration 6 +color red +name Amaya +start 20050814 +length 30 +duration 6 +color red +name Amaya +start 20050708 +length 30 +duration 6 +color red +name Amaya +start 20041210 +length 30 +duration 6 +color red +name Amaya +start 20020517 +length 26 +duration 4 +color red +name Amaya +start 20020612 +length 28 +color red +name Amaya +start 20020517 +length 26 +duration 4 +color red +name Amaya +start 20020612 +length 28 +color red +name Amaya --- mencal-2.3.orig/debian/patches/10_daylightsaving.patch +++ mencal-2.3/debian/patches/10_daylightsaving.patch @@ -0,0 +1,28 @@ +Description: Repairs daylight savings time bug. + mencal does not account for daylight savings time when calculating the + variable '$day' in the markdays() subroutine, resulting in fractional + values for '$day', which breaks mencal if the start date and current + date are in different daylight savings time states. + . + This may actually be due to changed behaviour in POSIX::mktime back in + 2007, where mktime now sets isdst=-1 by default, instead of setting + isdst=0 by default. + . + This patch fixes this problem simply by ensuring that '$day' is + an integer. +Origin: vendor, http://bugs.debian.org/489203 +Bug-Debian: http://bugs.debian.org/489203 +Forwarded: no +Author: Scott Barker + +--- mencal-2.3.orig/mencal ++++ mencal-2.3/mencal +@@ -184,7 +184,7 @@ + + sub markdays { + my ($self, $begin, $end, $date, $length) = (shift, shift, shift, shift, shift); +- my $day = ($date - $begin) / (24 * 3600) + 1; ++ my $day = int(($date - $begin) / (24 * 3600) + 1); + my $limit = $date + $length; + $limit = $end if ($end < $limit); + while ($date < $limit) { --- mencal-2.3.orig/debian/patches/series +++ mencal-2.3/debian/patches/series @@ -0,0 +1,2 @@ +10_mencal.patch +10_daylightsaving.patch --- mencal-2.3.orig/debian/patches/10_mencal.patch +++ mencal-2.3/debian/patches/10_mencal.patch @@ -0,0 +1,213 @@ +Description: Monolithic patch that combines multiple combinations. + Warning: the list below may be incomplete. +Bug-Debian: http://bugs.debian.org/312452 +Author: Toni Timonen +Bug-Debian: http://bugs.debian.org/194322 +Author: Sam Hocevar +Bug-Debian: http://bugs.debian.org/274722 or http://bugs.debian.org/344550 +Author: Matthew Wilcox +Forwarded: do not know… + +--- mencal-2.3.orig/mencal ++++ mencal-2.3/mencal +@@ -100,22 +100,15 @@ + + sub new { + my $type=shift; ++ my @starts; + my $self={ +- 'start' => shift || '', ++ 'start' => \@starts, + 'length' => shift || 28, + 'duration' => shift || 4, + 'name' => shift || 'Unknown', + 'color' => lc(shift) || 'red', + 'days' => '' + }; +- if($self->{'start'}!~/^[0-9]{8}$/) { +- my @localtime=localtime(); +- if($self->{'start'}=~/^[0-1][0-9][0-3][0-9]$/) { +- $self->{'start'}=($localtime[5]+1900).$self->{'start'}; +- } else { +- $self->{'start'}=($localtime[5]+1900).sprintf("%02d", $localtime[4]+1).sprintf("%02d", $localtime[3]); +- } +- } + $self->{'color'}=~/^(nocolor|red|green|blue|yellow|violet|cyan|shiny|bold)$/ || ($self->{'color'}='red'); + $self->{'length'}=~/^[0-9]+$/ || do { $self->{'length'}=28; }; + $self->{'duration'}=~/^[0-9]+$/ || do { $self->{'duration'}=4; }; +@@ -127,10 +120,11 @@ + my $self=shift; + (my $filename=shift) || return(0); + open(FILE, $filename) || return(0); ++ my $starts = $self->{'start'}; + while() { + chomp; + (/^#/ || /^$/) && next; +- /^start ([0-9]{8})$/ && do { $self->{'start'}=$1; next; }; ++ /^start ([0-9]{8})$/ && do { push @{$starts},$1; next; }; + /^length ([0-9]+)$/ && do { $self->{'length'}=$1; next; }; + /^duration ([0-9]+)$/ && do { $self->{'duration'}=$1; next; }; + /^color (nocolor|red|green|blue|yellow|violet|cyan|shiny|bold)$/ && do { $self->{'color'}=$1; next; }; +@@ -147,13 +141,14 @@ + my $self=shift; + (my $str=shift) || return(0); + my $filename=''; ++ my $starts = $self->{'start'}; + foreach(split(',', $str)) { + /^(s|start)=([0-9]{4})$/ && do { + my @localtime=localtime(); +- $self->{'start'}=($localtime[5]+1900).$2; ++ push @{$starts},($localtime[5]+1900).$2; + next; + }; +- /^(s|start)=([0-9]{8})$/ && do { $self->{'start'}=$2; next; }; ++ /^(s|start)=([0-9]{8})$/ && do { push @{$starts},$2; next; }; + /^(l|length)=([0-9]+)$/ && do { $self->{'length'}=$2; next; }; + /^(d|duration)=([0-9]+)$/ && do { $self->{'duration'}=$2; next; }; + /^(c|color)=(nocolor|red|green|blue|yellow|violet|cyan|shiny|bold)$/ && do { $self->{'color'}=$2; next; }; +@@ -165,7 +160,10 @@ + ($self->{'duration'}>=$self->{'length'}) && do { $self->{'duration'}=$self->{'length'}; }; + if($filename) { + if(open(RC, ">$filename")) { +- foreach my $key ('start', 'length', 'duration', 'color', 'name') { ++ foreach my $date (@{$starts}) { ++ print RC 'start '.$date."\n"; ++ } ++ foreach my $key ('length', 'duration', 'color', 'name') { + print RC $key.' '.$self->{$key}."\n"; + } + close(RC); +@@ -177,27 +175,76 @@ + return(1); + } + ++ sub date2sec { ++ my $date = shift; ++ $date =~ /^([0-9]{4})([0-9]{2})([0-9]{2})$/; ++ my ($sy, $sm, $sd) = ($1, $2, $3); ++ return mktime(0, 0, 0, $sd, ($sm-1), ($sy-1900)); ++ } ++ ++ sub markdays { ++ my ($self, $begin, $end, $date, $length) = (shift, shift, shift, shift, shift); ++ my $day = ($date - $begin) / (24 * 3600) + 1; ++ my $limit = $date + $length; ++ $limit = $end if ($end < $limit); ++ while ($date < $limit) { ++ $self->{'days'} .= $day.'#' if ($day > 0); ++ $day++; ++ $date += 24 * 3600; ++ } ++ } ++ ++ sub getnext { ++ my $self = shift; ++ my $first = shift; ++ my $starts = $self->{'start'}; ++ my $length = $self->{'length'} * 24 * 3600; ++ my $n_s = scalar @{$starts}; ++ my $best; ++ ++ if (($n_s > 0) && (date2sec($starts->[0]) <= $first) && ++ ($first <= date2sec($starts->[($n_s - 1)]))) { ++ foreach (@{$starts}) { ++ $best = date2sec($_); ++ last if $best >= $first; ++ } ++ return $best; ++ } ++ ++ if ($n_s == 0) { ++ $best = strftime "%Y%m%d", localtime; ++ } elsif ($first < date2sec($starts->[0])) { ++ $best = date2sec($starts->[0]); ++ } else { ++ $best = date2sec($starts->[$n_s - 1]); ++ } ++ ++ while ($best > ($first + $length)) { ++ $best -= $length; ++ } ++ ++ while ($best < $first) { ++ $best += $length; ++ } ++ ++ return $best; ++ } ++ + sub getdays { +- my $self=shift; +- my ($year, $month)=(shift, shift); +- $self->{'days'}='#'; +- $self->{'start'}=~/^([0-9]{4})([0-9]{2})([0-9]{2})$/; +- my ($sy, $sm, $sd)=($1, $2, $3); +- +- my $month_first=mktime(0, 0, 0, 1, ($month-1), ($year-1900)); +- my $month_next=mktime(0, 0, 0, 1, $month, ($year-1900)); +- my $actday=mktime(0, 0, 0, $sd, ($sm-1), ($sy-1900)); +- while($actday>=$month_first) { $actday-=24*3600*$self->{'length'}; } +- while(($actday+24*3600*$self->{'length'})<$month_first) { $actday+=24*3600*$self->{'length'}; } +- $self->{'start'}=strftime("%Y%m%d", localtime($actday)); +- +- my ($i, $duration, $first, $onmonth)=(0, 0, 0, 0); +- while($actday<$month_next) { +- (!$onmonth) && ($actday>=$month_first) && do { $first=$i; $onmonth++; }; +- ($duration<$self->{'duration'}) && ($actday>=$month_first) && ($self->{'days'}.=($i-$first+1).'#'); +- $duration++; $i++; +- $actday+=24*3600; +- ($duration==$self->{'length'}) && ($duration=0); ++ my $self = shift; ++ my ($year, $month) = (shift, shift); ++ my $duration = $self->{'duration'} * 24 * 3600; ++ $self->{'days'} = '#'; ++ ++ my $month_first = mktime(0, 0, 0, 1, ($month-1), ($year-1900)); ++ my $month_next = mktime(0, 0, 0, 1, $month, ($year-1900)); ++ my $first_interesting = $month_first - $duration; ++ ++ my $actday = $self->getnext($first_interesting); ++ ++ while ($actday < $month_next) { ++ markdays($self, $month_first, $month_next, $actday, $duration); ++ $actday = $self->getnext($actday + $duration + 1); + } + } + +@@ -223,12 +270,19 @@ + 'topline' => 'Su Mo Tu We Th Fr Sa', + 'month_delimiter_h' => " ", + 'month_delimiter_v' => "\n", +- 'nocolor' => 0, ++ 'nocolor' => (not POSIX::isatty('STDOUT')), + 'icolor' => 'red', + 'quiet' => 0 + ); + my @confs=(); + ++ #There exists a config file ++ $_ = "$ENV{HOME}/.mencalrc"; ++ if (-f $_ && -r $_) { ++ push(@confs,Conf->new()); ++ $confs[$#confs]->parsefile($_); ++ } ++ + for(my $i=0; $i<=$#ARGV; $i++) { + foreach($ARGV[$i]) { + /^(-h|--help)$/ && &Main::usage; +@@ -241,6 +295,7 @@ + }; + /^(-q|--quiet)$/ && do { $config{'quiet'}=1; last; }; + /^(-m|--monday)$/ && do { $config{'monday_first'}=1; last; }; ++ /^(-C|--color)$/ && do { $config{'nocolor'}=0; last; }; + /^(-n|--nocolor)$/ && do { $config{'nocolor'}=1; last; }; + /^(-i|--icolor)$/ && do { + (($#ARGV>$i) && ($ARGV[++$i]=~/^(red|green|blue|yellow|violet|cyan|shiny|bold)$/)) || &Main::out("Invalid intersection color, see '-h' for more details"); +@@ -362,6 +417,7 @@ + " -3 previous, current and next month\n". + " -y [YYYY] all-year calendar (default YYYY is current year)\n". + " -q, --quiet no top information will be printed\n". ++ " -C, --color colored output (default)\n". + " -n, --nocolor noncolored output\n". + " -i, --icolor COLOR intersection color (default red)\n". + " available colors: red, green, blue, yellow, violet, cyan, shiny, bold\n".