Ignore:
Timestamp:
Mar 23, 2011, 9:37:17 AM (10 years ago)
Author:
tbretz
Message:
Added some example how to calculate with times.
File:
1 edited

Legend:

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

    r10183 r10251  
    44
    55using namespace std;
     6using namespace boost::posix_time;
    67
    78int main(int, char **)
     
    7273    cout << endl;
    7374
     75    const Time t0;
     76    Time t1 = t0;
     77    cout << "T0  =          " << t0 << endl;
     78    cout << "T1  =          " << t1 << endl;
     79    t1 += hours(4242);
     80    cout << "T1 += 4242h:   " << t1 << endl;
     81    t1 += minutes(42);
     82    cout << "T1 += 42min:   " << t1 << endl;
     83    t1 += seconds(42);
     84    cout << "T1 += 42sec:   " << t1 << endl;
     85    cout << endl;
     86
     87    cout << "T1 - T0 = " << t1-t0 << endl;
     88
     89    const time_duration diff = t1-t0;
     90    cout << "T1 - T0 = " << diff.total_seconds() << "sec" << endl;
     91    cout << endl;
     92
    7493    return 0;
    7594}
Note: See TracChangeset for help on using the changeset viewer.