#!/bin/sh

# Requires date and sort.

THEDATE=""
case $1
  in
  20[0-5][0-9]-[01][0-9]-[0-3][0-9])
    THEDATE=$1
    shift
    ;;
  *)
    THEDATE=`date +%Y-%m-%d`
    ;;
esac

THETIME=""
THEIMPORT=""
case $1
  in
  A|B|C|D)
    THEIMPORT=$1
    shift
  ;;
  [012][0-9]:[0-5][0-9])
    THETIME=$1
    shift
  ;;
  *)
    THEIMPORT=B
    ;;
esac

mv plan.txt plan.bak.txt
cp plan.bak.txt plan.next.txt
echo $THEDATE $THEIMPORT $THETIME $* >>plan.next.txt
sort plan.next.txt >plan.txt
rm plan.next.txt

# What's with the "shift" below?
#clear; while [ 0 -lt $# ]; do shift; done; . chores.sh <plan.txt
clear; while [ 0 -lt $# ]; do shift; done; python plans.py <plan.txt

