C# Class NFluent.Helpers.TimeHelper

Static class hosting various time helper.
Show file Open project: tpierrain/NFluent Class Usage Examples

Public Methods

Method Description
Convert ( System.TimeSpan value, TimeUnit unit ) : double

Expresses a TimeSpan duration in the desired TimeUnit.

DiscoverUnit ( System.TimeSpan timeSpan ) : TimeUnit

Discover the most appropriate TimeUnit to express the given duration.

GetFromNanoSeconds ( double duration, TimeUnit timeUnit ) : double

Converts a duration in nanoseconds to the desired TimeUnit.

GetInNanoSeconds ( double value, TimeUnit unit ) : double

Converts a duration in nanoseconds.

ToTimeSpan ( double value, TimeUnit timeUnit ) : System.TimeSpan

Creates a TimeSpan representing the duration expressed in TimeUnit.

Private Methods

Method Description
GetConversionFactor ( TimeUnit unit ) : long

Method Details

Convert() public static method

Expresses a TimeSpan duration in the desired TimeUnit.
Raised if time unit is not recognized.
public static Convert ( System.TimeSpan value, TimeUnit unit ) : double
value System.TimeSpan Duration to convert.
unit TimeUnit to convert to.
return double

DiscoverUnit() public static method

Discover the most appropriate TimeUnit to express the given duration.
public static DiscoverUnit ( System.TimeSpan timeSpan ) : TimeUnit
timeSpan System.TimeSpan /// Duration to analyze. ///
return TimeUnit

GetFromNanoSeconds() public static method

Converts a duration in nanoseconds to the desired TimeUnit.
/// Raised if time unit is not recognized. ///
public static GetFromNanoSeconds ( double duration, TimeUnit timeUnit ) : double
duration double /// The duration in nanoseconds. ///
timeUnit TimeUnit /// The time unit desired. ///
return double

GetInNanoSeconds() public static method

Converts a duration in nanoseconds.
Raised if time unit is not recognized.
public static GetInNanoSeconds ( double value, TimeUnit unit ) : double
value double Number of time units.
unit TimeUnit Time unit in which duration is expressed.
return double

ToTimeSpan() public static method

Creates a TimeSpan representing the duration expressed in TimeUnit.
Raised if time unit is not recognized.
public static ToTimeSpan ( double value, TimeUnit timeUnit ) : System.TimeSpan
value double /// Duration duration. ///
timeUnit TimeUnit /// Duration unit. ///
return System.TimeSpan