-í
µe>c       s&     d  Z   	 d f  d „  ƒ  YZ d S(   sÏ   
Date.py - by Richard Shiao

Represents dates on the Gregorian Calendar, containing fields for
four digit year, two digit month, and two digit day.  Includes
comparision, addition, and subtraction features.
s   Datec      s:  	 
 h  Z   d e  d < d e  d < d e  d < d e  d < d	 e  d
 < d e  d < d e  d < d e  d < d e  d < d e  d < d e  d < d e  d < d „  Z ( d „  Z 6 d d d d „ Z @ d „  Z H d d „ Z Q d  „  Z f d! „  Z u d" „  Z  d# „  Z	  d$ „  Z
  d% „  Z RS(&   Ns   Januaryi   s   Februaryi   s   Marchi   s   Aprili   s   Mayi   s   Junei   s   Julyi   s   Augusti   s	   Septemberi	   s   Octoberi
   s   Novemberi   s   Decemberi   c    sw      |  i d d j o   d SnL ! |  i d d j o " d Sn* # |  i d d j o $ d Sn & d Sd S(   sù   Returns 1 if self is part of leap year. Else, returns 0.

        If a year is divisible by 4, and not divisible by 100, it is
        a leap year.
        If a year is divisible by 400, it is a leap year.
        All other years are not leap years.i  i    i   id   i   N(   s   selfs   year(   s   self(    (    s   ./richard.pys
   isLeapYear s   c    s   ( , - | d d d d d d d g j o . d SnW / | d	 d
 d d g j o 0 d Sn0 1 | d j o
 |  i ƒ  o 2 d Sn 4 d Sd S(   s¤   Returns the number of days in a given month.

        The argument month is an integer 1 - 12.
        If the month is February, checks whether self is a leap year.i   i   i   i   i   i
   i   i   i   i   i	   i   i   i   i   i   N(   s   months   selfs
   isLeapYear(   s   selfs   month(    (    s   ./richard.pys   num_days( s   %il  c    s.   6 ; < | |  _  = | |  _ > | |  _ d S(   s  Initializes date object with 1900-01-01, unless respective
        arguments supplied.  Year must be a positive integer, and
        must be explicit (e.g. 99 is not 1999).
        Month must be an integer between 1 and 12.
        Day must be a existing day, given the year and month.N(   s   years   selfs   months   day(   s   selfs   years   months   day(    (    s   ./richard.pys   __init__6 s   c    sU   @ C D t  | d d !ƒ |  _ E t  | d d !ƒ |  _ F t  | d d !ƒ |  _ d S(   s²   Return a new Date object given a string formatted date: YYYY-MM-DD.
        Year must be four digits long.  Month must be two digits long.mro
        Day must be two digits long.i    i   i   i   i   i
   N(   s   ints   strs   selfs   years   months   day(   s   selfs   str(    (    s   ./richard.pys   newDate@ s   s   textc    sƒ   H K L | d j o7 M t i |  i d t |  i ƒ d t |  i ƒ Sn3 O t |  i ƒ d t |  i ƒ d t |  i ƒ Sd S(   sº    Converts a Date object to a string in the format YYYY-MM-DD.  Or, if
        'text' specified for the argument format, converts Date object to string
        in format 'Month DD, YYYY' s   texts    s   , s   -N(   s   formats   Dates   months   selfs   strs   days   year(   s   selfs   format(    (    s   ./richard.pys   __str__H s   7c    s×   Q S T |  i | i j o U d Sn­ V |  i | i j  o W d SnŒ Y |  i | i j o Z d Snk [ |  i | i j  o \ d SnJ ^ |  i | i j o _ d Sn) ` |  i | i j  o a d Sn d d Sd S(   s…    If self occurrs before other Date, return -1.  If self occurrs later than
        other, return 1.  If self is other Date, return 0.i   iÿÿÿÿi    N(   s   selfs   years   others   months   day(   s   selfs   other(    (    s   ./richard.pys   __cmp__Q s   c    s<  f g h |  i d j o |  i d j o |  i ƒ  p‹ |  i d j o |  i d j o
 |  i ƒ  p^ |  i d d d d d d	 d
 g j o |  i d j p) |  i d d d d g j o |  i d j oY l d |  _ m |  i d |  _ n |  i d j o# o d |  _ p |  i d |  _ n n r |  i d |  _ s |  Sd S(   s$   Returns the date one day after self.i   i   i   i   i   i   i   i   i
   i   i   i   i   i	   i   i   i   N(   s   selfs   months   days
   isLeapYears   year(   s   self(    (    s   ./richard.pys   nextf s   ¿c    sœ   u v w |  i d j oe x |  i d |  _ y |  i d j o# z d |  _ { |  i d |  _ n | |  i |  i ƒ |  _ n ~ |  i d |  _  |  Sd S(   s%   Returns the date one day before self.i   i    i   N(   s   selfs   days   months   years   num_days(   s   self(    (    s   ./richard.pys   prevu s   c    s‡    † ‡ t  |  i |  i |  i ƒ } ˆ | d j  o ‰ | d | Sn Š x/ Š | d j o ‹ | i ƒ  Œ | d } qM W | Sd S(   sí   Returns a date plus the amount given in inc.
        Positive values for inc will cause the date returned to be
        inc days after self.
        Negative values for inc will cause the date returned to be
        inc days before self.i    i   N(   s   Dates   selfs   years   months   days   ds   incs   next(   s   selfs   incs   d(    (    s   ./richard.pys   __add__ s    c    s‡    ” • t  |  i |  i |  i ƒ } – | d j  o — | d | Sn ˜ x/ ˜ | d j o ™ | i ƒ  š | d } qM W› | Sd S(   sî   Returns a date minus the amount given in inc.
        Positive values for inc will cause the date returned to be
        inc days before self.
        Negative values for inc will cause the date returned to be
        inc days after self.i    i   N(   s   Dates   selfs   years   months   days   ds   incs   prev(   s   selfs   incs   d(    (    s   ./richard.pys   __sub__ s    c    s.    ž Ÿ | |  _    | |  _ ¡ | |  _ d S(   s6   Sets self to have new values for year, month, and day.N(   s   years   selfs   months   day(   s   selfs   years   months   day(    (    s   ./richard.pys   set s   (   s   months
   isLeapYears   num_dayss   __init__s   newDates   __str__s   __cmp__s   nexts   prevs   __add__s   __sub__s   set(    (    (    s   ./richard.pys   Date	 s0   	
	N(   s   __doc__s   Date(   s   Date(    (    s   ./richard.pys   ? s   