From 99d25bd0dbdc41c5d8aace47ead4a5468f0fc330 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 1 Jul 2011 22:21:25 -0400 Subject: [PATCH] Enhancement - Implemented Record::get_duration as a helper. --- src/Record.cpp | 10 ++++++++++ src/Record.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/Record.cpp b/src/Record.cpp index 45fe7d32a..df7977a6e 100644 --- a/src/Record.cpp +++ b/src/Record.cpp @@ -178,6 +178,16 @@ time_t Record::get_date (const std::string& name) const return 0; } +//////////////////////////////////////////////////////////////////////////////// +time_t Record::get_duration (const std::string& name) const +{ + Record::const_iterator i = this->find (name); + if (i != this->end ()) + return (time_t) strtoul (i->second.value ().c_str (), NULL, 10); + + return 0; +} + //////////////////////////////////////////////////////////////////////////////// void Record::set (const std::string& name, const std::string& value) { diff --git a/src/Record.h b/src/Record.h index 61586f47c..93fbc0820 100644 --- a/src/Record.h +++ b/src/Record.h @@ -51,6 +51,7 @@ public: int get_int (const std::string&) const; unsigned long get_ulong (const std::string&) const; time_t get_date (const std::string&) const; + time_t get_duration (const std::string&) const; void set (const std::string&, const std::string&); void set (const std::string&, int); void remove (const std::string&);