Skip to content

Commit

Permalink
Add new TimeSpan.From methods (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
gligorov authored and josesimoes committed Nov 28, 2018
1 parent 35f62a9 commit a160f28
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions source/nanoFramework.CoreLibrary/System/TimeSpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,42 @@ public double TotalMilliseconds
/// <param name="value">A number of ticks that represent a time.</param>
/// <returns>An object that represents value.</returns>
public static TimeSpan FromTicks(long value) => new TimeSpan(value);

/// <summary>
/// Returns a <see cref="TimeSpan"/> that represents a specified time, where the specification is in units of miliseconds.
/// </summary>
/// <param name="value">A number of miliseconds that represent a time.</param>
/// <returns>An object that represents value.</returns>
public static TimeSpan FromMiliseconds(long value) => new TimeSpan(TimeSpan.TicksPerMillisecond * value);

/// <summary>
/// Returns a <see cref="TimeSpan"/> that represents a specified time, where the specification is in units of seconds.
/// </summary>
/// <param name="value">A number of seconds that represent a time.</param>
/// <returns>An object that represents value.</returns>
public static TimeSpan FromSeconds(long value) => new TimeSpan(TimeSpan.TicksPerSecond * value);

/// <summary>
/// Returns a <see cref="TimeSpan"/> that represents a specified time, where the specification is in units of minute.
/// </summary>
/// <param name="value">A number of minute that represent a time.</param>
/// <returns>An object that represents value.</returns>
public static TimeSpan FromMinutes(long value) => new TimeSpan(TimeSpan.TicksPerMinute * value);

/// <summary>
/// Returns a <see cref="TimeSpan"/> that represents a specified time, where the specification is in units of hours.
/// </summary>
/// <param name="value">A number of hours that represent a time.</param>
/// <returns>An object that represents value.</returns>
public static TimeSpan FromHours(long value) => new TimeSpan(TimeSpan.TicksPerHour * value);

/// <summary>
/// Returns a <see cref="TimeSpan"/> that represents a specified time, where the specification is in units of days.
/// </summary>
/// <param name="value">A number of days that represent a time.</param>
/// <returns>An object that represents value.</returns>
public static TimeSpan FromDays(long value) => new TimeSpan(TimeSpan.TicksPerDay * value);

/// <summary>
/// Converts the value of the current <see cref="TimeSpan"/> object to its equivalent string representation.
/// </summary>
Expand Down

0 comments on commit a160f28

Please sign in to comment.