/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to src/time.h

  • Committer: edam
  • Date: 2012-02-28 17:11:15 UTC
  • Revision ID: edam@waxworlds.org-20120228171115-j3k91a3v71d3wnc1
cleanu

Show diffs side-by-side

added added

removed removed

24
24
#define _TIME_H_
25
25
 
26
26
 
27
 
namespace Time
 
27
class Time
28
28
{
29
 
        /**
30
 
         * Initialise time from store.
31
 
         */
32
 
        void load_time();
33
 
 
34
 
        /**
35
 
         * Save the time to the store.
36
 
         */
37
 
        void save_time();
38
 
 
39
 
        /**
40
 
         * Get year.
41
 
         *
42
 
         * @return year
43
 
         */
44
 
        int get_year();
45
 
 
46
 
        /**
47
 
         * Get month.
48
 
         *
49
 
         * @return month, 1 to 12
50
 
         */
51
 
        int get_month();
52
 
 
53
 
        /**
54
 
         * Get month name.
55
 
         *
56
 
         * @return month name
57
 
         */
58
 
        const char *get_month_name();
59
 
 
60
 
        /**
61
 
         * Get day.
62
 
         *
63
 
         * @return date, 1 to 31
64
 
         */
65
 
        int get_day();
66
 
 
67
 
        /**
68
 
         * Get number suffix.
69
 
         *
70
 
         * @param number
71
 
         * @return suffix
72
 
         */
73
 
        const char *get_day_suffix();
 
29
public:
 
30
 
 
31
        /**
 
32
         * Get singleton instance.
 
33
         *
 
34
         * @return instance
 
35
         */
 
36
        static Time &get_instance();
74
37
 
75
38
        /**
76
39
         * Get hours.
98
61
         */
99
62
        void update();
100
63
 
101
 
        /**
102
 
         * Increment the hours and save the time.
103
 
         */
104
 
        void inc_hours();
105
 
 
106
 
        /**
107
 
         * Increment the minutes and save the time.
108
 
         */
109
 
        void inc_minutes();
110
 
 
111
 
        /**
112
 
         * Reset the seconds and save the time.
113
 
         */
114
 
        void reset_seconds();
115
 
 
116
 
        /**
117
 
         * Increment the year and save the time.
118
 
         */
119
 
        void inc_year();
120
 
 
121
 
        /**
122
 
         * Increment the month and save the time.
123
 
         */
124
 
        void inc_month();
125
 
 
126
 
        /**
127
 
         * Increment the day and save the time.
128
 
         */
129
 
        void inc_day();
 
64
protected:
 
65
 
 
66
        Time();
 
67
 
 
68
        /** hours */
 
69
        int _hours;
 
70
 
 
71
        /** minutes */
 
72
        int _minutes;
 
73
 
 
74
        /** seconds */
 
75
        int _seconds;
 
76
 
 
77
private:
 
78
 
 
79
        /** milliseconds at last update */
 
80
        unsigned long _last_millis;
 
81
 
 
82
        /** milliseconds carries over from last update */
 
83
        unsigned long _carry;
130
84
 
131
85
};
132
86
 
133
87
 
134
 
#endif //_TIME_H_
 
88
#endif _TIME_H_