File: testclocks.cpp

package info (click to toggle)
boost1.35 1.35.0-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 203,856 kB
  • ctags: 337,867
  • sloc: cpp: 938,683; xml: 56,847; ansic: 41,589; python: 18,999; sh: 11,566; makefile: 664; perl: 494; yacc: 456; asm: 353; csh: 6
file content (40 lines) | stat: -rw-r--r-- 1,415 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Copyright (c) 2003-2004 CrystalClear Software, Inc.
 * Subject to the Boost Software License, Version 1.0. 
 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
 * Author: Jeff Garland, Bart Garst
 * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
 */

#include "boost/date_time/local_time/local_time.hpp"
#include <iostream>

// The actual clocks are tested in posix_time/testclock.cpp. 
// These tests are to verify that the time zone is applied correctly

int
main()
{
  using namespace boost::gregorian;
  using namespace boost::posix_time;
  using namespace boost::local_time;


  boost::shared_ptr<time_zone> az_tz(new posix_time_zone("MST-07"));
  boost::shared_ptr<time_zone> ny_tz(new posix_time_zone("EST-05EDT,M4.1.0,M10.5.0"));

  ptime tl = second_clock::local_time();
  std::cout << to_simple_string(tl) << std::endl;
  local_date_time ldt1 = local_sec_clock::local_time(az_tz);
  std::cout << ldt1.to_string() << std::endl;
  local_date_time ldt2 = local_sec_clock::local_time(ny_tz);
  std::cout << ldt2.to_string() << std::endl;
  
  tl = microsec_clock::local_time();
  std::cout << to_simple_string(tl) << std::endl;
  local_date_time ldt3 = local_microsec_clock::local_time(az_tz);
  std::cout << ldt3.to_string() << std::endl;
  local_date_time ldt4 = local_microsec_clock::local_time(ny_tz);
  std::cout << ldt4.to_string() << std::endl;

   return 0;
}