// ========================================================================================
// IMPORTANT: You should not edit this file
// ========================================================================================

#ifndef __TIMESTAMP_H___
#define __TIMESTAMP_H___

#include <iostream>
#include <cstdint>

// The TimeStamp class represents time with integers for the day,
// hour, min, seconds, and milliseconds.  We can increment a TimeStamp
// by adding an integer number of milliseconds.  We can compute the
// difference or time elapsed between two TimeStamp objects. Timestamp
// objects can be sorted chronologically.  TimeStamp objects are
// printed in military format (00:00:00.000 -> 23:59:59.999).

// NOTE: The type uint64_t is an unsigned integer guaranteed to be
// exactly 64 bits.  If we used only a 32 bit integer to represent
// total milliseconds, it would overflow after ~50 days.


class TimeStamp {
public:
  // CONSTRUCTOR
  TimeStamp(int h=0, int m=0, int s=0, int ms=0)
    : days(0), hours(h), minutes(m), seconds(s), milliseconds(ms) { }
  // ACCESSORS
  int getDays() const { return days; }
  int getHours() const { return hours; }
  int getMinutes() const { return minutes; }
  int getSeconds() const { return seconds; }
  int getMilliseconds() const { return milliseconds; }
  // helper function for the comparison operators
  uint64_t getTotalMilliseconds() const;
  // MODIFIER
  void addMilliseconds(int ms);
private:
  // REPRESENTATION
  int days;
  int hours;
  int minutes;
  int seconds;
  int milliseconds;
};

// RELATED HELPER FUNCTIONS:

// the difference in seconds between two timestamps (a should be earlier or equal to b)
uint64_t elapsedMilliseconds(const TimeStamp &a, const TimeStamp &b);  

// comparison operators for sorting
bool operator== (const TimeStamp &a, const TimeStamp &b);
bool operator< (const TimeStamp &a, const TimeStamp &b);
bool operator<= (const TimeStamp &a, const TimeStamp &b);
bool operator> (const TimeStamp &a, const TimeStamp &b);
bool operator>= (const TimeStamp &a, const TimeStamp &b);


// for printing
std::ostream& operator<<(std::ostream &ostr, const TimeStamp &a);

#endif

