]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/date_time/test/local_time/testdst_transition_day_rule.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / date_time / test / local_time / testdst_transition_day_rule.cpp
1 /* Copyright (c) 2003-2004 CrystalClear Software, Inc.
2 * Subject to the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
4 * Author: Jeff Garland, Bart Garst
5 * $Date$
6 */
7
8 #include "boost/date_time/gregorian/gregorian.hpp"
9 #include "boost/date_time/local_time/dst_transition_day_rules.hpp"
10 #include "boost/shared_ptr.hpp"
11 #include "../testfrmwk.hpp"
12
13
14
15 // see http://www.timeanddate.com/time/aboutdst.html for some info
16 // also
17 int
18 main()
19 {
20 // using namespace boost::posix_time;
21 using namespace boost::local_time;
22 using namespace boost::gregorian;
23
24 boost::shared_ptr<dst_calc_rule>
25 rule1(new partial_date_dst_rule(partial_date(30,Apr),
26 partial_date(30,Oct)));
27
28 check("partial date rule", rule1->start_day(2001) == date(2001, Apr, 30));
29 check("partial date rule", rule1->end_day(2001) == date(2001, Oct, 30));
30
31 boost::shared_ptr<dst_calc_rule>
32 rule2(new first_last_dst_rule(first_last_dst_rule::start_rule(Sunday,Apr),
33 first_last_dst_rule::end_rule(Sunday,Oct)));
34
35 check("first last rule", rule2->start_day(2001) == date(2001, Apr, 1));
36 check("first last rule", rule2->end_day(2001) == date(2001, Oct, 28));
37
38 boost::shared_ptr<dst_calc_rule>
39 rule3(new last_last_dst_rule(last_last_dst_rule::start_rule(Sunday,Mar),
40 last_last_dst_rule::end_rule(Sunday,Oct)));
41
42 check("last last rule", rule3->start_day(2001) == date(2001, Mar, 25));
43 check("last last rule", rule3->end_day(2001) == date(2001, Oct, 28));
44
45 typedef nth_kday_of_month nkday;
46 boost::shared_ptr<dst_calc_rule>
47 rule4(new nth_last_dst_rule(nth_last_dst_rule::start_rule(nkday::first,Sunday,Mar),
48 nth_last_dst_rule::end_rule(Sunday,Oct)));
49
50 check("nth Last rule", rule4->start_day(2001) == date(2001, Mar, 4));
51 check("nth Last rule", rule4->end_day(2001) == date(2001, Oct, 28));
52
53 boost::shared_ptr<dst_calc_rule>
54 rule5(new nth_kday_dst_rule(nth_kday_dst_rule::start_rule(nkday::first,Sunday,Mar),
55 nth_kday_dst_rule::end_rule(nkday::fourth,Sunday,Oct)));
56
57 check("nth_kday rule", rule5->start_day(2001) == date(2001, Mar, 4));
58 check("nth_kday rule", rule5->end_day(2001) == date(2001, Oct, 28));
59
60
61
62 return printTestStats();
63
64 }
65