BVB Source Codes

mars Show formatters_limited.hpp Source code

Return Download mars: download formatters_limited.hpp Source code - Download mars Source code - Type:.hpp
  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.  
  18. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  19. namespace 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.  
  82.  
downloadformatters_limited.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top