MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / normalize

Method normalize

src/utilities/time/DateTime.cpp:274–294  ·  view source on GitHub ↗

ensure that stored time is less than 24 hrs and adjust date accordingly

Source from the content-addressed store, hash-verified

272
273// ensure that stored time is less than 24 hrs and adjust date accordingly
274void DateTime::normalize() {
275 // total number of whole days in the time
276 int wholeDays = m_time.days();
277
278 // if time is longer than a day (either positive or negative) normalize it to remainder less than 24 hrs
279 if (wholeDays != 0) {
280 Time adjustTime(wholeDays, 0, 0, 0);
281 m_date += adjustTime;
282 m_time -= adjustTime;
283 }
284
285 // total number of fractional days in the time
286 double fracDays = m_time.totalDays();
287
288 // if time is negative add a day to make it positive
289 if (fracDays < 0) {
290 Time adjustTime(1, 0, 0, 0);
291 m_date -= adjustTime;
292 m_time += adjustTime;
293 }
294}
295
296int DateTime::utcOffsetHours() const {
297 return (int)m_utcOffset;

Callers 3

WindowGroupMethod · 0.45
aimAtMethod · 0.45
aimAtMethod · 0.45

Calls 2

daysMethod · 0.80
totalDaysMethod · 0.80

Tested by

no test coverage detected