File indexing completed on 2025-01-18 09:30:34
0001 #ifndef GREGORIAN_FORMATTERS_LIMITED_HPP___
0002 #define GREGORIAN_FORMATTERS_LIMITED_HPP___
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "boost/date_time/gregorian/gregorian_types.hpp"
0013 #include "boost/date_time/date_formatting_limited.hpp"
0014 #include "boost/date_time/iso_format.hpp"
0015 #include "boost/date_time/date_format_simple.hpp"
0016 #include "boost/date_time/compiler_config.hpp"
0017
0018 namespace boost {
0019 namespace gregorian {
0020
0021
0022
0023
0024 inline std::string to_simple_string(const date& d) {
0025 return date_time::date_formatter<date,date_time::simple_format<char> >::date_to_string(d);
0026 }
0027
0028
0029
0030
0031 inline std::string to_simple_string(const date_period& d) {
0032 std::string s("[");
0033 std::string d1(date_time::date_formatter<date,date_time::simple_format<char> >::date_to_string(d.begin()));
0034 std::string d2(date_time::date_formatter<date,date_time::simple_format<char> >::date_to_string(d.last()));
0035 return std::string("[" + d1 + "/" + d2 + "]");
0036 }
0037
0038
0039
0040
0041 inline std::string to_iso_string(const date_period& d) {
0042 std::string s(date_time::date_formatter<date,date_time::iso_format<char> >::date_to_string(d.begin()));
0043 return s + "/" + date_time::date_formatter<date,date_time::iso_format<char> >::date_to_string(d.last());
0044 }
0045
0046
0047
0048
0049
0050 inline std::string to_iso_extended_string(const date& d) {
0051 return date_time::date_formatter<date,date_time::iso_extended_format<char> >::date_to_string(d);
0052 }
0053
0054
0055
0056
0057 inline std::string to_iso_string(const date& d) {
0058 return date_time::date_formatter<date,date_time::iso_format<char> >::date_to_string(d);
0059 }
0060
0061
0062
0063 inline std::string to_sql_string(const date& d)
0064 {
0065 date::ymd_type ymd = d.year_month_day();
0066 std::ostringstream ss;
0067 ss << ymd.year << "-"
0068 << std::setw(2) << std::setfill('0')
0069 << ymd.month.as_number()
0070 << "-"
0071 << std::setw(2) << std::setfill('0')
0072 << ymd.day;
0073 return ss.str();
0074 }
0075
0076
0077 } }
0078
0079
0080 #endif
0081