]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/date_time/include/boost/date_time/gregorian/formatters_limited.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / date_time / include / boost / date_time / gregorian / formatters_limited.hpp
CommitLineData
7c673cae
FG
1#ifndef GREGORIAN_FORMATTERS_LIMITED_HPP___
2#define GREGORIAN_FORMATTERS_LIMITED_HPP___
3
4/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
5 * Use, modification and distribution is subject to the
6 * Boost Software License, Version 1.0. (See accompanying
7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
8 * Author: Jeff Garland, Bart Garst
9 * $Date$
10 */
11
12#include "boost/date_time/gregorian/gregorian_types.hpp"
13#include "boost/date_time/date_formatting_limited.hpp"
14#include "boost/date_time/iso_format.hpp"
15#include "boost/date_time/date_format_simple.hpp"
16#include "boost/date_time/compiler_config.hpp"
17
18namespace boost {
19namespace gregorian {
20
21 //! To YYYY-mmm-DD string where mmm 3 char month name. Example: 2002-Jan-01
22 /*!\ingroup date_format
23 */
24 inline std::string to_simple_string(const date& d) {
25 return date_time::date_formatter<date,date_time::simple_format<char> >::date_to_string(d);
26 }
27
28 //! Convert date period to simple string. Example: [2002-Jan-01/2002-Jan-02]
29 /*!\ingroup date_format
30 */
31 inline std::string to_simple_string(const date_period& d) {
32 std::string s("[");
33 std::string d1(date_time::date_formatter<date,date_time::simple_format<char> >::date_to_string(d.begin()));
34 std::string d2(date_time::date_formatter<date,date_time::simple_format<char> >::date_to_string(d.last()));
35 return std::string("[" + d1 + "/" + d2 + "]");
36 }
37
38 //! Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
39 /*!\ingroup date_format
40 */
41 inline std::string to_iso_string(const date_period& d) {
42 std::string s(date_time::date_formatter<date,date_time::iso_format<char> >::date_to_string(d.begin()));
43 return s + "/" + date_time::date_formatter<date,date_time::iso_format<char> >::date_to_string(d.last());
44 }
45
46
47 //! Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31
48 /*!\ingroup date_format
49 */
50 inline std::string to_iso_extended_string(const date& d) {
51 return date_time::date_formatter<date,date_time::iso_extended_format<char> >::date_to_string(d);
52 }
53
54 //! Convert to iso standard string YYYYMMDD. Example: 20021231
55 /*!\ingroup date_format
56 */
57 inline std::string to_iso_string(const date& d) {
58 return date_time::date_formatter<date,date_time::iso_format<char> >::date_to_string(d);
59 }
60
61
62
63 inline std::string to_sql_string(const date& d)
64 {
65 date::ymd_type ymd = d.year_month_day();
66 std::ostringstream ss;
67 ss << ymd.year << "-"
68 << std::setw(2) << std::setfill('0')
69 << ymd.month.as_number() //solves problem with gcc 3.1 hanging
70 << "-"
71 << std::setw(2) << std::setfill('0')
72 << ymd.day;
73 return ss.str();
74 }
75
76
77} } //namespace gregorian
78
79
80#endif
81