Xyris  0.5
Time::TimeDescriptor Class Reference

#include <time.hpp>

Public Member Functions

 TimeDescriptor (int sec, int min, int hr, int d, int m, int y)
 
 TimeDescriptor ()
 
 ~TimeDescriptor ()
 
int getSeconds ()
 
int getMinutes ()
 
int getHour ()
 
int getDay ()
 
int getMonth ()
 
int getYear ()
 
void setSeconds (int sec)
 
void setMinutes (int min)
 
void setHour (int hr)
 
void setDay (int d)
 
void setMonth (int m)
 
void setYear (int y)
 
void toDate ()
 

Private Member Functions

void converterEpochToDate (uint64_t Number)
 

Private Attributes

int _seconds
 
int _minutes
 
int _hour
 
int _day
 
int _month
 
int _year
 
int _dayOfWeek
 

Detailed Description

Definition at line 19 of file time.hpp.

Constructor & Destructor Documentation

◆ TimeDescriptor() [1/2]

Time::TimeDescriptor::TimeDescriptor ( int  sec,
int  min,
int  hr,
int  d,
int  m,
int  y 
)

Definition at line 24 of file time.cpp.

25  : _seconds(sec)
26  , _minutes(min)
27  , _hour(hr)
28  , _day(d)
29  , _month(m)
30  , _year(y)
31 {
32  // Initialize nothing.
33 }

◆ TimeDescriptor() [2/2]

Time::TimeDescriptor::TimeDescriptor ( )

Definition at line 19 of file time.cpp.

20 {
21  toDate();
22 }
+ Here is the call graph for this function:

◆ ~TimeDescriptor()

Time::TimeDescriptor::~TimeDescriptor ( )

Definition at line 34 of file time.cpp.

35 {
36  // Nothing to deconstruct
37 }

Member Function Documentation

◆ converterEpochToDate()

void Time::TimeDescriptor::converterEpochToDate ( uint64_t  Number)
private

Definition at line 39 of file time.cpp.

40 {
41  int a, b, c, day, month, year;
42  setSeconds(epoch % 60);
43  epoch /= 60;
44  setMinutes(epoch % 60);
45  epoch /= 60;
46  setHour(epoch % 24);
47  epoch /= 24;
48 
49  // This is the formula used by everyone. No idea how it works :p
50  a = ((4 * epoch + 102032) / 146097 + 15);
51  b = (epoch + 2442113 + a - (a / 4));
52  year = (20 * b - 2442) / 7305;
53  c = b - 365 * year - (year / 4);
54  month = c * 1000 / 30601;
55  day = c - month * 30 - month * 601 / 1000;
56  if (month <= 13) {
57  year -= 4716;
58  month -= 1;
59  } else {
60  year -= 4715;
61  month -= 13;
62  }
63 
64  setDay(day);
65  setMonth(month);
66  setYear(year);
67 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDay()

int Time::TimeDescriptor::getDay ( )
inline

Definition at line 29 of file time.hpp.

29 { return _day; }

◆ getHour()

int Time::TimeDescriptor::getHour ( )
inline

Definition at line 28 of file time.hpp.

28 { return _hour; }

◆ getMinutes()

int Time::TimeDescriptor::getMinutes ( )
inline

Definition at line 27 of file time.hpp.

27 { return _minutes; }

◆ getMonth()

int Time::TimeDescriptor::getMonth ( )
inline

Definition at line 30 of file time.hpp.

30 { return _month; }

◆ getSeconds()

int Time::TimeDescriptor::getSeconds ( )
inline

Definition at line 26 of file time.hpp.

26 { return _seconds; }

◆ getYear()

int Time::TimeDescriptor::getYear ( )
inline

Definition at line 31 of file time.hpp.

31 { return _year; }

◆ setDay()

void Time::TimeDescriptor::setDay ( int  d)
inline

Definition at line 36 of file time.hpp.

36 { _day = d; }
+ Here is the caller graph for this function:

◆ setHour()

void Time::TimeDescriptor::setHour ( int  hr)
inline

Definition at line 35 of file time.hpp.

35 { _hour = hr; }
+ Here is the caller graph for this function:

◆ setMinutes()

void Time::TimeDescriptor::setMinutes ( int  min)
inline

Definition at line 34 of file time.hpp.

34 { _minutes = min; }
+ Here is the caller graph for this function:

◆ setMonth()

void Time::TimeDescriptor::setMonth ( int  m)
inline

Definition at line 37 of file time.hpp.

37 { _month = m; }
+ Here is the caller graph for this function:

◆ setSeconds()

void Time::TimeDescriptor::setSeconds ( int  sec)
inline

Definition at line 33 of file time.hpp.

33 { _seconds = sec; }
+ Here is the caller graph for this function:

◆ setYear()

void Time::TimeDescriptor::setYear ( int  y)
inline

Definition at line 38 of file time.hpp.

38 { _year = y; }
+ Here is the caller graph for this function:

◆ toDate()

void Time::TimeDescriptor::toDate ( )

Definition at line 69 of file time.cpp.

70 {
71  uint64_t epoch = RTC::getEpoch();
72  converterEpochToDate(epoch);
73  // TODO: for another GMT, add or subtract time zone in epoch number
74  // e.g
75  // for GMT -3 =(-3*3600)= -10800
76  // converterEpochToDate(epoch-10800);
77  converterEpochToDate(epoch);
78 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ _day

int Time::TimeDescriptor::_day
private

Definition at line 47 of file time.hpp.

◆ _dayOfWeek

int Time::TimeDescriptor::_dayOfWeek
private

Definition at line 50 of file time.hpp.

◆ _hour

int Time::TimeDescriptor::_hour
private

Definition at line 46 of file time.hpp.

◆ _minutes

int Time::TimeDescriptor::_minutes
private

Definition at line 45 of file time.hpp.

◆ _month

int Time::TimeDescriptor::_month
private

Definition at line 48 of file time.hpp.

◆ _seconds

int Time::TimeDescriptor::_seconds
private

Definition at line 44 of file time.hpp.

◆ _year

int Time::TimeDescriptor::_year
private

Definition at line 49 of file time.hpp.


The documentation for this class was generated from the following files:
Time::TimeDescriptor::_hour
int _hour
Definition: time.hpp:46
Time::TimeDescriptor::setYear
void setYear(int y)
Definition: time.hpp:38
Time::TimeDescriptor::setDay
void setDay(int d)
Definition: time.hpp:36
RTC::month
uint32_t month
Definition: rtc.cpp:39
Time::TimeDescriptor::_month
int _month
Definition: time.hpp:48
Time::TimeDescriptor::converterEpochToDate
void converterEpochToDate(uint64_t Number)
Definition: time.cpp:39
Time::TimeDescriptor::setSeconds
void setSeconds(int sec)
Definition: time.hpp:33
RTC::getEpoch
uint64_t getEpoch()
Get a epoch number from rtc.
Definition: rtc.cpp:193
Time::TimeDescriptor::_day
int _day
Definition: time.hpp:47
RTC::day
uint32_t day
Definition: rtc.cpp:38
Time::TimeDescriptor::setMonth
void setMonth(int m)
Definition: time.hpp:37
Time::TimeDescriptor::_year
int _year
Definition: time.hpp:49
Time::TimeDescriptor::_minutes
int _minutes
Definition: time.hpp:45
Time::TimeDescriptor::setMinutes
void setMinutes(int min)
Definition: time.hpp:34
Time::TimeDescriptor::toDate
void toDate()
Definition: time.cpp:69
Time::TimeDescriptor::_seconds
int _seconds
Definition: time.hpp:44
Time::TimeDescriptor::setHour
void setHour(int hr)
Definition: time.hpp:35
RTC::year
uint32_t year
Definition: rtc.cpp:40