libtime++: Date and time calculation

◆ example3()

void example3 ( )

Definition at line 127 of file example++.cc.

References example3sub1().

Referenced by main().

128 {
129  libtime::TAbsoluteTime first("2000/12/8 9:35:1.2671"),
130  reqstart("2000/12/8 12:37:14"),
131  reqend("2000/12/8 12:43:52"),
132  exstart, exend;
133  libtime::TRelativeTime interval(0,0,0,0,5), reqspan, exspan;
134 
135  cout << "\n"
136  << "Example 3: Serving a data request\n"
137  << "----------\n"
138  << "\n";
139 
140  cout << " Imagine that you might have a database file that starts\n"
141  << " with a first sample at "
142  << std::string(first) << ".\n"
143  << " A client requests a time series that should start at\n"
144  << " " << std::string(reqstart) << " and end at "
145  << " " << std::string(reqend) << ".\n"
146  << " The sampling interval is " << std::string(interval) << endl;
147 
148  long int offset1=(reqstart-first)/interval;
149  long int offset2=(reqend-first)/interval;
150  exstart=first+interval*(offset1);
151  exend=first+interval*(offset2);
152  reqspan=reqend-reqstart;
153  exspan=exend-exstart;
154 
155  cout << " The requested time span is "
156  << std::string(reqspan) << endl;
157 
158  cout << "\n"
159  << " The client will receive a data segment from offset "
160  << offset1 << " to " << offset2 << ".\n";
161 
162  cout << " The segment's first sample is at " << std::string(exstart) << "\n"
163  << " and it's last one is at " << std::string(exend) << endl;
164 
165  example3sub1("the first requested sample",
166  "the first delivered sample",
167  reqstart, exstart, interval);
168 
169  example3sub1("the last requested sample",
170  "the last delivered sample",
171  reqend, exend, interval);
172 
173  example3sub1("the first requested sample",
174  "the sample before the first delivered one",
175  reqstart, exstart-interval, interval);
176 
177  example3sub1("the first requested sample",
178  "the sample after the first delivered one",
179  reqstart, exstart+interval, interval);
180 
181 }
class to contain relative times
Definition: libtime++.h:201
class to contain absolute times
Definition: libtime++.h:149
void example3sub1(std::string s1, std::string s2, libtime::TAbsoluteTime t1, libtime::TAbsoluteTime t2, libtime::TRelativeTime i)
Definition: example++.cc:112
Here is the call graph for this function:
Here is the caller graph for this function: