Belle II Software  release-05-01-25
Date.cc
1 #include "daq/slc/base/Date.h"
2 
3 #include <cstring>
4 
5 using namespace Belle2;
6 
7 Date::Date(time_t time)
8 {
9  set(time);
10 }
11 
12 Date::Date(const Date& date)
13 {
14  set(date.m_time);
15 }
16 
17 Date::Date()
18 {
19  set();
20 }
21 
22 Date::~Date() {}
23 
24 void Date::set()
25 {
26  m_time = time(NULL);
27  m_tm = localtime(&m_time);
28 }
29 
30 void Date::set(time_t time)
31 {
32  m_time = time;
33  m_tm = localtime(&m_time);
34 }
35 
36 int Date::getSecond() const
37 {
38  return m_tm->tm_sec;
39 }
40 
41 int Date::getMinitue() const
42 {
43  return m_tm->tm_min;
44 }
45 
46 int Date::getHour() const
47 {
48  return m_tm->tm_hour;
49 }
50 
51 int Date::getDay() const
52 {
53  return m_tm->tm_mday;
54 }
55 
56 int Date::getMonth() const
57 {
58  return m_tm->tm_mon + 1;
59 }
60 
61 int Date::getYear() const
62 {
63  return m_tm->tm_year + 1900;
64 }
65 
66 const char* Date::toString(const char* format) const
67 {
68  memset(m_str, 0, sizeof(m_str));
69  if (format == NULL) {
70  strftime(m_str, 31, "%Y-%m-%d %H:%M:%S", m_tm);
71  } else {
72  strftime(m_str, 31, format, m_tm);
73  }
74  return m_str;
75 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::Date
Definition: Date.h:12