• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 //  Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
3 //
4 //  Distributed under the Boost Software License, Version 1.0. (See
5 //  accompanying file LICENSE_1_0.txt or copy at
6 //  http://www.boost.org/LICENSE_1_0.txt)
7 //
8 
9 #ifndef BOOST_LOCALE_WITH_ICU
10 #include <iostream>
main()11 int main()
12 {
13         std::cout << "ICU is not build... Skipping" << std::endl;
14 }
15 #else
16 
17 #ifdef _MSC_VER
18 #define _CRT_SECURE_NO_WARNINGS
19 // Disable this "security crap"
20 #endif
21 
22 #include <boost/locale/formatting.hpp>
23 #include <boost/locale/format.hpp>
24 #include <boost/locale/generator.hpp>
25 #include "test_locale.hpp"
26 #include "test_locale_tools.hpp"
27 #include <sstream>
28 #include <iostream>
29 #include <iomanip>
30 
31 #include <time.h>
32 
main()33 int main()
34 {
35     try {
36 
37         time_t now=time(0);
38         boost::locale::generator gen;
39         std::locale::global(gen("en_US.UTF-8"));
40 
41         for(int i=0;i<366;i++) {
42             time_t point = now + i * 24 * 3600;
43             std::stringstream ss;
44             ss << boost::locale::format("{1,ftime='%H %M %S'}") % point;
45             int icu_hour = 0,icu_min = 0,icu_sec = 0;
46             ss >> icu_hour >> icu_min >> icu_sec;
47             std::tm *tm=localtime(&point);
48             TEST(icu_hour == tm->tm_hour);
49             TEST(icu_min == tm->tm_min);
50             TEST(icu_sec == tm->tm_sec);
51 
52         }
53     }
54     catch(std::exception const &e) {
55         std::cerr << "Failed " << e.what() << std::endl;
56         return EXIT_FAILURE;
57     }
58     FINALIZE();
59 
60 }
61 
62 #endif // NO ICU
63 
64 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
65 // boostinspect:noascii
66