summaryrefslogtreecommitdiffstats
path: root/dev/a3-earthquake/date.h
blob: 876874527a67a7f8c8c792e4aa147cdd24505d69 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/** CSci-4611 Assignment 3:  Earthquake
 */

#ifndef DATE_H_
#define DATE_H_

#include <ctime>
#include <iostream>

/** A date class that handles leap years and can convert itself to seconds and
    handle < and > operations.
 */
class Date {
public:
    Date();
    Date(double seconds);
    Date(int m, int d, int y);
    Date(int m, int d, int y, int hr, int min, double sec);

    bool operator<(const Date& other);
    bool operator>(const Date& other);

    double ToSeconds() const;

    double SecondsUntil(const Date& other) const;
    
    int year();
    
    int month();
    
    int day();
    
    int hour();
    
    int minute();
    
    double second();

private:
    std::time_t ctime_;
    int fouryears_;
    int year_;
    int month_;
    int day_;
    int hour_;
    int minute_;
    double second_;
};

#endif