Belle II Software development
Date Class Reference

Public Member Functions

 Date (time_t time)
 
 Date (const Date &date)
 
void set ()
 
void set (time_t time)
 
time_t get () const
 
int getSecond () const
 
int getMinitue () const
 
int getHour () const
 
int getDay () const
 
int getMonth () const
 
int getYear () const
 
const char * toString (const char *format=NULL) const
 
const Dateoperator= (const Date &date)
 

Private Attributes

time_t m_time
 
struct tm * m_tm
 
char m_str [31]
 

Detailed Description

Definition at line 19 of file Date.h.

Constructor & Destructor Documentation

◆ Date() [1/3]

Date ( time_t  time)

Definition at line 14 of file Date.cc.

15{
16 set(time);
17}

◆ Date() [2/3]

Date ( const Date date)

Definition at line 19 of file Date.cc.

20{
21 set(date.m_time);
22}

◆ Date() [3/3]

Date ( )

Definition at line 24 of file Date.cc.

25{
26 set();
27}

◆ ~Date()

~Date ( )

Definition at line 29 of file Date.cc.

29{}

Member Function Documentation

◆ get()

time_t get ( ) const
inline

Definition at line 30 of file Date.h.

30{ return m_time; }

◆ getDay()

int getDay ( ) const

Definition at line 58 of file Date.cc.

59{
60 return m_tm->tm_mday;
61}

◆ getHour()

int getHour ( ) const

Definition at line 53 of file Date.cc.

54{
55 return m_tm->tm_hour;
56}

◆ getMinitue()

int getMinitue ( ) const

Definition at line 48 of file Date.cc.

49{
50 return m_tm->tm_min;
51}

◆ getMonth()

int getMonth ( ) const

Definition at line 63 of file Date.cc.

64{
65 return m_tm->tm_mon + 1;
66}

◆ getSecond()

int getSecond ( ) const

Definition at line 43 of file Date.cc.

44{
45 return m_tm->tm_sec;
46}

◆ getYear()

int getYear ( ) const

Definition at line 68 of file Date.cc.

69{
70 return m_tm->tm_year + 1900;
71}

◆ operator=()

const Date & operator= ( const Date date)
inline

Definition at line 40 of file Date.h.

41 {
42 set(date.m_time);
43 return *this;
44 }

◆ set() [1/2]

void set ( )

Definition at line 31 of file Date.cc.

32{
33 m_time = time(NULL);
34 m_tm = localtime(&m_time);
35}

◆ set() [2/2]

void set ( time_t  time)

Definition at line 37 of file Date.cc.

38{
39 m_time = time;
40 m_tm = localtime(&m_time);
41}

◆ toString()

const char * toString ( const char *  format = NULL) const

Definition at line 73 of file Date.cc.

74{
75 memset(m_str, 0, sizeof(m_str));
76 if (format == NULL) {
77 strftime(m_str, 31, "%Y-%m-%d %H:%M:%S", m_tm);
78 } else {
79 strftime(m_str, 31, format, m_tm);
80 }
81 return m_str;
82}

Member Data Documentation

◆ m_str

char m_str[31]
mutableprivate

Definition at line 49 of file Date.h.

◆ m_time

time_t m_time
private

Definition at line 47 of file Date.h.

◆ m_tm

struct tm* m_tm
private

Definition at line 48 of file Date.h.


The documentation for this class was generated from the following files: