diff options
author | Dieter Hametner <dh (plus) vdr (at) gekrumbel (dot) de> | 2008-01-16 20:58:14 +0100 |
---|---|---|
committer | Dieter Hametner <dh (plus) vdr (at) gekrumbel (dot) de> | 2008-01-16 20:58:14 +0100 |
commit | 53920ac400a4a062eb90bb1656140e03e19ecd3d (patch) | |
tree | c79e978737a52041c6812a872f7f827b2e57d0fe /tools.cpp | |
parent | 6601d4c8cfe062f61196ef6f4e2ade0156c3345c (diff) | |
parent | 99b67b42f6844701667fe01b5d781d03ce299d59 (diff) | |
download | vdr-plugin-live-53920ac400a4a062eb90bb1656140e03e19ecd3d.tar.gz vdr-plugin-live-53920ac400a4a062eb90bb1656140e03e19ecd3d.tar.bz2 |
Merge commit 'winni/master'
Diffstat (limited to 'tools.cpp')
-rw-r--r-- | tools.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -242,4 +242,33 @@ string GetXMLValue( std::string const& xml, std::string const& element ) return xml.substr(startPos + start.size(), endPos - startPos - start.size()); } +// return the time value as time_t from <datestring> formatted with <format> +time_t GetDateFromDatePicker(std::string const& datestring, std::string const& format) +{ + if (datestring.empty()) + return 0; + int year = lexical_cast< int >(datestring.substr(format.find("yyyy"), 4)); + int month = lexical_cast< int >(datestring.substr(format.find("mm"), 2)); + int day = lexical_cast< int >(datestring.substr(format.find("dd"), 2)); + struct tm tm_r; + tm_r.tm_year = year - 1900; + tm_r.tm_mon = month -1; + tm_r.tm_mday = day; + tm_r.tm_hour = tm_r.tm_min = tm_r.tm_sec = 0; + tm_r.tm_isdst = -1; // makes sure mktime() will determine the correct DST setting + return mktime(&tm_r); +} + +// format is in datepicker format ('mm' for month, 'dd' for day, 'yyyy' for year) +std::string DatePickerToC(time_t date, std::string const& format) +{ + if (date == 0) return ""; + std::string cformat = format; + cformat = StringReplace(cformat, "mm", "%m"); + cformat = StringReplace(cformat, "dd", "%d"); + cformat = StringReplace(cformat, "yyyy", "%Y"); + return FormatDateTime(cformat.c_str(), date); +} + + } // namespace vdrlive |