date_time.h.xml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <chapter xml:id="date_time.h">
  2. <title><tt>__vic/date_time.h</tt></title>
  3. <p>Date and time utilies.</p>
  4. <chapter xml:id="is_leap_year">
  5. <title><tt>is_leap_year()</tt></title>
  6. <code-block lang="C++">
  7. constexpr bool is_leap_year(int year);
  8. </code-block>
  9. <p>Determines if the year is a leap year according to Gregorian calendar.</p>
  10. </chapter>
  11. <chapter xml:id="days_in_month">
  12. <title><tt>days_in_month()</tt></title>
  13. <code-block lang="C++">
  14. int days_in_month(int month, int year);
  15. </code-block>
  16. <p>Returns number of days in the month. Month is a number from 1 to 12.
  17. The second parameter is used only if the month is 2 (february), otherwise
  18. is just ignored.</p>
  19. </chapter>
  20. <chapter xml:id="days_between_years">
  21. <title><tt>days_between_years()</tt></title>
  22. <code-block lang="C++">
  23. long days_between_years(unsigned year1, unsigned year2);
  24. </code-block>
  25. <p>Returns the difference in days between the beginning of the 2nd year and
  26. the beginning of the 1st year.</p>
  27. </chapter>
  28. <chapter xml:id="invalid_date">
  29. <title><tt>invalid_date</tt></title>
  30. <code-block lang="C++">
  31. class invalid_date; // : public std::exception
  32. </code-block>
  33. <p>The exception thrown when the value of the date or time element is
  34. invalid.</p>
  35. </chapter>
  36. <chapter xml:id="validate_date_time">
  37. <title><tt>validate_date()</tt>, <tt>validate_time()</tt>,
  38. <tt>validate_date_time()</tt></title>
  39. <code-block lang="C++">
  40. void validate_date(int yy, int mm, int dd);
  41. void validate_time(int hh, int mi, int ss);
  42. void validate_date_time(int yy, int mm, int dd, int hh, int mi, int ss);
  43. </code-block>
  44. <p>Checks if the date/time value is valid. Following constraints are checked:
  45. </p>
  46. <list style="bulleted">
  47. <item><tt>yy</tt> (year) - cannot be <tt>0</tt>,</item>
  48. <item><tt>mm</tt> (month) - <tt>1..12</tt>,</item>
  49. <item><tt>dd</tt> (day of the month) - <tt>1..{28..31}</tt>, depending
  50. on the month,</item>
  51. <item><tt>hh</tt> (hour) - <tt>0..23</tt>,</item>
  52. <item><tt>mi</tt> (minute) - <tt>0..59</tt>,</item>
  53. <item><tt>ss</tt> (second) - <tt>0..59</tt>.</item>
  54. </list>
  55. <p><tt>invalid_date</tt> is thrown in case of the constraint violation.</p>
  56. <note>Specific time values as <tt>24:00:00</tt> (midnight at the end of a
  57. day) or <tt>59:60</tt> (leap second) are considered as invalid!</note>
  58. </chapter>
  59. </chapter>