/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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()); }
/// <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)); }
/// <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)); }