Changeset 13954 for trunk/FACT++


Ignore:
Timestamp:
05/28/12 23:50:20 (13 years ago)
Author:
tbretz
Message:
Added functions to get time difference as string
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Time.cc

    r13777 r13954  
    268268}
    269269
     270string Time::MinutesTo(const Time &time) const
     271{
     272    ostringstream str;
     273    if (time>*this)
     274        str << time-*this;
     275    else
     276        str << *this-time;
     277    return str.str().substr(0, 5);
     278}
     279
     280string Time::SecondsTo(const Time &time) const
     281{
     282    ostringstream str;
     283    if (time>*this)
     284        str << time-*this;
     285    else
     286        str << *this-time;
     287    return str.str().substr(str.str().substr(0, 3)=="00:" ? 3 : 0, 5);
     288}
     289
    270290// --------------------------------------------------------------------------
    271291//
  • trunk/FACT++/src/Time.h

    r13777 r13954  
    103103    uint64_t JavaDate() const { return uint64_t(UnixTime()*1000); }
    104104
     105    std::string MinutesTo(const Time & = Time()) const;
     106    std::string SecondsTo(const Time & = Time()) const;
     107
    105108    int NightAsInt() const;
    106109};
Note: See TracChangeset for help on using the changeset viewer.