bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
agg_util::SimpleTimeParser Class Reference

#include <SimpleTimeParser.h>

Collaboration diagram for agg_util::SimpleTimeParser:
Collaboration graph

Static Public Member Functions

static bool parseIntoSeconds (long &seconds, const std::string &duration)
 

Detailed Description

Helper class to parse in very simple string specifications of times and return it as an (approximate) duration in seconds. By approximate, we use a month to be 31 days and a year to be 365 days for purposes of converting to seconds.

We only can parse strings of the form "%d %unit" where d stands for a number and unit stands for a single basic time unit in this list. We give the unit and then the strings that can be used to represent it.

seconds: { s, second, seconds } minutes: { m, min, mins } hours: { h, hour, hours } days: { day, days } weeks: { week, weeks} months: { month, months } [note: month considered 31 days!] years: { year, years }

For example:

"1 min" "3 s" "5 hours" "3 days" "10 seconds" "5 years" "1 month"

TODO This probably should be tested using CPPUnit

Definition at line 73 of file SimpleTimeParser.h.

Constructor & Destructor Documentation

◆ SimpleTimeParser()

agg_util::SimpleTimeParser::SimpleTimeParser ( )

Definition at line 49 of file SimpleTimeParser.cc.

◆ ~SimpleTimeParser()

agg_util::SimpleTimeParser::~SimpleTimeParser ( )

Definition at line 53 of file SimpleTimeParser.cc.

Member Function Documentation

◆ parseIntoSeconds()

bool agg_util::SimpleTimeParser::parseIntoSeconds ( long & seconds,
const std::string & duration )
static

Parse the string in duration and to calculate the (approximate) number of seconds it represents. By approximate, we mean that a month is considered 31 days and a year as 365 days.

Parameters
secondsthe result will be placed in here on success
durationtime duration as specified in class docs.
Returns
whether the parse was successful. if true, seconds is valid. if false, seconds will also be -1.

Definition at line 57 of file SimpleTimeParser.cc.


The documentation for this class was generated from the following files: