32 #include <boost/date_time/c_local_time_adjustor.hpp>
33 #include <boost/date_time/local_time_adjustor.hpp>
36 namespace fs = boost::filesystem;
52 if (fs::is_directory(p)) {
53 boost::system::error_code ec;
54 fs::directory_iterator(p, ec);
57 else if(fs::is_regular_file(p)) {
58 ifstream ifs(p.string().c_str(), ifstream::in);
69 boost::system::error_code ec;
70 const bool eq = p == fs::canonical(p, ec);
75 string lpad(
const string & s,
size_t mida,
char f) {
76 const size_t L = s.length();
77 const size_t c = (L <
mida) ? (mida-L) : 0;
78 return string(c, f) + s;
81 string rpad(
const string & s,
size_t mida,
char f) {
82 const size_t L = s.length();
83 const size_t c = (L <
mida) ? (mida-L) : 0;
84 return s + string(c, f);
87 string formata_data(
const boost::posix_time::ptime & pt,
const string & fmt) {
88 using namespace boost::gregorian;
89 using namespace boost::posix_time;
91 time_facet * df =
new time_facet();
92 ss.imbue(std::locale(std::locale::classic(), df));
93 df->format(fmt.c_str());
99 return formata_data(boost::posix_time::from_time_t(pt), fmt);
102 boost::posix_time::ptime
llegeix_data(
const string & s,
const string & fmt) {
104 using namespace boost::posix_time;
105 istringstream iss(s);
106 time_input_facet * tif =
new time_input_facet(fmt.c_str());
107 iss.imbue(std::locale(std::locale::classic(), tif));
108 boost::posix_time::ptime pt;