calc_rules.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* A simple example for creating various dst_calc_rule instances
  2. */
  3. #include "boost/date_time/gregorian/gregorian.hpp"
  4. #include "boost/date_time/local_time/local_time.hpp"
  5. #include <iostream>
  6. int
  7. main()
  8. {
  9. using namespace boost;
  10. using namespace local_time;
  11. using namespace gregorian;
  12. /***** create the necessary date_generator objects *****/
  13. // starting generators
  14. first_day_of_the_week_in_month fd_start(Sunday, May);
  15. last_day_of_the_week_in_month ld_start(Sunday, May);
  16. nth_day_of_the_week_in_month nkd_start(nth_day_of_the_week_in_month::third,
  17. Sunday, May);
  18. partial_date pd_start(1, May);
  19. // ending generators
  20. first_day_of_the_week_in_month fd_end(Sunday, Oct);
  21. last_day_of_the_week_in_month ld_end(Sunday, Oct);
  22. nth_day_of_the_week_in_month nkd_end(nth_day_of_the_week_in_month::third,
  23. Sunday, Oct);
  24. partial_date pd_end(31, Oct);
  25. /***** create the various dst_calc_rule objects *****/
  26. dst_calc_rule_ptr pdr(new partial_date_dst_rule(pd_start, pd_end));
  27. dst_calc_rule_ptr flr(new first_last_dst_rule(fd_start, ld_end));
  28. dst_calc_rule_ptr llr(new last_last_dst_rule(ld_start, ld_end));
  29. dst_calc_rule_ptr nlr(new nth_last_dst_rule(nkd_start, ld_end));
  30. dst_calc_rule_ptr ndr(new nth_day_of_the_week_in_month_dst_rule(nkd_start, nkd_end));
  31. std::cout << "Program run successfully" << std::endl;
  32. return 0;
  33. }
  34. /* Copyright 2001-2005: CrystalClear Software, Inc
  35. * http://www.crystalclearsoftware.com
  36. *
  37. * Subject to the Boost Software License, Version 1.0.
  38. * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  39. */