Exemplo n.º 1
0
 /// <summary>
 /// Adds given <see cref="TimeSpan"/> to current <see cref="DateTime.Now"/> and returns resulting <see cref="DateTime"/> in the future.
 /// </summary>
 public static DateTime FromNow(this FluentTimeSpan from)
 {
     return(from.From(DateTime.Now));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Adds given <see cref="TimeSpan"/> to supplied <paramref name="originalValue"/> <see cref="DateTime"/> and returns resulting <see cref="DateTime"/> in the future.
 /// </summary>
 public static DateTime From(this FluentTimeSpan from, DateTime originalValue)
 {
     return(originalValue.AddMonths(from.Months).AddYears(from.Years).Add(from.TimeSpan));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Subtracts given <see cref="TimeSpan"/> from <paramref name="originalValue"/> <see cref="DateTime"/> and returns resulting <see cref="DateTime"/> in the past.
 /// </summary>
 public static DateTime Ago(this FluentTimeSpan from, DateTime originalValue)
 {
     return(from.Before(originalValue));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Subtracts given <see cref="FluentTimeSpan"/> from current date (<see cref="DateTime.Now"/>) and returns resulting <see cref="DateTime"/> in the past.
 /// </summary>
 public static DateTime Ago(this FluentTimeSpan from)
 {
     return(from.Before(DateTime.Now));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Convert a <see cref="TimeSpan"/> to a human readable string.
 /// </summary>
 /// <param name="timeSpan">The <see cref="TimeSpan"/> to convert</param>
 /// <returns>A human readable string for <paramref name="timeSpan"/></returns>
 public static string ToDisplayString(this FluentTimeSpan timeSpan)
 {
     return(((TimeSpan)timeSpan).ToDisplayString());
 }
Exemplo n.º 6
0
 /// <summary>
 /// Adds given <see cref="TimeSpan"/> to supplied <paramref name="originalValue"/> <see cref="DateTime"/> and returns resulting <see cref="DateTime"/> in the future.
 /// </summary>
 /// <seealso cref="From(FluentTimeSpan,System.DateTime)"/>
 /// <remarks>
 /// Synonym of <see cref="From(FluentTimeSpan,System.DateTime)"/> method.
 /// </remarks>
 public static DateTime Since(this FluentTimeSpan from, DateTime originalValue)
 {
     return(From(from, originalValue));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Subtracts given <see cref="TimeSpan"/> from <paramref name="originalValue"/> <see cref="DateTime"/> and returns resulting <see cref="DateTime"/> in the past.
 /// </summary>
 public static DateTimeOffset Before(this FluentTimeSpan from, DateTimeOffset originalValue)
 {
     return(originalValue.AddMonths(-from.Months).AddYears(-from.Years).Add(-from.TimeSpan));
 }