/*********************************************
Days Past

This program reads a start date and an end date
from the user, and prints out the number of
days ellapsed between the two.

The key to the problem is to write a function
"monthread()" that reads a month from the user
and returns the number of days from New Year's
to the beginning of that month.
 *********************************************/
#include <iostream>
#include <string>
using namespace std;

int monthread();

/*********************************************
 ** main() functions
 *********************************************/
int main()
{
  int a, ds, df;
  // Get # of days from New Year's to start
  cout << "Enter start  date (e.g. 27 Mar): ";
  cin >> a;
  ds = a + monthread();

  // Get # of days from New Year's to finish  
  cout << "Enter ending date (e.g. 13 Jul): ";
  cin >> a;
  df = a + monthread();

  // Print out number of days in between
  cout << "That lasted " << df - ds << " days.  "
       << "Or " << df - ds + 1 << " depending on "
       << "how you count."
       << endl;

  return 0;
}

/*********************************************
 ** Reads a month and returns the number of
 ** days from New Year's to that month
 *********************************************/
int monthread()
{
  // Read in the 
  string M;
  cin >> M;

  // Get # of days from month
  int d;
  if      (M == "Jan")
    d = 0;
  else if (M == "Feb")
    d = 31;
  else if (M == "Mar")
    d = 59;
  else if (M == "Apr")
    d = 90;
  else if (M == "May")
    d = 120;
  else if (M == "Jun")
    d = 151;
  else if (M == "Jul")
    d = 181;
  else if (M == "Aug")
    d = 212;
  else if (M == "Sep")
    d = 243;
  else if (M == "Oct")
    d = 273;
  else if (M == "Nov")
    d = 304;
  else
    d = 334;

  return d;
}