diff options
author | Pino Toscano <pino@kde.org> | 2010-05-28 14:34:37 +0200 |
---|---|---|
committer | Pino Toscano <pino@kde.org> | 2010-05-28 14:34:37 +0200 |
commit | 2ff840b62e41e2fc98e9fcff7330f40216de58a5 (patch) | |
tree | e71827f171cf7960d04cb81b3cefa43c19392079 /cpp/poppler-private.cpp | |
parent | 8112e9111313eaded4cd2e89d0e67efb0f3e29db (diff) |
[cpp] move the actual convert_date(const char*) implementation in the detail
this way it is possible to call it from inside poppler-cpp without an implicit conversion to std::string
Diffstat (limited to 'cpp/poppler-private.cpp')
-rw-r--r-- | cpp/poppler-private.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cpp/poppler-private.cpp b/cpp/poppler-private.cpp index 51d557cb..5b63786d 100644 --- a/cpp/poppler-private.cpp +++ b/cpp/poppler-private.cpp @@ -18,9 +18,11 @@ #include "poppler-private.h" +#include "DateInfo.h" #include "GooString.h" #include "Page.h" +#include <ctime> #include <iostream> #include <sstream> @@ -105,3 +107,26 @@ GooString* detail::ustring_to_unicode_GooString(const ustring &str) GooString *goo = new GooString(&ba[0]); return goo; } + +time_type detail::convert_date(const char *date) +{ + int year, mon, day, hour, min, sec, tzHours, tzMins; + char tz; + + if (!parseDateString(date, &year, &mon, &day, &hour, &min, &sec, + &tz, &tzHours, &tzMins)) { + return time_type(-1); + } + + struct tm time; + time.tm_sec = sec; + time.tm_min = min; + time.tm_hour = hour; + time.tm_mday = day; + time.tm_mon = mon - 1; + time.tm_year = year - 1900; + time.tm_wday = -1; + time.tm_yday = -1; + time.tm_isdst = -1; + return mktime(&time); +} |