DateTimeExtensions Class

Namespace:
Weavy.Core.Helpers
Assembly:
Weavy.Core.dll

Helper and extension methods for dates and times.

public static class DateTimeExtensions
Inheritance:
System.Object → DateTimeExtensions

Methods

From(DateTime, DateTime, bool) Returns a textual representation of a date relative to another date.
FromNow(DateTime, bool) Returns a textual representation of the specified date from now. This is sometimes called "time ago" or "relative time".
FromNow(DateTime?) Returns a textual representation of the specified date from now. This is sometimes called "time ago" or "relative time".
IsBetween(DateTime, DateTime, DateTime) Check if date is between the two dates a and b.
NextFrom(CrontabSchedule, DateTime?) Gets the next occurrence of this schedule starting with a base time.
ToLocal(DateTime) Converts an UTC date to local server/user time.
ToLocal(DateTime?) Converts an UTC date to local server/user time.
ToShortDateString(DateTime?) Converts a datetime object to its short date string representation.
ToString(DateTime?, string) Converts a datetime object to string.
ToStringRelative(TimeSpan, bool) Returns a textual representation of a time span.
ToUnixTime(DateTime) Gets the current Unix time for the specified date (UTC), i.e. the number of seconds since 1970-01-01T00:00:00Z.
ToUtc(DateTime) Converts a local time to UTC.
When(DateTime, bool) Returns a textual representation when the specified date occured, e.g. "4:38 PM", "Yesterday", "Wednesday", "June 16", "10/06/16" etc.