conversion.hpp 863 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef DATE_TIME_LOCAL_TIME_CONVERSION_HPP__
  2. #define DATE_TIME_LOCAL_TIME_CONVERSION_HPP__
  3. /* Copyright (c) 2003-2004 CrystalClear Software, Inc.
  4. * Subject to the Boost Software License, Version 1.0.
  5. * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  6. * Author: Jeff Garland, Bart Garst
  7. * $Date$
  8. */
  9. #include "boost/date_time/posix_time/conversion.hpp"
  10. #include "boost/date_time/c_time.hpp"
  11. #include "boost/date_time/local_time/local_date_time.hpp"
  12. namespace boost {
  13. namespace local_time {
  14. //! Function that creates a tm struct from a local_date_time
  15. inline
  16. std::tm to_tm(const local_date_time& lt) {
  17. std::tm lt_tm = posix_time::to_tm(lt.local_time());
  18. if(lt.is_dst()){
  19. lt_tm.tm_isdst = 1;
  20. }
  21. else{
  22. lt_tm.tm_isdst = 0;
  23. }
  24. return lt_tm;
  25. }
  26. }} // namespaces
  27. #endif // DATE_TIME_LOCAL_TIME_CONVERSION_HPP__