#include <oks_utils.hpp>
|
| Date (const char *s) |
|
virtual | ~Date () |
|
void | set (const char *) |
|
long | year () const |
|
unsigned short | month () const |
|
unsigned short | day () const |
|
virtual std::string | str () const |
|
Definition at line 69 of file oks_utils.hpp.
◆ Date()
dunedaq::oks::Date::Date |
( |
const char * | s | ) |
|
|
inline |
◆ ~Date()
virtual dunedaq::oks::Date::~Date |
( |
| ) |
|
|
inlinevirtual |
◆ day()
unsigned short dunedaq::oks::Date::day |
( |
| ) |
const |
|
inline |
◆ month()
unsigned short dunedaq::oks::Date::month |
( |
| ) |
const |
|
inline |
◆ set()
void dunedaq::oks::Date::set |
( |
const char * | s | ) |
|
Definition at line 22 of file time.cpp.
23{
25
26 if(s == 0) return;
27
28
29
31
32
34 char * nds = 0;
35
36
37
38
39 p_tm.tm_mday = strtol(s, &nds, 10);
40
41 if(*nds != '/') {
42 Oks::error_msg(
"oks::Time::Time()") <<
"failed to find the day in \'" << s2 <<
"\'\n";
43 return;
44 }
45 else
47
48 if(
p_tm.tm_mday > 31 ||
p_tm.tm_mday == 0) {
49 Oks::error_msg(
"oks::Time::Time()") <<
"bad day " <<
p_tm.tm_mday <<
" in \'" << s2 <<
"\'\n";
50 return;
51 }
52
53
54
55
56 p_tm.tm_mon = strtol(s, &nds, 10);
57
58 if(*nds != '/') {
59 Oks::error_msg(
"oks::Time::Time()") <<
"failed to find the month in \'" << s2 <<
"\'\n";
60 return;
61 }
62 else
64
65 if(
p_tm.tm_mon > 12 ||
p_tm.tm_mon == 0) {
66 Oks::error_msg(
"oks::Time::Time()") <<
"bad month " <<
p_tm.tm_mon <<
" in \'" << s2 <<
"\'\n";
67 return;
68 }
69
71
72
73
74
75 p_tm.tm_year = strtol(s, &nds, 10);
76
77 if(
p_tm.tm_year >= 0) {
78 if(
p_tm.tm_year < 70)
p_tm.tm_year += 2000;
79 else if(
p_tm.tm_year < 100)
p_tm.tm_year += 1900;
80 }
81
82
83
84 if(*nds == 0) return;
85
87
88
89
90
92 if(*s == 0) return;
93
94
95
96
97 p_tm.tm_hour = strtol(s, &nds, 10);
98
99 if(*nds != ':') {
100 Oks::error_msg(
"oks::Time::Time()") <<
"failed to find the hour in \'" << s2 <<
"\'\n";
101 return;
102 }
103 else
105
106 if(
p_tm.tm_hour > 23) {
107 Oks::error_msg(
"oks::Time::Time()") <<
"bad hour " <<
p_tm.tm_hour <<
" in \'" << s2 <<
"\'\n";
108 return;
109 }
110
111
112
113
114 p_tm.tm_min = strtol(s, &nds, 10);
115
116 if(
p_tm.tm_min > 59) {
117 Oks::error_msg(
"oks::Time::Time()") <<
"bad minute " <<
p_tm.tm_min <<
" in \'" << s2 <<
"\'\n";
118 return;
119 }
120
121 if(*nds != ':') return;
122
123
124
125
126 p_tm.tm_sec = strtol(nds + 1, &nds, 10);
127
128 if(
p_tm.tm_sec > 59) {
129 Oks::error_msg(
"oks::Time::Time()") <<
"bad second " <<
p_tm.tm_sec <<
" in \'" << s2 <<
"\'\n";
130 return;
131 }
132}
static std::ostream & error_msg(const char *)
◆ str()
std::string dunedaq::oks::Date::str |
( |
| ) |
const |
|
virtual |
Reimplemented in dunedaq::oks::Time.
Definition at line 136 of file time.cpp.
137{
138 std::ostringstream
s;
139
140 s <<
p_tm.tm_mday <<
'/' << (
p_tm.tm_mon + 1) <<
'/' << std::setfill(
'0') << std::setw(2)
141 << ((
p_tm.tm_year < 1970 ||
p_tm.tm_year >= 2070) ?
p_tm.tm_year : (
p_tm.tm_year < 2000 ? (
p_tm.tm_year - 1900) : (
p_tm.tm_year - 2000)));
142
144}
◆ year()
long dunedaq::oks::Date::year |
( |
| ) |
const |
|
inline |
◆ p_tm
struct tm dunedaq::oks::Date::p_tm |
|
protected |
The documentation for this class was generated from the following files:
- /github/workspace/dunedaq/sourcecode/oks/src/oks_utils.hpp
- /github/workspace/dunedaq/sourcecode/oks/src/time.cpp