
/** An instance gives the time of day in a time zone, in terms
    hours, minutes, and seconds. The implemented time zones are:<br><br>
    
     GMT: Greenwich Mean Time, GMT<br>
     BST: British Summer Time, GMT+1<br>
     EST: Eastern Standard Time, GMT-5 hours (NY)<br>
     EDT: Eastern Daylight Savings Time, GMT-4 hours (NY)<br>
     CST: Central Standard Time, GMT-6 hours (Chicago)<br>
     CDT: Central Daylight Savings Time, GMT-5 hours (Chicago)<br>
     MST: Mountain Standard Time, GMT-7 hours (Phoenix)<br>
     MDT: Mountain Daylight Savings Time, GMT-6 (Phoenix)<br>
     PST: Pacific Standard Time, GMT-8 hours (LA)<br>
     PDT: Pacific Daylight Saving Time, GMT-7 hours (LA)<br>
     IST: Indian Standard Time, GMT+5:30 hours (New Delhi)<br><br>
     
     India (IST) is included to show that times are not always on
     hourly boundaries from GMT.<br><br>
     
     A time may appear negative or greater than 24 hours.
     This is because we allow a conversion of a time from one time
     zone to another, and a time of 0 hours GMT is -7 hours PDT
     (for example), while a time of 23:59 GMT is 29:29 IST.<br><br>
     
     An instance of the class can show the time using a 24-hour clock
     or using the AM-PM designation; it is the user's choice.
 */
public class TimeZones {
    /**  = "GMT", a time zone */
    public static final String GMT= "GMT";
    /**  = "BST", a time zone */
    public static final String BST= "BST";
    /**  = "EST", a time zone */
    public static final String EST= "EST";
    /**  = "EDT", a time zone */
    public static final String EDT= "EDT";
    /**  = "CST", a time zone */
    public static final String CST= "CST";
    /**  = "CDT", a time zone */
    public static final String CDT= "CDT";
    /**  = "MST", a time zone */
    public static final String MST= "MST";
    /**  = "MDT", a time zone */
    public static final String MDT= "MDT";
    /**  = "PST", a time zone */
    public static final String PST= "PST";
    /**  = "PDT", a time zone */
    public static final String PDT= "PDT";
    /**  = "IST", a time zone */
    public static final String IST= "IST";
    
    /** Contains all the time zones given above, separated by " " */
    public static final String ALL= "GMT BST EST EDT CST CDT MST MDT PST PDT IST";
    
    /** Class invariant: Variable time is a time in seconds on a day in
        time zone zone. The time may be negative or greater than 24 hours,
        as indicated in the class specification (which says why). Field
        displayMode has the meaning
             "the time should be viewed as a 12-hour clock".
     */
    private int time= 0;
    private String zone= "GMT";
    private boolean displayMode= false; 
    
    
    /** Constructor: an instance with time 0 GMT and a 24-hour clock */
    public TimeZones() {
    }
    
    /** Constructor: A time of day of s seconds in zone z.
        If z is not a legal zone, make it GMT. 
        Parameter s should be > -24 hours and < 48 hours;
        if not, use time 0.
        The time should be displayed as am-pm iff b is true */
    public TimeZones(int s, String z, boolean b) {
        if (isLegal(z)) {
            zone= z;
        }
        time= s;
        if (s <= -24*60*60  ||  48*60*60 <= s) {
            time= 0;
        }
        displayMode= b;
    }
    
    /** Constructor: A time of day of h hours, m minutes, s seconds
     in zone z. The time should be > -24 hours and < 48 hours;
     if not, use time 0 is. If z is not a legal zone, make it GMT. 
     The time should be displayed as am-pm iff b is true */
    public TimeZones(int h, int m, int s, String z, boolean b) {
        
    }
    
    /* = the time, in seconds */
    public int getTime() {
        return 0;
    }
    
    /** = the time zone */
    public String getZone() {
        return "";
    }
    
    /** = am-pm indication: true means display in AM-PM format;
                            false means display in 24-hour format */
    public boolean getAmPm() {
        return false;
    }
    
    /** If b is true, set the display mode to AM-PM;
        if b is false, set it to "twenty-four hours". */
    public void setDisplay(boolean b) {
        
    }
    
    /** = "z is a legal zone" --see class specification. */
    public static boolean isLegal(String z) {
        return true;  
    }
    
    /** = a string representation of the time. This is basically in the
     form "hours:minutes:seconds zone", but it differs depending on
     whether a 12- or 24-hour clock is wanted. 
     We describe the difference with examples:<br><br>
     
       In AM-PM mode:   06:20:05AM DST  or  06:20:05PM DST<br>
       In 24-hour mode: 06:20:05 DST    or  18:20:05 DST<br><br>
       
     If the time is negative or at least 24 hours, print it using the
     24-hour mode, even if 12-hour mode is indicated.
     See the assignment handout, section "rules for function toString",
     for more details.
     */
    public String toString() {
        String result= "";
        
        // Save the am-pm indication in a local variable amPm
        // Then, if the time is negative or >= 24, set amPm to
        // false to get 24-hour mode. 
        
        
        // Append the hour to result --with a - sign if necessary
        
        
        // Append the minutes and seconds to result
        
        
        // Append the am-pm designation to result, if necessary
        // --use local variable amPM to help determine this
        
        
        // Append the zone to result
        
        return result;   
    }
    
    
    /** =  a new Time that is the same as this time but described in GMT */
    public TimeZones timeInGMT() {
        TimeZones t= new TimeZones(time, GMT, displayMode);
        if (zone.equals(BST)) t.time= time - 1*3600;
        if (zone.equals(EST)) t.time= time + 5*3600;
        if (zone.equals(EDT)) t.time= time + 4*3600;
        if (zone.equals(CST)) t.time= time + 6*3600;
        if (zone.equals(CDT)) t.time= time + 5*3600;
        if (zone.equals(MST)) t.time= time + 7*3600;
        if (zone.equals(MDT)) t.time= time + 6*3600;
        if (zone.equals(PST)) t.time= time + 8*3600;
        if (zone.equals(PDT)) t.time= time + 7*3600;
        if (zone.equals(IST)) t.time= time - 5*3600 - 3600/2;
        
        return t;
    }
    
    /** =  a new Time that is the same as this time but described in 
     zone z. If z is not a legal zone, the new zone is taken to be GMT */
    public TimeZones timeInZone(String z) {
        
        return null;
    }
    
    /** = -1 if this time < time t,
           0 if this time equals time t, and
           1 if this time > time t */
    public int compare(TimeZones t) {
 
       return 1;   
    }
    
}