Project

General

Profile

Task #1152

Updated by Junxiao Shi about 10 years ago

Define `time::Duration` and `time::Point` types; implement `time::now`. 

 `time::Duration` should be convertible to and from nanoseconds.   
 `time::Point` represents a time point in monotonic clock, and doesn't need to relate with UTC time. 

 These types should support addition, subtraction, and comparison operators. 

 * Point + Duration => Point 
 * Point - Point => Duration 
 * Duration + Duration => Duration 
 * Duration - Duration => Duration 
 * Comparisons should take two operands of same type 

 `time::now()` uses monotonic clock on every platform that supports it, otherwise fallback to wall clock. 
 

 `time::nowCached()` returns the result from most recent invocation of `time::now()`.

Back