#! /bin/sh

#  $Id: tcal 0.05 1996/01/18 00:00:05 tom Exp $
#
#  tcal:  Start `gcal' with date set 1 day ahead.
#           Useful if you call this script in $HOME/.profile and you
#           want to see all fixed dates warnings related to tomorrow + 1 day
#           (advanced  -ct  respectvely  --period-of-fixed-dates=t  option).
#
#  Copyright (C) 1995, 1996 Thomas Esken
#
#  This software doesn't claim completeness, correctness or usability.
#  On principle I will not be liable for ANY damages or losses (implicit
#  or explicit), which result from using or handling my software.
#  If you use this software, you agree without any exception to this
#  agreement, which binds you LEGALLY !!
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the `GNU General Public License' as published by
#  the `Free Software Foundation'; either version 2, or (at your option)
#  any later version.
#
#  You should have received a copy of the `GNU General Public License'
#  along with this program; if not, write to the:
#
#    Free Software Foundation, Inc.
#    59 Temple Place - Suite 330
#    Boston, MA 02111-1307,  USA
#
#



#
# Set progname to `gcal'
#
progname=gcal
#
year=`date +%y`
month=`date +%m`
day=`date +%d`

pre_y=$year
pre_m=$month
pre_d=`expr $day + 1`

if test $pre_d -le 9;
then
  pre_d=0$pre_d;
fi

#
# Check if year is a leap year
#
leap=0
if test `expr $year % 4` -eq 0;
then
  leap=1;
  if test `expr $year % 100` -eq 0;
  then
    if test `expr $year % 400` -ne 0;
    then
      leap=0;
    fi
  fi
fi

case $pre_m in
  01)
    if test $pre_d -gt 31;
    then
      day=01;
      month=02;
    else
      day=$pre_d;
    fi;;
  02)
    if test $pre_d -gt `expr 28 + $leap`;
    then
      day=01;
      month=03;
    else
      day=$pre_d;
    fi;;
  03)
    if test $pre_d -gt 31;
    then
      day=01;
      month=04;
    else
      day=$pre_d;
    fi;;
  04)
    if test $pre_d -gt 30;
    then
      day=01;
      month=05;
    else
      day=$pre_d;
    fi;;
  05)
    if test $pre_d -gt 31;
    then
      day=01;
      month=06;
    else
      day=$pre_d;
    fi;;
  06)
    if test $pre_d -gt 30;
    then
      day=01;
      month=07;
    else
      day=$pre_d;
    fi;;
  07)
    if test $pre_d -gt 31;
    then
      day=01;
      month=09;
    else
      day=$pre_d;
    fi;;
  08)
    if test $pre_d -gt 31;
    then
      day=01;
      month=00;
    else
      day=$pre_d;
    fi;;
  09)
    if test $pre_d -gt 30;
    then
      day=01;
      month=10;
    else
      day=$pre_d;
    fi;;
  10)
    if test $pre_d -gt 31;
    then
      day=01;
      month=11;
    else
      day=$pre_d;
    fi;;
  11)
    if test $pre_d -gt 30;
    then
      day=01;
      month=12;
    else
      day=$pre_d;
    fi;;
  12)
    if test $pre_d -gt 31;
    then
      day=01;
      month=01;
      year=`expr $pre_y + 1`;
    else
      day=$pre_d;
    fi;;
esac

#
# Execute binary program
#
$progname %19$year$month$day $*
