time_zone_names.hpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef DATE_TIME_TIME_ZONE_NAMES_HPP__
  2. #define DATE_TIME_TIME_ZONE_NAMES_HPP__
  3. /* Copyright (c) 2002-2003,2005 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
  8. * $Date$
  9. */
  10. #include <string>
  11. namespace boost {
  12. namespace date_time {
  13. template<class CharT>
  14. struct default_zone_names {
  15. public:
  16. typedef CharT char_type;
  17. static const char_type standard_name[9];
  18. static const char_type standard_abbrev[11];
  19. static const char_type non_dst_identifier[7];
  20. };
  21. template <class CharT>
  22. const typename default_zone_names<CharT>::char_type
  23. default_zone_names<CharT>::standard_name[9] =
  24. {'s','t','d','_','n','a','m','e'};
  25. template <class CharT>
  26. const typename default_zone_names<CharT>::char_type
  27. default_zone_names<CharT>::standard_abbrev[11] =
  28. {'s','t','d','_','a','b','b','r','e','v'};
  29. template <class CharT>
  30. const typename default_zone_names<CharT>::char_type
  31. default_zone_names<CharT>::non_dst_identifier[7] =
  32. {'n','o','-','d','s','t'};
  33. //! Base type that holds various string names for timezone output.
  34. /*! Class that holds various types of strings used for timezones.
  35. * For example, for the western United States there is the full
  36. * name: Pacific Standard Time and the abbreviated name: PST.
  37. * During daylight savings there are additional names:
  38. * Pacific Daylight Time and PDT.
  39. *@tparam CharT Allows class to support different character types
  40. */
  41. template<class CharT>
  42. class time_zone_names_base
  43. {
  44. public:
  45. typedef std::basic_string<CharT> string_type;
  46. time_zone_names_base() :
  47. std_zone_name_(default_zone_names<CharT>::standard_name),
  48. std_zone_abbrev_(default_zone_names<CharT>::standard_abbrev),
  49. dst_zone_name_(default_zone_names<CharT>::non_dst_identifier),
  50. dst_zone_abbrev_(default_zone_names<CharT>::non_dst_identifier)
  51. {}
  52. time_zone_names_base(const string_type& std_zone_name_str,
  53. const string_type& std_zone_abbrev_str,
  54. const string_type& dst_zone_name_str,
  55. const string_type& dst_zone_abbrev_str) :
  56. std_zone_name_(std_zone_name_str),
  57. std_zone_abbrev_(std_zone_abbrev_str),
  58. dst_zone_name_(dst_zone_name_str),
  59. dst_zone_abbrev_(dst_zone_abbrev_str)
  60. {}
  61. string_type dst_zone_abbrev() const
  62. {
  63. return dst_zone_abbrev_;
  64. }
  65. string_type std_zone_abbrev() const
  66. {
  67. return std_zone_abbrev_;
  68. }
  69. string_type dst_zone_name() const
  70. {
  71. return dst_zone_name_;
  72. }
  73. string_type std_zone_name() const
  74. {
  75. return std_zone_name_;
  76. }
  77. private:
  78. string_type std_zone_name_;
  79. string_type std_zone_abbrev_;
  80. string_type dst_zone_name_;
  81. string_type dst_zone_abbrev_;
  82. };
  83. //! Specialization of timezone names for standard char.
  84. //typedef time_zone_names_base<char> time_zone_names;
  85. } } //namespace
  86. #endif