Skip to content

Instantly share code, notes, and snippets.

@lnrsoft
Created July 2, 2014 22:47
Show Gist options
  • Save lnrsoft/413a018f1b671c79001b to your computer and use it in GitHub Desktop.
Save lnrsoft/413a018f1b671c79001b to your computer and use it in GitHub Desktop.
Testing your Boost C++ libraries installation. Running the sample code that using the date_time Boost C++ library.
// This source code written by Roland Ihasz
#include <iostream>
#include "boost/date_time/gregorian/gregorian.hpp"
using namespace std;
int main()
{
using namespace boost::gregorian;
date today = day_clock::local_day();
partial_date new_years_day(1,Jan);
days days_since_year_start = today - new_years_day.get_date(today.year());
cout << "Today's date: " << today << endl;
cout << "Days since Jan 1 (" << today.year() << ") : "<< days_since_year_start.days() << endl;
days days_until_year_start = new_years_day.get_date(today.year()+1) - today;
cout << "Days until next Jan 1 (" << today.year()+1 << ") : " << days_until_year_start.days() << endl;
return 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment