Joutsen  v0.4.1
Static Public Member Functions | Public Attributes | List of all members
Joutsen.System.TimeSpanExtensions Class Reference

A static class containing extensions for the System.TimeSpan class. More...

Static Public Member Functions

static String ToUnitString (this TimeSpan timeSpan, String numberFormat="0.###")
 Creates a string representation of timeSpan which represents the time unit that is bigger than zero. More...
 
static String TicksToUnitString (double tickFractions, String numberFormat="0.###")
 Creates a string representation of a number of ticks. More...
 

Public Attributes

const long MICROSECOND_TICKS = 10L
 Number of Ticks in a microsecond. More...
 
const long MILLISECOND_TICKS = MICROSECOND_TICKS * 1000L
 Number of Ticks in a millisecond. More...
 
const long SECOND_TICKS = MILLISECOND_TICKS * 1000
 Number of Ticks in a second. More...
 
const long MINUTE_TICKS = SECOND_TICKS * 60
 Number of Ticks in a minute. More...
 
const long HOUR_TICKS = MINUTE_TICKS * 60
 Number of Ticks in am hour. More...
 
const long DAY_TICKS = HOUR_TICKS * 24
 Number of Ticks in a day. More...
 

Detailed Description

A static class containing extensions for the System.TimeSpan class.

Since
0.3.0

Member Function Documentation

◆ TicksToUnitString()

static String Joutsen.System.TimeSpanExtensions.TicksToUnitString ( double  tickFractions,
String  numberFormat = "0.###" 
)
static

Creates a string representation of a number of ticks.

The resulting representation consists of the number of the biggest possible time unit and the time unit representation. E.g. 2000 Ticks results in 2 ms.

Parameters
tickFractionsthe number of ticks, can also be a fraction
numberFormatthe number format of the output, something like 0.0 for one integer and one decimal palce. See String.Format for details.
Returns
a string representation of the tickFractions in the format including a tiem unit
Remarks
This function is mainly meant to deal with fractional ticks. If not dealing with fractions it is likely that ToUnitString(Timespan) will yield better results.
Since
0.4.0

◆ ToUnitString()

static String Joutsen.System.TimeSpanExtensions.ToUnitString ( this TimeSpan  timeSpan,
String  numberFormat = "0.###" 
)
static

Creates a string representation of timeSpan which represents the time unit that is bigger than zero.

Parameters
timeSpanThe value for which to create the string
numberFormatthe number format of the output, something like 0.0 for one integer and one decimal palce. See String.Format for details.
Returns
A time string consisting of a value and a unit
Remarks
Creates the string for the biggest unit possible. Example: For 1 hour and 30 mins with a format 0.00 the result would be 1.50 h.

Member Data Documentation

◆ DAY_TICKS

const long Joutsen.System.TimeSpanExtensions.DAY_TICKS = HOUR_TICKS * 24

Number of Ticks in a day.

◆ HOUR_TICKS

const long Joutsen.System.TimeSpanExtensions.HOUR_TICKS = MINUTE_TICKS * 60

Number of Ticks in am hour.

◆ MICROSECOND_TICKS

const long Joutsen.System.TimeSpanExtensions.MICROSECOND_TICKS = 10L

Number of Ticks in a microsecond.

◆ MILLISECOND_TICKS

const long Joutsen.System.TimeSpanExtensions.MILLISECOND_TICKS = MICROSECOND_TICKS * 1000L

Number of Ticks in a millisecond.

◆ MINUTE_TICKS

const long Joutsen.System.TimeSpanExtensions.MINUTE_TICKS = SECOND_TICKS * 60

Number of Ticks in a minute.

◆ SECOND_TICKS

const long Joutsen.System.TimeSpanExtensions.SECOND_TICKS = MILLISECOND_TICKS * 1000

Number of Ticks in a second.