DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
No more ctime(3C) errors - Time(3C++)

Functions for expressing Durations in natural units

A constructor can sometimes be an awkward way to express a Duration, especially in certain expressions. For example, a Duration of 1 second would be written:

       Duration(0,0,0,1)

which is not very readable. For this reason, class Duration provides four static member functions (Duration::days(), Duration::hours(), Duration::minutes(), and Duration::seconds()) that allow Durations to be expressed more naturally. To illustrate their use, the expressions on either side of the equality operator yield equal values:

       Duration(1,0,0,1) ==  Duration::days(1) +
                             Duration::seconds(1)

The functions were made static members (rather than ordinary global functions) to avoid polluting the global namespace.


Next topic: Component extractors
Previous topic: Constructors

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004