C# Class Utilities.Extensions.NumberExtensions

Mostra file Open project: feanz/Utilities

Public Methods

Method Description
Days ( this num ) : System.TimeSpan

Converts the number to days as a TimeSpan.

DaysAgo ( this days ) : System.DateTime

Returns a date in the past by given number of days.

DaysFromNow ( this days ) : System.DateTime

Returns a date in the future by days.

EnsurePositive ( this number ) : float

Ensures that the specified float is positive

EnsurePositive ( this number ) : int

Ensures that the specified integer is positive

ForceLength ( this number, int length ) : string

Convert integer to string with a minimum length padding with "0" if int is to short.

Hours ( this num ) : System.TimeSpan

Converts the number to hours as a TimeSpan

HoursAgo ( this hours ) : System.DateTime

Returns a date in the past by hours.

HoursFromNow ( this hours ) : System.DateTime

Returns a date in the future by hours.

IsEven ( this value ) : bool

Returns true if number is even

IsOdd ( this value ) : bool

Returns true if number is odd

Minutes ( this num ) : System.TimeSpan

Converts the number of minutes as a TimeSpan

MinutesAgo ( this minutes ) : System.DateTime

Returns a date in the past by minutes

MinutesFromNow ( this minutes ) : System.DateTime

Returns a date in the future by minutes.

Seconds ( this num ) : System.TimeSpan

Converts the number to seconds as a TimeSpan

SecondsAgo ( this seconds ) : System.DateTime

Gets a date in the past according to seconds

SecondsFromNow ( this seconds ) : System.DateTime

Gets a date in the future by seconds.

Time ( this num ) : System.TimeSpan

Converts the number to a TimeSpan.

Time ( this num, bool convertSingleDigitsToHours ) : System.TimeSpan

Converts the military time to a timespan.

ToBinary ( this number ) : string

Returns a binary string representation of the number.

ToHex ( this number ) : string

Returns a hexadecimal string representation of the number.

ToHexChar ( this nibble ) : int

Convert an nibble value(4 bit) integer to its corresponding hex value

ToStringCurrentCulture ( this instance ) : string

Returns a string representation using the Current culture

ToStringInvariantCulture ( this instance ) : string

Returns a string representation using an invariant culture

Method Details

Days() public static method

Converts the number to days as a TimeSpan.
public static Days ( this num ) : System.TimeSpan
num this Number representing days
return System.TimeSpan

DaysAgo() public static method

Returns a date in the past by given number of days.
public static DaysAgo ( this days ) : System.DateTime
days this The days.
return System.DateTime

DaysFromNow() public static method

Returns a date in the future by days.
public static DaysFromNow ( this days ) : System.DateTime
days this The days.
return System.DateTime

EnsurePositive() public static method

Ensures that the specified float is positive
public static EnsurePositive ( this number ) : float
number this The float we are ensuring is positive
return float

EnsurePositive() public static method

Ensures that the specified integer is positive
public static EnsurePositive ( this number ) : int
number this The integer we are ensuring is positive.
return int

ForceLength() public static method

Convert integer to string with a minimum length padding with "0" if int is to short.
public static ForceLength ( this number, int length ) : string
number this The number we are coverting to a fixed string length.
length int The length to fix the integer to.
return string

Hours() public static method

Converts the number to hours as a TimeSpan
public static Hours ( this num ) : System.TimeSpan
num this Number representing hours
return System.TimeSpan

HoursAgo() public static method

Returns a date in the past by hours.
public static HoursAgo ( this hours ) : System.DateTime
hours this The hours.
return System.DateTime

HoursFromNow() public static method

Returns a date in the future by hours.
public static HoursFromNow ( this hours ) : System.DateTime
hours this The hours.
return System.DateTime

IsEven() public static method

Returns true if number is even
public static IsEven ( this value ) : bool
value this The value to check.
return bool

IsOdd() public static method

Returns true if number is odd
public static IsOdd ( this value ) : bool
value this
return bool

Minutes() public static method

Converts the number of minutes as a TimeSpan
public static Minutes ( this num ) : System.TimeSpan
num this Number representing minutes
return System.TimeSpan

MinutesAgo() public static method

Returns a date in the past by minutes
public static MinutesAgo ( this minutes ) : System.DateTime
minutes this The minutes.
return System.DateTime

MinutesFromNow() public static method

Returns a date in the future by minutes.
public static MinutesFromNow ( this minutes ) : System.DateTime
minutes this The minutes.
return System.DateTime

Seconds() public static method

Converts the number to seconds as a TimeSpan
public static Seconds ( this num ) : System.TimeSpan
num this
return System.TimeSpan

SecondsAgo() public static method

Gets a date in the past according to seconds
public static SecondsAgo ( this seconds ) : System.DateTime
seconds this The seconds.
return System.DateTime

SecondsFromNow() public static method

Gets a date in the future by seconds.
public static SecondsFromNow ( this seconds ) : System.DateTime
seconds this The seconds.
return System.DateTime

Time() public static method

Converts the number to a TimeSpan.
public static Time ( this num ) : System.TimeSpan
num this Number reprsenting a timespan
return System.TimeSpan

Time() public static method

Converts the military time to a timespan.
public static Time ( this num, bool convertSingleDigitsToHours ) : System.TimeSpan
num this
convertSingleDigitsToHours bool Indicates whether to treat "9" as 9 hours instead of minutes.
return System.TimeSpan

ToBinary() public static method

Returns a binary string representation of the number.
public static ToBinary ( this number ) : string
number this The integer number to convert.
return string

ToHex() public static method

Returns a hexadecimal string representation of the number.
public static ToHex ( this number ) : string
number this The integer number to convert.
return string

ToHexChar() public static method

Convert an nibble value(4 bit) integer to its corresponding hex value
public static ToHexChar ( this nibble ) : int
nibble this
return int

ToStringCurrentCulture() public static method

Returns a string representation using the Current culture
public static ToStringCurrentCulture ( this instance ) : string
instance this
return string

ToStringInvariantCulture() public static method

Returns a string representation using an invariant culture
public static ToStringInvariantCulture ( this instance ) : string
instance this
return string