-
Notifications
You must be signed in to change notification settings - Fork 11
Common DateTime
Ivan Kozhin edited this page Sep 7, 2020
·
4 revisions
DateTime Truncate(DateTime target, DateTimePeriod period, CultureInfo cultureInfo = null)Truncates date by the specified period. Return begin of the period.
int CompareTo(DateTime target, DateTime value, DateTimePeriod period)Compares the value of the instance to a specified DateTime object with truncation, and returns an integer that indicates whether this instance is earlier than, the same as, or later than the specified DateTime value.
IEnumerable<DateTime> GetRange(DateTime fromDate, DateTime toDate)Returns dates range. Uses lazy implementation.
DateTime CombineDateAndTime(DateTime date, DateTime time)Combines date part from date and time from another. Kind is getting from the time part.
DateTime GetStartOfPeriod(DateTime target, DateTimePeriod period, CultureInfo cultureInfo = null)Returns start of the period.
DateTime GetEndOfPeriod(DateTime target, DateTimePeriod period, CultureInfo cultureInfo = null)Returns end DateTime of the period.
DateTime FromUnixTimestamp(double unixTimeStamp)Converts from UNIX timestamp to DateTime.
double ToUnixTimestamp(DateTime target)Converts DateTime to UNIX timestamp.
double GetDiff(DateTime target1, DateTime target2, DateTimePeriod period)Returns period difference between two dates. Negative values are converted to positive.
DateTime SetPart(DateTime target, DateTimePeriod period, int value)Shortcut to set date part.