Timer.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. #ifndef Time_H
  2. #define Time_H
  3. #include "OperatingSystem.h"
  4. #include "ReferenceCounter.h"
  5. namespace Framework
  6. {
  7. class Text; //! Text.h
  8. class Clock; //! From this file
  9. class Date; //! From this file
  10. class Time; //! From this file
  11. class Timer; //! From this file
  12. //! This class stores a time of day in the form of hours, minutes and
  13. //! seconds
  14. class Clock : public virtual ReferenceCounter
  15. {
  16. private:
  17. __int64 stunde, minute, sekunde;
  18. int update();
  19. public:
  20. //! Creates a new Clock object with the default values 00:00:00
  21. DLLEXPORT Clock();
  22. //! Sets the time by copying.
  23. //! \param zeit The values for hour, minute and second are
  24. //! copied from this object.
  25. DLLEXPORT int setClock(Clock* zeit);
  26. //! Sets the time.
  27. //! \param stunde The hour of the new time.
  28. //! \param minute The minute of the new time.
  29. //! \param sekunde The second of the new time.
  30. //! \return The number of remaining days.
  31. //! Example: setClock( 30, 30, 30 ); return: 1, stored: 6:30:30
  32. DLLEXPORT int setClock(int stunde, int minute, int sekunde);
  33. //! Sets the time.
  34. //! \param format A string that determines the format of the
  35. //! time in (zeit). h=hour, i=minute, s=second. \param
  36. //! zeit A string containing the new time. \return The
  37. //! number of remaining days. Example: setClock( "h:i:s", "05:30:00" );
  38. //! Example: setClock( "h:i:s", "30:30:00" ); return: 1, stored:
  39. //! 6:30:00
  40. DLLEXPORT int setClock(const char* format, const char* zeit);
  41. //! Sets the time.
  42. //! \param format A string that determines the format of the
  43. //! time in (zeit). h=hour, i=minute, s=second. \param
  44. //! zeit A Text object containing the new time. \return The
  45. //! number of remaining days. Example: setClock( "h:i:s", new Text(
  46. //! "05:30:00" ) ); Example: setClock( "h:i:s", new Text( "30:30:00"
  47. //! ) ); return: 1, stored: 6:30:00
  48. DLLEXPORT int setClock(const char* format, Text* zeit);
  49. //! Sets the hour.
  50. //! \param stunde The hour to be stored.
  51. //! \return The number of remaining days.
  52. //! Example: setStunde( 30 ); return: 1 day, stored hours: 6
  53. DLLEXPORT int setStunde(int stunde);
  54. //! Sets the minute.
  55. //! \param minute The minute to be stored.
  56. //! \return The number of remaining days.
  57. //! Example: Old time: 23:50:10, setMinute( 80 ); return: 1,
  58. //! stored time: 01:10:10
  59. DLLEXPORT int setMinute(int minute);
  60. //! Sets the second.
  61. //! \param minute The second to be stored.
  62. //! \return The number of remaining days.
  63. //! Example: Old time: 23:59:10, setSekunde( 80 ); return: 1,
  64. //! stored time: 00:00:30
  65. DLLEXPORT int setSekunde(int sekunde);
  66. //! Calculates the sum of this and another time and stores the result.
  67. //! \param zeit The time whose values are to be added.
  68. //! \return The number of remaining days.
  69. //! Example: Old time: 19:40:18, plusClock( (10:05:30) ); return 1,
  70. //! stored time: 05:45:48
  71. DLLEXPORT int plusClock(Clock* zeit);
  72. //! Calculates the sum of this and another time and stores the result.
  73. //! \param stunde The hours to be added.
  74. //! \param minute The minutes to be added.
  75. //! \param sekunde The seconds to be added.
  76. //! \return The number of remaining days.
  77. //! Example: Old time: 19:40:18, plusClock( 10, 5, 30 ); return 1,
  78. //! stored time: 05:45:48
  79. DLLEXPORT int plusClock(int stunde, int minute, int sekunde);
  80. //! Calculates the sum of this and another time and stores the result.
  81. //! \param format A string that determines the format of the
  82. //! time in (zeit). h=hour, i=minute, s=second.
  83. //! \param zeit A string containing the time to add.
  84. //! \return The number of remaining days.
  85. //! Example: Old time: 19:40:18, plusClock( "h:i:s", "10:05:30" );
  86. //! return 1, stored time: 05:45:48
  87. DLLEXPORT int plusClock(const char* format, const char* zeit);
  88. //! Calculates the sum of this and another time and stores the result.
  89. //! \param format A string that determines the format of the
  90. //! time in (zeit). h=hour, i=minute, s=second.
  91. //! \param zeit A Text object containing the time to add.
  92. //! \return The number of remaining days.
  93. //! Example: Old time: 19:40:18, plusClock( "h:i:s", new Text(
  94. //! "10:05:30" ) ); return 1, stored time: 05:45:48
  95. DLLEXPORT int plusClock(const char* format, Text* zeit);
  96. //! Calculates the sum of this and another time and stores the result.
  97. //! \param stunde The hours to add.
  98. //! \return The number of remaining days.
  99. //! Example: Old time: 20:50:30, plusHour( 10 ); return 1,
  100. //! stored time: 6:50:30
  101. DLLEXPORT int plusHour(__int64 stunde);
  102. //! Calculates the sum of this and another time and stores the result.
  103. //! \param minute The minutes to add.
  104. //! \return The number of remaining days.
  105. //! Example: Old time: 23:50:30, plusMinute( 11 ); return 1,
  106. //! stored time: 00:01:30
  107. DLLEXPORT int plusMinute(__int64 minute);
  108. //! Calculates the sum of this and another time and stores the result.
  109. //! \param sekunde The seconds to add.
  110. //! \return The number of remaining days.
  111. //! Example: Old time: 23:59:30, plusSecond( 40 ); return 1,
  112. //! stored time: 00:00:10
  113. DLLEXPORT int plusSecond(__int64 sekunde);
  114. //! Subtracts a given time from this one and stores the result.
  115. //! \param zeit The time to subtract.
  116. //! \return The number of remaining days.
  117. //! Example: Old time: 10:40:18, minusClock( (19:05:30) ); return -1,
  118. //! stored time: 15:34:48
  119. DLLEXPORT int minusClock(Clock* zeit);
  120. //! Subtracts a given time from this one and stores the result.
  121. //! \param stunde The hours to subtract.
  122. //! \param minute The minutes to subtract.
  123. //! \param sekunde The seconds to subtract.
  124. //! \return The number of remaining days.
  125. //! Example: Old time: 10:40:18, minusClock( 19, 05, 30 );
  126. //! return -1, stored time: 15:34:48
  127. DLLEXPORT int minusClock(int stunde, int minute, int sekunde);
  128. //! Subtracts a given time from this one and stores the result.
  129. //! \param format A string that determines the format of the
  130. //! time in (zeit). h=hour, i=minute, s=second.
  131. //! \param zeit A string containing the time to subtract.
  132. //! \return The number of remaining days.
  133. //! Example: Old time: 10:40:18, minusClock( "h:i:s", "19:05:30" );
  134. //! return -1, stored time: 15:34:48
  135. DLLEXPORT int minusClock(const char* format, const char* zeit);
  136. //! Subtracts a given time from this one and stores the result.
  137. //! \param format A string that determines the format of the
  138. //! time in (zeit). h=hour, i=minute, s=second.
  139. //! \param zeit A Text object containing the time to subtract.
  140. //! \return The number of remaining days.
  141. //! Example: Old time: 10:40:18, minusClock( "h:i:s", new Text(
  142. //! "19:05:30" ) ); return -1, stored time: 15:34:48
  143. DLLEXPORT int minusClock(const char* format, Text* zeit);
  144. //! Subtracts a given time from this one and stores the result.
  145. //! \param stunde The hours to subtract.
  146. //! \return The number of remaining days.
  147. //! Example: Old time: 10:40:18, minusHour( 19 ); return -1,
  148. //! stored time: 15:40:18
  149. DLLEXPORT int minusHour(__int64 stunde);
  150. //! Subtracts a given time from this one and stores the result.
  151. //! \param minute The minutes to subtract.
  152. //! \return The number of remaining days.
  153. //! Example: Old time: 00:40:18, minusMinute( 50 ); return -1,
  154. //! stored time: 23:50:18
  155. DLLEXPORT int minusMinute(__int64 minute);
  156. //! Subtracts a given time from this one and stores the result.
  157. //! \param sekunde The seconds to subtract.
  158. //! \return The number of remaining days.
  159. //! Example: Old time: 00:00:20, minusSecond( 50 ); return -1,
  160. //! stored time: 23:59:30
  161. DLLEXPORT int minusSecond(__int64 sekunde);
  162. //! Returns the hour.
  163. DLLEXPORT int getStunde() const;
  164. //! Returns the minute.
  165. DLLEXPORT int getMinute() const;
  166. //! Returns the second.
  167. DLLEXPORT int getSekunde() const;
  168. //! Returns the time formatted as text.
  169. //! \param format A string that determines the format of the
  170. //! returned time. h=hour, i=minute, s=second.
  171. //! Example: Time: 5:40:39, getClock( "h:i:s" ); return: "5:40:39"
  172. DLLEXPORT Text* getClock(const char* format) const;
  173. //! Checks if the time equals zeit.
  174. //! \param zeit The time to compare with.
  175. //! \return (true) if both times are equal. (false) if they
  176. //! are not equal.
  177. DLLEXPORT bool isEqual(Clock* zeit) const;
  178. //! Checks if the time equals zeit.
  179. //! \param format A string that determines the format of the
  180. //! time in (zeit). h=hour, i=minute, s=second. \param
  181. //! zeit A string containing the other time. \return
  182. //! (true) if both times are equal. (false) if they
  183. //! are not equal.
  184. DLLEXPORT bool isEqual(const char* format, const char* zeit) const;
  185. //! Checks if the time equals zeit.
  186. //! \param format A string that determines the format of the
  187. //! time in (zeit). h=hour, i=minute, s=second. \param
  188. //! zeit A Text object containing the other time.
  189. //! \return (true) if both times are equal. (false) if they
  190. //! are not equal.
  191. DLLEXPORT bool isEqual(const char* format, Text* zeit) const;
  192. //! Checks if the time equals the given time. Does not validate
  193. //! whether the given time is a valid time of day.
  194. //! \param stunde The hours of the time to check.
  195. //! \param minute The minutes of the time to check.
  196. //! \param sekunde The seconds of the time to check.
  197. //! \return (true) if both times are equal. (false) if they
  198. //! are not equal.
  199. DLLEXPORT bool isEqual(int stunde, int minute, int sekunde) const;
  200. //! Checks if the hour equals the given hour.
  201. //! \param stunde The hour to check.
  202. //! \return (true) if the hours are equal. (false) if they
  203. //! are not equal.
  204. DLLEXPORT bool hourEqual(int stunde) const;
  205. //! Checks if the minute equals the given minute.
  206. //! \param minute The minute to check.
  207. //! \return (true) if the minutes are equal. (false) if they
  208. //! are not equal.
  209. DLLEXPORT bool minuteEqual(int minute) const;
  210. //! Checks if the second equals the given second.
  211. //! \param sekunde The second to check.
  212. //! \return (true) if the seconds are equal. (false) if they
  213. //! are not equal.
  214. DLLEXPORT bool secondEqual(int sekunde) const;
  215. //! Checks if the time is less than zeit.
  216. //! \param zeit The time to check against.
  217. //! \return (true) if the stored time is less than the given
  218. //! time. (false) otherwise.
  219. //! Example: (5:30:00).isSmaller( (10:40:29) ); return true
  220. DLLEXPORT bool isSmaller(Clock* zeit) const;
  221. //! Checks if the time is less than the given time.
  222. //! \param stunde The hours of the time to check.
  223. //! \param minute The minutes of the time to check.
  224. //! \param sekunde The seconds of the time to check.
  225. //! \return (true) if the stored time is less than the given
  226. //! time. (false) otherwise.
  227. //! Example: (5:30:00).isSmaller( 10, 40, 29 ); return true
  228. DLLEXPORT bool isSmaller(int stunde, int minute, int sekunde) const;
  229. //! Checks if the time is less than the given time.
  230. //! \param format A string that determines the format of the
  231. //! time in (zeit). h=hour, i=minute, s=second. \param
  232. //! zeit A string containing the other time. \return
  233. //! (true) if the stored time is less than the given
  234. //! time. (false) otherwise.
  235. //! Example: (5:30:00).isSmaller( "h:i:s", "10:40:29" ); return true
  236. DLLEXPORT bool isSmaller(const char* format, const char* zeit) const;
  237. //! Checks if the time is less than the given time.
  238. //! \param format A string that determines the format of the
  239. //! time in (zeit). h=hour, i=minute, s=second. \param
  240. //! zeit A Text object containing the other time.
  241. //! \return (true) if the stored time is less than the given
  242. //! time. (false) otherwise.
  243. DLLEXPORT bool isSmaller(const char* format, Text* zeit) const;
  244. //! Checks if the time is greater than zeit.
  245. //! \param zeit The time to check against.
  246. //! \return (true) if the stored time is greater than the given
  247. //! time. (false) otherwise.
  248. //! Example: (5:30:00).isLater( (10:40:29) ); return false
  249. DLLEXPORT bool isLater(Clock* zeit) const;
  250. //! Checks if the time is greater than the given time.
  251. //! \param stunde The hours of the time to check.
  252. //! \param minute The minutes of the time to check.
  253. //! \param sekunde The seconds of the time to check.
  254. //! \return (true) if the stored time is greater than the given
  255. //! time. (false) otherwise.
  256. //! Example: (5:30:00).isLater( 10, 40, 29 ); return false
  257. DLLEXPORT bool isLater(int stunde, int minute, int sekunde) const;
  258. //! Checks if the time is greater than the given time.
  259. //! \param format A string that determines the format of the
  260. //! time in (zeit). h=hour, i=minute, s=second. \param
  261. //! zeit A string containing the other time. \return
  262. //! (true) if the stored time is greater than the given
  263. //! time. (false) otherwise.
  264. //! Example: (5:30:00).isLater( "h:i:s", "10:40:29" ); return false
  265. DLLEXPORT bool isLater(const char* format, const char* zeit) const;
  266. //! Checks if the time is greater than the given time.
  267. //! \param format A string that determines the format of the
  268. //! time in (zeit). h=hour, i=minute, s=second. \param
  269. //! zeit A Text object containing the other time.
  270. //! \return (true) if the stored time is greater than the given
  271. //! time. (false) otherwise.
  272. //! Example: (5:30:00).isLater( "h:i:s", "10:40:29" ); return false
  273. DLLEXPORT bool isLater(const char* format, Text* zeit) const;
  274. };
  275. //! This class stores a date in the form of year, month and day
  276. class Date : public virtual ReferenceCounter
  277. {
  278. private:
  279. int jahr, monat, tag;
  280. int* maxTage;
  281. void update();
  282. public:
  283. //! Creates a new Date object with the default values 0.0.0.
  284. DLLEXPORT Date();
  285. //! Deletes the date.
  286. DLLEXPORT ~Date();
  287. //! Sets the date by copying.
  288. //! \param datum The date to store.
  289. DLLEXPORT void setDate(Date* datum);
  290. //! Sets the date to the given values.
  291. //! \param jahr The year of the new date.
  292. //! \param monat The month of the new date.
  293. //! \param tag The day of the new date.
  294. DLLEXPORT void setDate(int jahr, int monat, int tag);
  295. //! Sets the date to the given value.
  296. //! \param format A string specifying the format of the
  297. //! date in (datum). y=year, m=month, d=day. \param datum
  298. //! A string containing the new date.
  299. //! Example: setDate( "y-m-d", "2016-01-25" );
  300. DLLEXPORT void setDate(const char* format, const char* datum);
  301. //! Sets the date to the given value.
  302. //! \param format A string specifying the format of the
  303. //! date in (datum). y=year, m=month, d=day. \param datum
  304. //! A Text object containing the new date.
  305. //! Example: setDate( "y-m-d", new Text( "2016-01-25" ) );
  306. DLLEXPORT void setDate(const char* format, Text* datum);
  307. //! Changes the year of the date.
  308. //! \param jahr The new year.
  309. DLLEXPORT void setJahr(int jahr);
  310. //! Changes the month of the date.
  311. //! \param monat The new month.
  312. DLLEXPORT void setMonat(int monat);
  313. //! Changes the day of the date.
  314. //! \param tag The new day.
  315. DLLEXPORT void setTag(int tag);
  316. //! Adds the given date to the current date and stores the result.
  317. //! \param datum The date to add.
  318. //! Example: ( 1.11.1995 ).plusDate( ( 5.2.7 ) ); new date: 6.1.2003
  319. DLLEXPORT void plusDate(Date* datum);
  320. //! Adds the given date to the current date and stores the result.
  321. //! \param jahr The year to add. \param monat The month to add.
  322. //! \param tag The day to add.
  323. //! Example: ( 1.11.1995 ).plusDate( 7, 2, 5 ); new date: 6.1.2003
  324. DLLEXPORT void plusDate(int jahr, int monat, int tag);
  325. //! Adds the given date to the current date and stores the result.
  326. //! \param format A string specifying the format of the
  327. //! date in (datum). y=year, m=month, d=day.
  328. //! \param datum A string containing the date to add.
  329. //! Example: ( 1.11.1995 ).plusDate( "d.m.y", "5.2.7" );
  330. //! new date: 6.1.2003
  331. DLLEXPORT void plusDate(const char* format, const char* datum);
  332. //! Adds the given date to the current date and stores the result.
  333. //! \param format A string specifying the format of the
  334. //! date in (datum). y=year, m=month, d=day.
  335. //! \param datum A Text object containing the date to add.
  336. //! Example: ( 1.11.1995 ).plusDate( "d.m.y", new Text(
  337. //! "5.2.7" ) ); new date: 6.1.2003
  338. DLLEXPORT void plusDate(const char* format, Text* datum);
  339. //! Adds the given year to the current date and stores the result.
  340. //! \param jahr The year to add.
  341. //! Example: ( 1.11.1995 ).plusYear( 21 ); new date: 1.11.2016
  342. DLLEXPORT void plusYear(int jahr);
  343. //! Adds the given month to the current date and stores the result.
  344. //! \param monat The month to add.
  345. //! Example: ( 1.11.1995 ).plusMonth( 13 ); new date: 1.12.1996
  346. DLLEXPORT void plusMonth(int monat);
  347. //! Adds the given day to the current date and stores the result.
  348. //! \param tag The day to add.
  349. //! Example: ( 1.1.2000 ).plusDay( 32 ); new date: 2.2.2000
  350. DLLEXPORT void plusDay(int tag);
  351. //! Subtracts the given date from the current date and stores the
  352. //! result.
  353. //! \param datum The date to subtract.
  354. //! Example: ( 2.12.1996 ).minusDate( ( 1.1.1 ) ); new date: 1.11.1995
  355. DLLEXPORT void minusDate(Date* datum);
  356. //! Subtracts the given date from the current date and stores the
  357. //! result.
  358. //! \param jahr The year to subtract. \param monat The month to
  359. //! subtract.
  360. //! \param tag The day to subtract.
  361. //! Example: ( 2.12.1996 ).minusDate( 1, 1, 1 ); new date: 1.11.1995
  362. DLLEXPORT void minusDate(int jahr, int monat, int tag);
  363. //! Subtracts the given date from the current date and stores the
  364. //! result.
  365. //! \param format A string specifying the format of the
  366. //! date in (datum). y=year, m=month, d=day.
  367. //! \param datum A string containing the date to subtract.
  368. //! Example: ( 2.12.1996 ).minusDate( "d.m.y", "1.1.1" );
  369. //! new date: 1.11.1995
  370. DLLEXPORT void minusDate(const char* format, const char* datum);
  371. //! Subtracts the given date from the current date and stores the
  372. //! result.
  373. //! \param format A string specifying the format of the
  374. //! date in (datum). y=year, m=month, d=day.
  375. //! \param datum A Text object containing the date to subtract.
  376. //! Example: ( 2.12.1996 ).minusDate( "d.m.y", new Text(
  377. //! "1.1.1" ) ); new date: 1.11.1995
  378. DLLEXPORT void minusDate(const char* format, Text* datum);
  379. //! Subtracts the given year from the current date and stores the
  380. //! result.
  381. //! \param jahr The year to subtract.
  382. //! Example: ( 1.11.1996 ).minusYear( 1 ); new date: 1.11.1995
  383. DLLEXPORT void minusYear(int jahr);
  384. //! Subtracts the given month from the current date and stores the
  385. //! result.
  386. //! \param monat The month to subtract.
  387. //! Example: ( 1.12.1996 ).minusMonth( 13 ); new date: 1.11.1995
  388. DLLEXPORT void minusMonth(int monat);
  389. //! Subtracts the given day from the current date and stores the result.
  390. //! \param tag The day to subtract.
  391. //! Example: ( 5.2.2016 ).minusDay( 11 ); new date: 25.1.2016
  392. DLLEXPORT void minusDay(int tag);
  393. //! Returns the year.
  394. DLLEXPORT int getJahr() const;
  395. //! Returns the month.
  396. DLLEXPORT int getMonat() const;
  397. //! Returns the day.
  398. DLLEXPORT int getTag() const;
  399. //! Returns the date as a Text object.
  400. //! \param format A string specifying the format of the
  401. //! returned date. y=year, m=month, d=day.
  402. //! Example: ( 1.11.1995 ).getDate( "y-m-d" ); return: "1995-11-1"
  403. DLLEXPORT Text* getDate(const char* format) const;
  404. //! Checks if the date equals the given date.
  405. //! \param datum The date to check.
  406. //! \return (true) if the given date matches the stored one.
  407. //! (false) otherwise.
  408. DLLEXPORT bool isEqual(Date* datum) const;
  409. //! Checks if the date equals the given date.
  410. //! \param format A string specifying the format of the
  411. //! date in (datum). y=year, m=month, d=day. \param datum
  412. //! A string containing the date to check. \return
  413. //! (true) if the given date matches the stored one.
  414. //! (false) otherwise.
  415. //! Example: ( 1.11.1995 ).isEqual( "y-m-d", "1995-11-1" ); return: true
  416. DLLEXPORT bool isEqual(const char* format, const char* datum) const;
  417. //! Checks if the date equals the given date.
  418. //! \param format A string specifying the format of the
  419. //! date in (datum). y=year, m=month, d=day. \param datum
  420. //! A Text object containing the date to check.
  421. //! \return (true) if the given date matches the stored one.
  422. //! (false) otherwise.
  423. //! Example: ( 1.11.1995 ).isEqual( "y-m-d", new Text( "1995-11-1" ) );
  424. //! return: true
  425. DLLEXPORT bool isEqual(const char* format, Text* datum) const;
  426. //! Checks if the date equals the given date.
  427. //! \param jahr The year of the date to check.
  428. //! \param monat The month of the date to check.
  429. //! \param tag The day of the date to check.
  430. //! \return (true) if the given date matches the stored one.
  431. //! (false) otherwise.
  432. //! Example: ( 1.11.1995 ).isEqual( 1995, 11, 1 ); return: true
  433. DLLEXPORT bool isEqual(int jahr, int monat, int tag) const;
  434. //! Checks if the year equals the given year.
  435. //! \param jahr The year to check.
  436. //! \return (true) if the given year matches the stored one.
  437. //! (false) otherwise.
  438. DLLEXPORT bool yearEqual(int jahr) const;
  439. //! Checks if the month equals the given month.
  440. //! \param monat The month to check.
  441. //! \return (true) if the given month matches the stored one.
  442. //! (false) otherwise.
  443. DLLEXPORT bool monthEqual(int monat) const;
  444. //! Checks if the day equals the given day.
  445. //! \param tag The day to check.
  446. //! \return (true) if the given day matches the stored one.
  447. //! (false) otherwise.
  448. DLLEXPORT bool dayEqual(int tag) const;
  449. //! Checks if the stored date is less than the given one.
  450. //! \param datum The date to check.
  451. //! \return (true) if the stored date is before the given one.
  452. //! (false) otherwise.
  453. //! Example: ( 1.11.1995 ).isSmaller( ( 23.1.2016 ) ); return true
  454. DLLEXPORT bool isSmaller(Date* datum) const;
  455. //! Checks if the stored date is less than the given one.
  456. //! \param jahr The year of the date to check.
  457. //! \param monat The month of the date to check.
  458. //! \param tag The day of the date to check.
  459. //! \return (true) if the stored date is before the given one.
  460. //! (false) otherwise.
  461. //! Example: ( 1.11.1995 ).isSmaller( 2016, 1, 23 ); return true
  462. DLLEXPORT bool isSmaller(int jahr, int monat, int tag) const;
  463. //! Checks if the stored date is less than the given one.
  464. //! \param format A string specifying the format of the
  465. //! date in (datum). y=year, m=month, d=day. \param datum
  466. //! A string containing the date to check. \return
  467. //! (true) if the stored date is before the given one.
  468. //! (false) otherwise.
  469. //! Example: ( 1.11.1995 ).isSmaller( "y, m, d", "2016, 1, 23" ); return
  470. //! true
  471. DLLEXPORT bool isSmaller(const char* format, const char* datum) const;
  472. //! Checks if the stored date is less than the given one.
  473. //! \param format A string specifying the format of the
  474. //! date in (datum). y=year, m=month, d=day. \param datum
  475. //! A Text object containing the date to check.
  476. //! \return (true) if the stored date is before the given one.
  477. //! (false) otherwise.
  478. //! Example: ( 1.11.1995 ).isSmaller( "y, m, d", new Text( "2016, 1, 23"
  479. //! ) ); return true
  480. DLLEXPORT bool isSmaller(const char* format, Text* datum) const;
  481. //! Checks if the stored date is greater than the given one.
  482. //! \param datum The date to check.
  483. //! \return (true) if the stored date is after the given one.
  484. //! (false) otherwise.
  485. //! Example: ( 1.11.1995 ).isLater( ( 23.1.2016 ) ); return false
  486. DLLEXPORT bool isLater(Date* datum) const;
  487. //! Checks if the stored date is greater than the given one.
  488. //! \param jahr The year of the date to check.
  489. //! \param monat The month of the date to check.
  490. //! \param tag The day of the date to check.
  491. //! \return (true) if the stored date is after the given one.
  492. //! (false) otherwise.
  493. //! Example: ( 1.11.1995 ).isLater( 2016, 1, 23 ); return false
  494. DLLEXPORT bool isLater(int jahr, int monat, int tag) const;
  495. //! Checks if the stored date is greater than the given one.
  496. //! \param format A string specifying the format of the
  497. //! date in (datum). y=year, m=month, d=day. \param datum
  498. //! A string containing the date to check. \return
  499. //! (true) if the stored date is after the given one.
  500. //! (false) otherwise.
  501. //! Example: ( 1.11.1995 ).isLater( "y, m, d", "2016, 1, 23" ); return
  502. //! false
  503. DLLEXPORT bool isLater(const char* format, const char* datum) const;
  504. //! Checks if the stored date is greater than the given one.
  505. //! \param format A string specifying the format of the
  506. //! date in (datum). y=year, m=month, d=day. \param datum
  507. //! A Text object containing the date to check.
  508. //! \return (true) if the stored date is after the given one.
  509. //! (false) otherwise.
  510. //! Example: ( 1.11.1995 ).isLater( "y, m, d", new Text( "2016, 1, 23" )
  511. //! ); return true
  512. DLLEXPORT bool isLater(const char* format, Text* datum) const;
  513. };
  514. //! This class combines the Date and Clock classes and thus stores
  515. //! a timestamp with year, month, day, hour, minute and second
  516. class Time : public virtual ReferenceCounter
  517. {
  518. private:
  519. Date* datum;
  520. Clock* uhrzeit;
  521. public:
  522. //! Creates a new Time with the default values 0.0.0 0:0:0.
  523. DLLEXPORT Time();
  524. //! Creates a new Time with the elapsed seconds since 1970.
  525. DLLEXPORT Time(__int64 timestamp);
  526. //! Deletes the current object.
  527. DLLEXPORT ~Time();
  528. //! Changes the stored time by copying the values from (zeit).
  529. //! \param zeit The new time.
  530. DLLEXPORT void setTime(Time* zeit);
  531. //! Changes the stored time.
  532. //! \param jahr The new year.
  533. //! \param monat The new month.
  534. //! \param tag The new day.
  535. //! \param stunde The new hour.
  536. //! \param minute The new minute.
  537. //! \param sekunde The new second.
  538. DLLEXPORT void setTime(
  539. int jahr, int monat, int tag, int stunde, int minute, int sekunde);
  540. //! Changes the stored time.
  541. //! \param format A string specifying the format of the new
  542. //! time in (zeit). y=year, m=month, d=day, h=hour,
  543. //! i=minute, s=second. \param zeit A string containing the new
  544. //! time. Example: setTime( "y-m-d h:i:s", "2016-1-25 21:59:30" );
  545. DLLEXPORT void setTime(const char* format, const char* zeit);
  546. //! Changes the stored time.
  547. //! \param format A string specifying the format of the new
  548. //! time in (zeit). y=year, m=month, d=day, h=hour,
  549. //! i=minute, s=second. \param zeit A Text object containing the
  550. //! new time. Example: setTime( "y-m-d h:i:s", new Text(
  551. //! "2016-1-25 21:59:30" ) );
  552. DLLEXPORT void setTime(const char* format, Text* zeit);
  553. //! Changes the stored year.
  554. //! \param jahr The new year.
  555. DLLEXPORT void setJahr(int jahr);
  556. //! Changes the stored month.
  557. //! \param monat The new month.
  558. DLLEXPORT void setMonat(int monat);
  559. //! Changes the stored day.
  560. //! \param tag The new day.
  561. DLLEXPORT void setTag(int tag);
  562. //! Changes the stored hour.
  563. //! \param stunde The new hour.
  564. DLLEXPORT void setStunde(int stunde);
  565. //! Changes the stored minute.
  566. //! \param minute The new minute.
  567. DLLEXPORT void setMinute(int minute);
  568. //! Changes the stored second.
  569. //! \param sekunde The new second.
  570. DLLEXPORT void setSekunde(int sekunde);
  571. //! Adds the given time and stores the result.
  572. //! \param zeit The time to add.
  573. DLLEXPORT void plusTime(Time* zeit);
  574. //! Adds the given time and stores the result.
  575. //! \param jahr The year to add.
  576. //! \param monat The month to add.
  577. //! \param tag The day to add.
  578. //! \param stunde The hour to add.
  579. //! \param minute The minute to add.
  580. //! \param sekunde The second to add.
  581. DLLEXPORT void plusTime(
  582. int jahr, int monat, int tag, int stunde, int minute, int sekunde);
  583. //! Adds the given time and stores the result.
  584. //! \param format A string specifying the format of the
  585. //! time in (zeit). y=year, m=month, d=day, h=hour,
  586. //! i=minute, s=second. \param zeit A string containing the
  587. //! time to add.
  588. DLLEXPORT void plusTime(const char* format, const char* zeit);
  589. //! Adds the given time and stores the result.
  590. //! \param format A string specifying the format of the
  591. //! time in (zeit). y=year, m=month, d=day, h=hour,
  592. //! i=minute, s=second. \param zeit A Text object containing the
  593. //! time to add.
  594. DLLEXPORT void plusTime(const char* format, Text* zeit);
  595. //! Adds the given time and stores the result.
  596. //! \param jahr The year to add.
  597. DLLEXPORT void plusYear(int jahr);
  598. //! Adds the given time and stores the result.
  599. //! \param monat The month to add.
  600. DLLEXPORT void plusMonth(int monat);
  601. //! Adds the given time and stores the result.
  602. //! \param tag The day to add.
  603. DLLEXPORT void plusDay(int tag);
  604. //! Adds the given time and stores the result.
  605. //! \param stunde The hour to add.
  606. DLLEXPORT void plusHour(__int64 stunde);
  607. //! Adds the given time and stores the result.
  608. //! \param minute The minute to add.
  609. DLLEXPORT void plusMinute(__int64 minute);
  610. //! Adds the given time and stores the result.
  611. //! \param sekunde The second to add.
  612. DLLEXPORT void plusSecond(__int64 sekunde);
  613. //! Subtracts the given time and stores the result.
  614. //! \param zeit The time to subtract.
  615. DLLEXPORT void minusTime(Time* zeit);
  616. //! Subtracts the given time and stores the result.
  617. //! \param jahr The year to subtract.
  618. //! \param monat The month to subtract.
  619. //! \param tag The day to subtract.
  620. //! \param stunde The hour to subtract.
  621. //! \param minute The minute to subtract.
  622. //! \param sekunde The second to subtract.
  623. DLLEXPORT void minusTime(
  624. int jahr, int monat, int tag, int stunde, int minute, int sekunde);
  625. //! Subtracts the given time and stores the result.
  626. //! \param format A string specifying the format of the
  627. //! time in (zeit). y=year, m=month, d=day, h=hour,
  628. //! i=minute, s=second. \param zeit A string containing the
  629. //! time to subtract.
  630. DLLEXPORT void minusTime(const char* format, const char* zeit);
  631. //! Subtracts the given time and stores the result.
  632. //! \param format A string specifying the format of the
  633. //! time in (zeit). y=year, m=month, d=day, h=hour,
  634. //! i=minute, s=second. \param zeit A Text object containing the
  635. //! time to subtract.
  636. DLLEXPORT void minusTime(const char* format, Text* zeit);
  637. //! Subtracts the given time and stores the result.
  638. //! \param jahr The year to subtract.
  639. DLLEXPORT void minusYear(int jahr);
  640. //! Subtracts the given time and stores the result.
  641. //! \param monat The month to subtract.
  642. DLLEXPORT void minusMonth(int monat);
  643. //! Subtracts the given time and stores the result.
  644. //! \param tag The day to subtract.
  645. DLLEXPORT void minusDay(int tag);
  646. //! Subtracts the given time and stores the result.
  647. //! \param stunde The hour to subtract.
  648. DLLEXPORT void minusHour(__int64 stunde);
  649. //! Subtracts the given time and stores the result.
  650. //! \param minute The minute to subtract.
  651. DLLEXPORT void minusMinute(__int64 minute);
  652. //! Subtracts the given time and stores the result.
  653. //! \param sekunde The second to subtract.
  654. DLLEXPORT void minusSecond(__int64 sekunde);
  655. //! Returns the stored time as text.
  656. //! \param format A string specifying the format of the
  657. //! returned time. y=year, m=month, d=day, h=hour,
  658. //! i=minute, s=second.
  659. DLLEXPORT Text* getTime(const char* format) const;
  660. //! Checks if the time equals the given time.
  661. //! \param zeit The time to check.
  662. //! \return (true) if the times are equal. (false) otherwise.
  663. DLLEXPORT bool isEqual(Time* zeit) const;
  664. //! Checks if the time equals the given time.
  665. //! \param format A string specifying the format of the
  666. //! time in (zeit). y=year, m=month, d=day, h=hour,
  667. //! i=minute, s=second. \param zeit A string containing the
  668. //! time to check. \return (true) if the times are equal.
  669. //! (false) otherwise.
  670. DLLEXPORT bool isEqual(const char* format, const char* zeit) const;
  671. //! Checks if the time equals the given time.
  672. //! \param format A string specifying the format of the
  673. //! time in (zeit). y=year, m=month, d=day, h=hour,
  674. //! i=minute, s=second. \param zeit A Text object containing the
  675. //! time to check. \return (true) if the times are equal.
  676. //! (false) otherwise.
  677. DLLEXPORT bool isEqual(const char* format, Text* zeit) const;
  678. //! Checks if the time equals the given time.
  679. //! \param jahr The year to check.
  680. //! \param monat The month to check.
  681. //! \param tag The day to check.
  682. //! \param stunde The hour to check.
  683. //! \param minute The minute to check.
  684. //! \param sekunde The second to check.
  685. //! \return (true) if the times are equal. (false) otherwise.
  686. DLLEXPORT bool isEqual(int jahr,
  687. int monat,
  688. int tag,
  689. int stunde,
  690. int minute,
  691. int sekunde) const;
  692. //! Returns the object storing the date with increased reference
  693. //! counter.
  694. DLLEXPORT Date* getDate() const;
  695. //! Returns the object storing the date without increased reference
  696. //! counter.
  697. DLLEXPORT Date* zDate() const;
  698. //! Returns the object storing the time of day with increased reference
  699. //! counter.
  700. DLLEXPORT Clock* getClock() const;
  701. //! Returns the object storing the time of day without increased
  702. //! reference counter.
  703. DLLEXPORT Clock* zClock() const;
  704. //! Checks if the stored time is less than the given time.
  705. //! \param zeit The time to check. \return (true)
  706. //! if the stored time is before the given time. (false)
  707. //! otherwise.
  708. DLLEXPORT bool isSmaller(Time* zeit) const;
  709. //! Checks if the stored time is less than the given time.
  710. //! \param jahr The year to check. \param monat The
  711. //! month to check. \param tag The day to check.
  712. //! \param stunde The hour to check. \param minute The
  713. //! minute to check. \param sekunde The second to check.
  714. //! \return (true) if the stored time is before the given time.
  715. //! (false) otherwise.
  716. DLLEXPORT bool isSmaller(int jahr,
  717. int monat,
  718. int tag,
  719. int stunde,
  720. int minute,
  721. int sekunde) const;
  722. //! Checks if the stored time is less than the given time.
  723. //! \param format A string specifying the format of the
  724. //! time in (zeit). y=year, m=month, d=day, h=hour,
  725. //! i=minute, s=second. \param zeit A string containing the
  726. //! time to check. \return (true) if the stored time is before
  727. //! the given time. (false) otherwise.
  728. DLLEXPORT bool isSmaller(const char* format, const char* zeit) const;
  729. //! Checks if the stored time is less than the given time.
  730. //! \param format A string specifying the format of the
  731. //! time in (zeit). y=year, m=month, d=day, h=hour,
  732. //! i=minute, s=second. \param zeit A Text object containing the
  733. //! time to check. \return (true) if the stored time is before
  734. //! the given time. (false) otherwise.
  735. DLLEXPORT bool isSmaller(const char* format, Text* zeit) const;
  736. //! Checks if the stored time is greater than the given time.
  737. //! \param zeit The time to check. \return (true)
  738. //! if the stored time is after the given time. (false)
  739. //! otherwise.
  740. DLLEXPORT bool isLater(Time* zeit) const;
  741. //! Checks if the stored time is greater than the given time.
  742. //! \param jahr The year to check. \param monat The
  743. //! month to check. \param tag The day to check.
  744. //! \param stunde The hour to check. \param minute The
  745. //! minute to check. \param sekunde The second to check.
  746. //! \return (true) if the stored time is after the given time.
  747. //! (false) otherwise.
  748. DLLEXPORT bool isLater(int jahr,
  749. int monat,
  750. int tag,
  751. int stunde,
  752. int minute,
  753. int sekunde) const;
  754. //! Checks if the stored time is greater than the given time.
  755. //! \param format A string specifying the format of the
  756. //! time in (zeit). y=year, m=month, d=day, h=hour,
  757. //! i=minute, s=second. \param zeit A string containing the
  758. //! time to check. \return (true) if the stored time is after
  759. //! the given time. (false) otherwise.
  760. DLLEXPORT bool isLater(const char* format, const char* zeit) const;
  761. //! Checks if the stored time is greater than the given time.
  762. //! \param format A string specifying the format of the
  763. //! time in (zeit). y=year, m=month, d=day, h=hour,
  764. //! i=minute, s=second. \param zeit A Text object containing the
  765. //! time to check. \return (true) if the stored time is after
  766. //! the given time. (false) otherwise.
  767. DLLEXPORT bool isLater(const char* format, Text* zeit) const;
  768. };
  769. //! Diese Class kann messen, wie viel Time zwischen zwei TimePoints
  770. //! verstrichen ist
  771. class Timer : public virtual ReferenceCounter
  772. {
  773. private:
  774. double start;
  775. double ende;
  776. double messung;
  777. public:
  778. //! Creates a new Timer object
  779. DLLEXPORT Timer();
  780. //! Deletes the current object
  781. DLLEXPORT ~Timer();
  782. //! Sets the start point of the time measurement
  783. DLLEXPORT void measureStart();
  784. //! Sets the end point of the time measurement
  785. DLLEXPORT void measureEnd();
  786. //! Returns the interval between start and end of the measurement
  787. //! in seconds
  788. DLLEXPORT double getSekunden() const;
  789. //! Returns the interval between start and end of the measurement
  790. //! in minutes
  791. DLLEXPORT double getMinuten() const;
  792. //! Returns the interval between start and end of the measurement
  793. //! in hours
  794. DLLEXPORT double getStunden() const;
  795. //! Returns true if a measurement is currently running
  796. DLLEXPORT bool isMeasuring() const;
  797. };
  798. //! Returns the current time of day.
  799. DLLEXPORT Clock* getClock();
  800. //! Returns the current date.
  801. DLLEXPORT Date* getDate();
  802. //! Returns the current time (date and time of day).
  803. DLLEXPORT Time* getTime();
  804. //! Checks whether jahr is a leap year.
  805. //! \param jahr The year to check.
  806. //! \return (true) if the given year is a leap year. (false) otherwise.
  807. DLLEXPORT bool isLeapYear(int jahr);
  808. } // namespace Framework
  809. #endif