date_format_simple.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #ifndef DATE_TIME_SIMPLE_FORMAT_HPP___
  2. #define DATE_TIME_SIMPLE_FORMAT_HPP___
  3. /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
  4. * Use, modification and distribution is subject to the
  5. * Boost Software License, Version 1.0. (See accompanying
  6. * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  7. * Author: Jeff Garland, Bart Garst
  8. * $Date$
  9. */
  10. #include "boost/date_time/parse_format_base.hpp"
  11. namespace boost {
  12. namespace date_time {
  13. //! Class to provide simple basic formatting rules
  14. template<class charT>
  15. class simple_format {
  16. public:
  17. //! String used printed is date is invalid
  18. static const charT* not_a_date()
  19. {
  20. return "not-a-date-time";
  21. }
  22. //! String used to for positive infinity value
  23. static const charT* pos_infinity()
  24. {
  25. return "+infinity";
  26. }
  27. //! String used to for positive infinity value
  28. static const charT* neg_infinity()
  29. {
  30. return "-infinity";
  31. }
  32. //! Describe month format
  33. static month_format_spec month_format()
  34. {
  35. return month_as_short_string;
  36. }
  37. static ymd_order_spec date_order()
  38. {
  39. return ymd_order_iso; //YYYY-MM-DD
  40. }
  41. //! This format uses '-' to separate date elements
  42. static bool has_date_sep_chars()
  43. {
  44. return true;
  45. }
  46. //! Char to sep?
  47. static charT year_sep_char()
  48. {
  49. return '-';
  50. }
  51. //! char between year-month
  52. static charT month_sep_char()
  53. {
  54. return '-';
  55. }
  56. //! Char to separate month-day
  57. static charT day_sep_char()
  58. {
  59. return '-';
  60. }
  61. //! char between date-hours
  62. static charT hour_sep_char()
  63. {
  64. return ' ';
  65. }
  66. //! char between hour and minute
  67. static charT minute_sep_char()
  68. {
  69. return ':';
  70. }
  71. //! char for second
  72. static charT second_sep_char()
  73. {
  74. return ':';
  75. }
  76. };
  77. #ifndef BOOST_NO_STD_WSTRING
  78. //! Specialization of formmating rules for wchar_t
  79. template<>
  80. class simple_format<wchar_t> {
  81. public:
  82. //! String used printed is date is invalid
  83. static const wchar_t* not_a_date()
  84. {
  85. return L"not-a-date-time";
  86. }
  87. //! String used to for positive infinity value
  88. static const wchar_t* pos_infinity()
  89. {
  90. return L"+infinity";
  91. }
  92. //! String used to for positive infinity value
  93. static const wchar_t* neg_infinity()
  94. {
  95. return L"-infinity";
  96. }
  97. //! Describe month format
  98. static month_format_spec month_format()
  99. {
  100. return month_as_short_string;
  101. }
  102. static ymd_order_spec date_order()
  103. {
  104. return ymd_order_iso; //YYYY-MM-DD
  105. }
  106. //! This format uses '-' to separate date elements
  107. static bool has_date_sep_chars()
  108. {
  109. return true;
  110. }
  111. //! Char to sep?
  112. static wchar_t year_sep_char()
  113. {
  114. return '-';
  115. }
  116. //! char between year-month
  117. static wchar_t month_sep_char()
  118. {
  119. return '-';
  120. }
  121. //! Char to separate month-day
  122. static wchar_t day_sep_char()
  123. {
  124. return '-';
  125. }
  126. //! char between date-hours
  127. static wchar_t hour_sep_char()
  128. {
  129. return ' ';
  130. }
  131. //! char between hour and minute
  132. static wchar_t minute_sep_char()
  133. {
  134. return ':';
  135. }
  136. //! char for second
  137. static wchar_t second_sep_char()
  138. {
  139. return ':';
  140. }
  141. };
  142. #endif // BOOST_NO_STD_WSTRING
  143. } } //namespace date_time
  144. #endif