TrueReality  v0.1.1912
DateTime.cpp
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * The Base of this class has been adopted from the Delta3D engine
6 *
7 * This library is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by the Free
9 * Software Foundation; either version 3.0 of the License, or (at your option)
10 * any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * @author Bradley Anderegg
22 */
23 #include <trUtil/DateTime.h>
24 
25 #include <trUtil/PlatformMacros.h>
26 
27 #include <cmath>
28 #include <ctime>
29 
30 #include <stdio.h>
31 #include <string.h>
32 
33 namespace trUtil
34 {
35  IMPLEMENT_ENUM(DateTime::TimeOrigin)
36  const DateTime::TimeOrigin DateTime::TimeOrigin::LOCAL_TIME("LOCAL_TIME");
37  const DateTime::TimeOrigin DateTime::TimeOrigin::GMT_TIME("GMT_TIME");
38 
39 
40  IMPLEMENT_ENUM(DateTime::TimeType)
41  const DateTime::TimeType DateTime::TimeType::CLOCK_TIME("CLOCK_TIME");
42  const DateTime::TimeType DateTime::TimeType::SIMULATION_TIME("SIMULATION_TIME");
43  const DateTime::TimeType DateTime::TimeType::SCENARIO_TIME("SCENARIO_TIME");
44  const DateTime::TimeType DateTime::TimeType::TRIP_TIME("TRIP_TIME");
45  const DateTime::TimeType DateTime::TimeType::TIME_STAMP("TIME_STAMP");
46  const DateTime::TimeType DateTime::TimeType::TIME_TYPE_OTHER("TIME_TYPE_OTHER");
47 
48 
49 
50  IMPLEMENT_ENUM(DateTime::TimeFormat)
51 
52  const DateTime::TimeFormat DateTime::TimeFormat::LOCAL_DATE_AND_TIME_FORMAT("LOCAL_DATE_AND_TIME_FORMAT");
53  const DateTime::TimeFormat DateTime::TimeFormat::LOCAL_DATE_FORMAT("LOCAL_DATE_FORMAT");
54  const DateTime::TimeFormat DateTime::TimeFormat::CLOCK_TIME_12_HOUR_FORMAT("CLOCK_TIME_12_HOUR_FORMAT");
55  const DateTime::TimeFormat DateTime::TimeFormat::LEXICAL_DATE_FORMAT("LEXICAL_DATE_FORMAT");
56 
57  const DateTime::TimeFormat DateTime::TimeFormat::CALENDAR_DATE_FORMAT("CALENDAR_DATE_FORMAT");
58  const DateTime::TimeFormat DateTime::TimeFormat::ORDINAL_DATE_FORMAT("ORDINAL_DATE_FORMAT");
59  const DateTime::TimeFormat DateTime::TimeFormat::WEEK_DATE_FORMAT("WEEK_DATE_FORMAT");
60  const DateTime::TimeFormat DateTime::TimeFormat::CLOCK_TIME_24_HOUR_FORMAT("CLOCK_TIME_24_HOUR_FORMAT");
61  const DateTime::TimeFormat DateTime::TimeFormat::CALENDAR_DATE_AND_TIME_FORMAT("CALENDAR_DATE_AND_TIME_FORMAT");
62 
63 
66  {
68  }
69 
72  {
74  mTimeOrigin = &to;
75 
77  {
78  SetToGMTTime();
79  }
81  {
83  }
84  }
85 
88  {
90  SetTime(t);
91  }
92 
94  DateTime::DateTime(const struct tm& t)
95  {
97  SetTime(t);
98  }
99 
100 
103  {
104  *this = rhs;
105  }
106 
109  {
110  mTimeScale = rhs.mTimeScale;
112  mSeconds = rhs.mSeconds;
113  mMinutes = rhs.mMinutes;
114  mHours = rhs.mHours;
115  mDays = rhs.mDays;
116  mMonths = rhs.mMonths;
117  mYears = rhs.mYears;
118  mGMTOffset = rhs.mGMTOffset;
119  mTimeOrigin = rhs.mTimeOrigin;
120  mTimeType = rhs.mTimeType;
122 
123  return *this;
124  }
125 
128  {
129 
130  }
131 
134  {
135  mTimeScale = 1.0f;
136  mFractionalSeconds = 0.0f;
137  mSeconds = 0;
138  mMinutes = 0;
139  mHours = 0;
140  mDays = 0;
141  mMonths = 0;
142  mYears = 0;
143  mGMTOffset = 0.0f;
147  }
148 
149 
151  DateTime::operator time_t() const
152  {
153  return GetTime();
154  }
155 
157  DateTime::operator tm() const
158  {
159  tm t;
160  GetTime(t);
161  return t;
162  }
163 
165  DateTime::operator std::string() const
166  {
167  return ToString();
168  }
169 
171  float DateTime::GetLocalGMTOffset(bool accountForDST)
172  {
173  time_t t = time(nullptr);
174  struct tm timeParts;
175  GetLocalTime(&t, timeParts);
176  float offset = CalcGMTOffset(timeParts, accountForDST);
177  return offset;
178  }
179 
181  void DateTime::IncrementClock(double seconds)
182  {
183  time_t timeInSeconds = *this;
184  seconds *= mTimeScale;
185  //accumulate fractions of a second and store off the remainder
186  seconds += mFractionalSeconds;
187  double floorSec = std::floor(seconds);
188 
189  timeInSeconds += time_t(floorSec);
190  SetTime(timeInSeconds);
191 
192  mFractionalSeconds = seconds - floorSec;
193  }
194 
196  void DateTime::AdjustTimeZone(float newGMTOffset)
197  {
198  float adjustmentToMake = newGMTOffset - mGMTOffset;
199  double adjustmentToMakeInSec = adjustmentToMake * 60.0 * 60.0;
200  IncrementClock(adjustmentToMakeInSec);
201  mGMTOffset = newGMTOffset;
202  }
203 
206  {
207  time_t t = time(nullptr);
208  struct tm timeParts;
209  GetLocalTime(&t, timeParts);
210  SetTime(timeParts);
211  mFractionalSeconds = 0.0f;
212  mGMTOffset = CalcGMTOffset(timeParts, false);
213  }
214 
217  {
218  time_t t = time(nullptr);
219  struct tm timeParts;
220  GetGMTTime(&t, timeParts);
221  SetTime(timeParts);
222  mFractionalSeconds = 0.0f;
223  mGMTOffset = 0.0f;
224  }
225 
226 
228  void DateTime::GetTime(unsigned& year, unsigned& month, unsigned& day, unsigned& hour, unsigned& min, float& sec) const
229  {
230  year = mYears;
231  month = mMonths;
232  day = mDays;
233  hour = mHours;
234  min = mMinutes;
235  sec = (float)mSeconds;
236  }
237 
239  void DateTime::GetTime(unsigned& year, unsigned& month, unsigned& day, unsigned& hour, unsigned& min, unsigned& sec) const
240  {
241  year = mYears;
242  month = mMonths;
243  day = mDays;
244  hour = mHours;
245  min = mMinutes;
246  sec = unsigned(floorf((float)mSeconds));
247  }
248 
250  void DateTime::GetGMTTime(unsigned& year, unsigned& month, unsigned& day, unsigned& hour, unsigned& min, float& sec) const
251  {
252  DateTime dt(GetGMTTime());
253  year = dt.mYears;
254  month = dt.mMonths;
255  day = dt.mDays;
256  hour = dt.mHours;
257  min = dt.mMinutes;
258  sec = (float)dt.mSeconds;
259  }
260 
262  void DateTime::GetGMTTime(unsigned& year, unsigned& month, unsigned& day, unsigned& hour, unsigned& min, unsigned& sec) const
263  {
264  DateTime dt(GetGMTTime());
265  year = dt.mYears;
266  month = dt.mMonths;
267  day = dt.mDays;
268  hour = dt.mHours;
269  min = dt.mMinutes;
270  sec = unsigned(floorf((float)dt.mSeconds));
271  }
272 
274  void DateTime::SetTime(unsigned year, unsigned month, unsigned day, unsigned hour, unsigned min, float sec)
275  {
276  mYears = year;
277  mMonths = month;
278  mDays = day;
279  mHours = hour;
280  mMinutes = min;
281  mSeconds = (unsigned)floorf(sec);
283  }
284 
286  void DateTime::SetTime(unsigned year, unsigned month, unsigned day, unsigned hour, unsigned min, unsigned sec)
287  {
288  mYears = year;
289  mMonths = month;
290  mDays = day;
291  mHours = hour;
292  mMinutes = min;
293  mSeconds = sec;
294  mFractionalSeconds = 0;
295  }
296 
299  {
300  return double(GetTime()) + mFractionalSeconds;
301  }
302 
304  time_t DateTime::GetTime() const
305  {
306  struct tm mt;
307  mt.tm_mon = mMonths - 1;
308  mt.tm_mday = mDays;
309  mt.tm_year = mYears - 1900;
310  mt.tm_hour = mHours;
311  mt.tm_min = mMinutes;
312  mt.tm_sec = mSeconds;
313  mt.tm_isdst = 0;
314 
315 
340 #ifdef TR_WIN
341  // mktime on windows adjusts for time zone, and we really don't want that
342  time_t ret = _mkgmtime(&mt);
343 #else
344  time_t ret = timegm(&mt);
345 #endif
346 
347  return ret;
348  }
349 
351  time_t DateTime::GetGMTTime() const
352  {
353  DateTime dt(GetTime());
354  dt.IncrementClock(3600.0f * -1.0f * mGMTOffset);
355  return dt.GetTime();
356  }
357 
359  void DateTime::SetTime(time_t t)
360  {
361  struct tm timeParts;
362  GetGMTTime(&t, timeParts);
363  SetTime(timeParts);
364  }
365 
367  void DateTime::GetTime(tm& timeParts) const
368  {
369  time_t t = GetTime();
370  GetGMTTime(&t, timeParts);
371  }
372 
374  void DateTime::GetGMTTime(tm& timeParts) const
375  {
376  DateTime dt(GetTime());
377  dt.IncrementClock(double(3600.0f * -mGMTOffset));
378  dt.GetTime(timeParts);
379  }
380 
382  void DateTime::SetTime(const tm& mt)
383  {
384  mMonths = mt.tm_mon + 1;
385  mDays = mt.tm_mday;
386  mYears = mt.tm_year + 1900;
387  mHours = mt.tm_hour;
388  mMinutes = mt.tm_min;
389  mSeconds = mt.tm_sec;
390 
391  mFractionalSeconds = 0.0f;
392  }
393 
395  void DateTime::SetGMTOffset(float hourOffset, bool dayLightSavings)
396  {
397  mGMTOffset = hourOffset + int(dayLightSavings);
398  }
399 
401  float DateTime::CalcGMTOffset(tm& timeParts, bool factorLocalDayLightSavingsIntoGMTOffset)
402  {
403 #ifdef TR_WIN
404  _tzset();
405  long tz;
406  _get_timezone(&tz);
407  tz = tz * -1;
408  float result = tz / 3600.0f;
409 
410  if (factorLocalDayLightSavingsIntoGMTOffset)
411  {
412  result += timeParts.tm_isdst;
413  }
414 #else
415  // If we are in daylight saving time, the gmt offset already accounts for that
416  // But the dateTime wants the value without it taken into account, so we have to
417  // subtract it back out.
418  long tz = timeParts.tm_gmtoff;
419  float result = tz / 3600.0f;
420 
421  if (!factorLocalDayLightSavingsIntoGMTOffset)
422  {
423  result -= timeParts.tm_isdst;
424  }
425 #endif
426  return result;
427  }
428 
430  void DateTime::SetGMTOffset(double /*latitude*/, double longitude, bool dayLightSavings)
431  {
432  double offset = 7.5;
433 
434  if (longitude < 0.0f)
435  {
436  offset = -offset;
437  }
438 
439  mGMTOffset = float(int(dayLightSavings) + int((longitude + offset) / 15.0));
440  }
441 
444  {
445  return mGMTOffset;
446  }
447 
449  float DateTime::GetSecond() const
450  {
451  return (float)(float(mSeconds) + mFractionalSeconds);
452  }
453 
455  void DateTime::SetSecond(float sec)
456  {
457  float seconds = std::floor(sec);
458  mSeconds = unsigned(seconds);
459  mFractionalSeconds = double(sec) - double(seconds);
460  }
461 
463  unsigned DateTime::GetMinute() const
464  {
465  return mMinutes;
466  }
467 
469  void DateTime::SetMinute(unsigned min)
470  {
471  mMinutes = min;
472  }
473 
475  unsigned DateTime::GetHour() const
476  {
477  return mHours;
478  }
479 
481  void DateTime::SetHour(unsigned hour)
482  {
483  mHours = hour;
484  }
485 
486 
488  unsigned DateTime::GetDay() const
489  {
490  return mDays;
491  }
492 
494  void DateTime::SetDay(unsigned day)
495  {
496  mDays = day;
497  }
498 
499 
501  unsigned DateTime::GetMonth() const
502  {
503  return mMonths;
504  }
505 
507  void DateTime::SetMonth(unsigned month)
508  {
509  mMonths = month;
510  }
511 
512 
514  unsigned DateTime::GetYear() const
515  {
516  return mYears;
517  }
518 
520  void DateTime::SetYear(unsigned year)
521  {
522  mYears = year;
523  }
524 
525 
528  {
529  return mTimeScale;
530  }
531 
533  void DateTime::SetTimeScale(float percentScaleInSeconds)
534  {
535  mTimeScale = percentScaleInSeconds;
536  }
537 
538 
541  {
542  return *mTimeType;
543  }
544 
547  {
548  mTimeType = &tt;
549  }
550 
553  {
554  return *mTimeOrigin;
555  }
556 
559  {
560  mTimeOrigin = &to;
561  }
562 
563 
566  {
567  return *mStringFormat;
568  }
569 
572  {
573  mStringFormat = &tf;
574  }
575 
577  std::string DateTime::ToString() const
578  {
579  return ToString(*mStringFormat);
580  }
581 
583  std::string DateTime::ToString(const DateTime& dt, const TimeFormat& tf)
584  {
585  return dt.ToString(tf);
586  }
587 
588 
590  std::string DateTime::ToString(const TimeFormat& tf) const
591  {
592  char buffer[80];
593  struct tm timeParts = *this; //conversion operator
594  std::string str;
595 
597  {
598  //this case we must handle specially because the msvc compiler insists on
599  //writing out the time zone for %z as opposed to printing the actual offset
600  //this is what we want it to look like
601  //2007-05-10T16:08:18.0-05:00
602 
603  float tz = GetGMTOffset();
604 
605  int tzHour = (int)floorf(tz);
606  int tzMin = (int)(tz - float(tzHour));
607 
608 #ifdef TR_WIN
609  _snprintf_s(buffer, 80, "%04d-%02d-%02d T%02d:%02d:%02d%+03d:%02d",
610 #else
611  snprintf(buffer, 80, "%04d-%02d-%02d T%02d:%02d:%02d%+03d:%02d", //Commented out because of deprecation warnings
612 #endif //TR_WIN
613  timeParts.tm_year + 1900, timeParts.tm_mon + 1, timeParts.tm_mday,
614  timeParts.tm_hour, timeParts.tm_min, timeParts.tm_sec,
615  tzHour, tzMin);
616  }
617  else
618  {
620  {
621  strftime(buffer, 80, "%F %T", &timeParts);
622  }
624  {
625  strftime(buffer, 80, "%I:%M:%S %p", &timeParts);
626  }
627  else if (tf == TimeFormat::LOCAL_DATE_FORMAT)
628  {
629  strftime(buffer, 80, "%x", &timeParts);
630  }
631  else if (tf == TimeFormat::LEXICAL_DATE_FORMAT)
632  {
633  strftime(buffer, 80, "%B %d, %Y", &timeParts);
634  }
635  else if (tf == TimeFormat::CALENDAR_DATE_FORMAT)
636  {
637  strftime(buffer, 80, "%Y-%m-%d", &timeParts);
638  }
640  {
641  strftime(buffer, 80, "%H:%M:%S", &timeParts);
642  }
643  else if (tf == TimeFormat::WEEK_DATE_FORMAT)
644  {
645  strftime(buffer, 80, "%Y-W%U-%w", &timeParts);
646  }
647  else if (tf == TimeFormat::ORDINAL_DATE_FORMAT)
648  {
649  strftime(buffer, 80, "%Y-%j", &timeParts);
650  }
651  }
652 
653  str.assign(buffer);
654  return str;
655  }
656 
657 
658 
659  void DateTime::GetGMTTime(time_t* t, tm& timeParts)
660  {
661  if (t != nullptr)
662  {
663 #ifdef TR_WIN
664  bool result = gmtime_s(&timeParts, t) != EINVAL;
665 #else
666  bool result = gmtime_r(t, &timeParts) != nullptr;
667 #endif
668  if (result)
669  {
670  return;
671  }
672  }
673 
674  memset(&timeParts, 0, sizeof(tm));
675  }
676 
677 
678  void DateTime::GetLocalTime(time_t* t, tm& timeParts)
679  {
680  if (t != nullptr)
681  {
682 #ifdef TR_WIN
683  bool result = localtime_s(&timeParts, t) != EINVAL;
684 #else
685  bool result = localtime_r(t, &timeParts) != nullptr;
686 #endif
687  if (result)
688  {
689  return;
690  }
691  }
692 
693  memset(&timeParts, 0, sizeof(tm));
694  }
695 }
DateTime()
The default constructor just zeros.
Definition: DateTime.cpp:65
unsigned GetMinute() const
Gets the minute.
Definition: DateTime.cpp:463
void SetGMTOffset(float hourOffset, bool dayLightSavings)
Sets the GMTOffset which is added to the time when getting GMT time,.
Definition: DateTime.cpp:395
void SetToGMTTime()
Changes time to be GMT- or Greenwich Mean Time.
Definition: DateTime.cpp:216
static const TimeFormat CALENDAR_DATE_AND_TIME_FORMAT
CALENDAR_DATE_AND_TIME_FORMAT: 2008-04-18T13:22:50-05:00.
Definition: DateTime.h:173
DateTime & operator=(const DateTime &)
Assignment operator.
Definition: DateTime.cpp:108
static const TimeType TRIP_TIME
The trip time.
Definition: DateTime.h:106
void SetToLocalTime()
Changes time to be system local time.
Definition: DateTime.cpp:205
static void GetLocalTime(time_t *t, tm &timeParts)
Gets local time.
Definition: DateTime.cpp:678
float mTimeScale
The time scale.
Definition: DateTime.h:822
const TimeFormat * mStringFormat
The string format.
Definition: DateTime.h:840
unsigned GetDay() const
Gets the day.
Definition: DateTime.cpp:488
const TimeType & GetTimeType() const
The TimeType enumeration is used to identify the purpose of a DateTime instance.
Definition: DateTime.cpp:540
void SetMonth(unsigned month)
Sets a month.
Definition: DateTime.cpp:507
void SetSecond(float sec)
Sets a second.
Definition: DateTime.cpp:455
static float CalcGMTOffset(tm &timeParts, bool factorLocalDayLightSavingsIntoGMTOffset)
Sets the GMTOffset using the systems local time this offset is added to the time when getting GMT tim...
Definition: DateTime.cpp:401
virtual ~DateTime()
Destructor.
Definition: DateTime.cpp:127
unsigned mMinutes
Definition: DateTime.h:833
float GetTimeScale() const
The TimeScale can be used to scale the time when incrementing the clock.
Definition: DateTime.cpp:527
static const TimeType TIME_STAMP
The time stamp.
Definition: DateTime.h:108
void AdjustTimeZone(float newGMTOffset)
Every date time has a GMT offset.
Definition: DateTime.cpp:196
static const TimeFormat LOCAL_DATE_AND_TIME_FORMAT
LOCAL_DATE_AND_TIME_FORMAT: 04-18-08 13:22:50.
Definition: DateTime.h:149
double GetTimeInSeconds() const
Returns the total clock time in seconds elapsed since midnight, January 1, 1970 This time includes fr...
Definition: DateTime.cpp:298
void IncrementClock(double seconds)
Increments the clock time by the number of seconds specified.
Definition: DateTime.cpp:181
float GetGMTOffset() const
Gets the GMTOffset, this will be 0 unless SetGMTOffset was called or SetToLocalTime() was called...
Definition: DateTime.cpp:443
const TimeType * mTimeType
Type of the time.
Definition: DateTime.h:838
static const TimeFormat LOCAL_DATE_FORMAT
LOCAL_DATE_FORMAT: 04/18/08.
Definition: DateTime.h:152
time_t GetTime() const
Gets the time in the standard time_t format, specified as seconds elapsed since midnight, January 1, 1970.
Definition: DateTime.cpp:304
#define IMPLEMENT_ENUM(EnumType)
A macro that defines implement enum.
unsigned mSeconds
Definition: DateTime.h:833
static const TimeType CLOCK_TIME
The clock time.
Definition: DateTime.h:100
void SetYear(unsigned year)
Sets a year.
Definition: DateTime.cpp:520
float GetSecond() const
Gets the second.
Definition: DateTime.cpp:449
void SetDay(unsigned day)
Sets a day.
Definition: DateTime.cpp:494
void SetMinute(unsigned min)
Sets a minute.
Definition: DateTime.cpp:469
static float GetLocalGMTOffset(bool accountForDST=false)
Gets local GMT offset.
Definition: DateTime.cpp:171
static const TimeFormat CLOCK_TIME_12_HOUR_FORMAT
CLOCK_TIME_12_HOUR_FORMAT: 01:22:50 PM.
Definition: DateTime.h:155
void SetTimeScale(float percentScaleInSeconds)
The TimeScale can be used to scale the time when incrementing the clock.
Definition: DateTime.cpp:533
void SetTimeOrigin(const TimeOrigin &)
The TimeOrigin enumeration determines how the instance of DateTime should be interpreted.
Definition: DateTime.cpp:558
unsigned GetHour() const
Gets the hour.
Definition: DateTime.cpp:475
unsigned mDays
Definition: DateTime.h:833
float mGMTOffset
The GMT offset.
Definition: DateTime.h:820
static const TimeOrigin LOCAL_TIME
The local time.
Definition: DateTime.h:61
const TimeOrigin & GetTimeOrigin() const
The TimeOrigin enumeration determines how the instance of DateTime should be interpreted.
Definition: DateTime.cpp:552
void ResetToDefaultValues()
Resets to default values.
Definition: DateTime.cpp:133
void SetTimeFormat(const TimeFormat &)
The TimeFormat enumeration is used to specify how to map a DateTime object to a string.
Definition: DateTime.cpp:571
static const TimeFormat CALENDAR_DATE_FORMAT
CALENDAR_DATE_FORMAT: 2008-04-18.
Definition: DateTime.h:164
Namespace that holds various utility classes for the engine.
Definition: SmrtPtr.h:208
void SetHour(unsigned hour)
Sets a hour.
Definition: DateTime.cpp:481
unsigned GetMonth() const
Gets the month.
Definition: DateTime.cpp:501
time_t GetGMTTime() const
Gets the time in standard time_t format, the GMTOffset is added to the time before calculating time_t...
Definition: DateTime.cpp:351
const TimeFormat & GetTimeFormat() const
The TimeFormat enumeration is used to specify how to map a DateTime object to a string.
Definition: DateTime.cpp:565
unsigned GetYear() const
Gets the year.
Definition: DateTime.cpp:514
static const TimeFormat WEEK_DATE_FORMAT
WEEK_DATE_FORMAT: 2008-W15-5.
Definition: DateTime.h:170
std::string ToString() const
The no parameter version of ToString uses the internal TimeFormat, see the TimeFormat enumeration abo...
Definition: DateTime.cpp:577
static const TimeOrigin GMT_TIME
The GMT time.
Definition: DateTime.h:63
static const TimeFormat CLOCK_TIME_24_HOUR_FORMAT
CLOCK_TIME_24_HOUR_FORMAT: 13:22:50.
Definition: DateTime.h:158
unsigned mYears
Store parts of time.
Definition: DateTime.h:833
static const TimeType TIME_TYPE_OTHER
The time type other.
Definition: DateTime.h:110
static const TimeFormat LEXICAL_DATE_FORMAT
LEXICAL_DATE_FORMAT: April 18, 2008.
Definition: DateTime.h:161
const TimeOrigin * mTimeOrigin
The time origin.
Definition: DateTime.h:836
unsigned mHours
Definition: DateTime.h:833
unsigned mMonths
Definition: DateTime.h:833
void SetTimeType(const TimeType &)
The TimeType enumeration is used to identify the purpose of a DateTime instance.
Definition: DateTime.cpp:546
double mFractionalSeconds
The fractional in seconds.
Definition: DateTime.h:824
static const TimeType SIMULATION_TIME
The simulation time.
Definition: DateTime.h:102
void GetTime(unsigned &year, unsigned &month, unsigned &day, unsigned &hour, unsigned &min, float &sec) const
Gets the time internally stored using unsigned year, month, day, hour, minute, and seconds...
Definition: DateTime.cpp:228
void SetTime(unsigned year, unsigned month, unsigned day, unsigned hour, unsigned min, float sec)
Sets the full time using year, month, day, hour, minute, and second.
Definition: DateTime.cpp:274
static const TimeType SCENARIO_TIME
The scenario time.
Definition: DateTime.h:104
static const TimeFormat ORDINAL_DATE_FORMAT
ORDINAL_DATE_FORMAT: 2008-109.
Definition: DateTime.h:167