dbdate.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. //
  2. //
  3. //////////////////////////////////////////////////////////////////////////////
  4. //
  5. // Copyright 2015 Autodesk, Inc. All rights reserved.
  6. //
  7. // Use of this software is subject to the terms of the Autodesk license
  8. // agreement provided at the time of installation or download, or which
  9. // otherwise accompanies this software in either electronic or hard copy form.
  10. //
  11. //////////////////////////////////////////////////////////////////////////////
  12. //
  13. //
  14. // DESCRIPTION: API for date class.
  15. #ifndef AD_DBDATE_H
  16. #define AD_DBDATE_H
  17. #include "acdb.h"
  18. #pragma pack(push, 8)
  19. class AcDbDwgFiler;
  20. class AcDbDate
  21. {
  22. public:
  23. enum InitialValue {
  24. kInitZero = 1,
  25. kInitLocalTime = 2,
  26. kInitUniversalTime = 3
  27. };
  28. AcDbDate();
  29. AcDbDate(InitialValue i);
  30. AcDbDate(const AcDbDate&);
  31. virtual ~AcDbDate();
  32. const AcDbDate& operator= (const AcDbDate&);
  33. // Get and set the date.
  34. //
  35. void getDate (short& month, short& day, short& year) const;
  36. AcString getLocalDisplayString() const;
  37. void setDate (short month, short day, short year);
  38. short month () const;
  39. void setMonth(short);
  40. short day () const;
  41. void setDay (short);
  42. short year () const;
  43. void setYear (short);
  44. #if defined(_WINBASE_) || defined(_ADESK_MAC_)
  45. // Get and set with win32 SYSTEMTIME struct.
  46. //
  47. void getTime (SYSTEMTIME &st) const;
  48. void setTime (const SYSTEMTIME &st);
  49. #endif
  50. // Get and set the time.
  51. //
  52. void getTime (short& hour, short& min, short& sec, short& msec) const;
  53. void setTime (short hour, short min, short sec, short msec);
  54. int getApproximateTime () const;
  55. void setApproximateTime (int time);
  56. short hour () const;
  57. void setHour (short);
  58. short minute () const;
  59. void setMinute(short);
  60. short second () const;
  61. void setSecond(short);
  62. short millisecond() const;
  63. void setMillisecond(short);
  64. void setToZero();
  65. // Initialize with current time.
  66. //
  67. void getLocalTime();
  68. void getUniversalTime();
  69. // Convert between local and universal time
  70. //
  71. void localToUniversal();
  72. void universalToLocal();
  73. // Get/Set Julian representation for the date.
  74. //
  75. Adesk::Int32 julianDay () const;
  76. Adesk::Int32 msecsPastMidnight () const;
  77. void setJulianDay (Adesk::Int32 julianDay);
  78. void setMsecsPastMidnight(Adesk::Int32 msec);
  79. void setJulianDate (Adesk::Int32 julianDay, Adesk::Int32 msec);
  80. double julianFraction () const;
  81. void setJulianFraction (double);
  82. // Boolean comparison operators
  83. //
  84. bool operator== (const AcDbDate&) const;
  85. bool operator > (const AcDbDate&) const;
  86. bool operator >= (const AcDbDate&) const;
  87. bool operator < (const AcDbDate&) const;
  88. bool operator <= (const AcDbDate&) const;
  89. // Arithmetic operators.
  90. //
  91. const AcDbDate operator + (const AcDbDate &date) const;
  92. const AcDbDate operator - (const AcDbDate &date) const;
  93. const AcDbDate & operator += (const AcDbDate &date);
  94. const AcDbDate & operator -= (const AcDbDate &date);
  95. // Obsolete. Please use += or -= operators.
  96. const AcDbDate& add (const AcDbDate &date);
  97. const AcDbDate& subtract (const AcDbDate &date);
  98. // Dwg in and out.
  99. //
  100. Acad::ErrorStatus dwgOut(AcDbDwgFiler *outFiler) const;
  101. Acad::ErrorStatus dwgIn (AcDbDwgFiler *inFiler);
  102. private:
  103. friend class AcDbImpDate;
  104. class AcDbImpDate *mpImpDate;
  105. };
  106. inline const AcDbDate AcDbDate::operator + (const AcDbDate & d) const
  107. {
  108. return AcDbDate(*this) += d;
  109. }
  110. inline const AcDbDate AcDbDate::operator - (const AcDbDate & d) const
  111. {
  112. return AcDbDate(*this) -= d;
  113. }
  114. inline bool AcDbDate::operator < (const AcDbDate & d) const
  115. {
  116. return ! operator >= (d);
  117. }
  118. inline bool AcDbDate::operator <= (const AcDbDate & d) const
  119. {
  120. return ! operator > (d);
  121. }
  122. inline const AcDbDate & AcDbDate::add(const AcDbDate &date)
  123. {
  124. return operator += (date);
  125. }
  126. inline const AcDbDate & AcDbDate::subtract(const AcDbDate &date)
  127. {
  128. return operator -= (date);
  129. }
  130. #pragma pack(pop)
  131. #endif