Skip to content

DateExtensions

Convenience predicates and formatters for DateTime/DateTime? values: current/future/past classification, min/max detection, short-date rendering, and epoch conversion.

Purpose

  • Convenience predicates and formatters for DateTime/DateTime? values: current/future/past classification, min/max detection, short-date rendering, and epoch conversion.

Context

  • Namespace: SAIF.Common.Extensions
  • Assembly/package: SAIF.Framework.Common

Public members

Member Signature Purpose
IsCurrentDate(this DateTime value) public static bool IsCurrentDate(this DateTime value) True when the date component equals today's date.
IsFutureDate(this DateTime value) public static bool IsFutureDate(this DateTime value) True when the date component is later than today.
IsPastDate(this DateTime value) public static bool IsPastDate(this DateTime value) True when the date component is earlier than today.
IsMinOrMax(this DateTime value) public static bool IsMinOrMax(this DateTime value) True when the value equals DateTime.MinValue or DateTime.MaxValue, used to detect an unset/open-ended sentinel date. (BR-002)
ToSaifShortDateString(this DateTime value) public static string ToSaifShortDateString(this DateTime value) Formats a DateTime using the library's short date convention.
ToSaifShortDateString(this DateTime? value) public static string ToSaifShortDateString(this DateTime? value) Nullable overload; formats or returns an empty/placeholder string when null.
ToEpochTime(this DateTime value) public static long ToEpochTime(this DateTime value) Converts a DateTime to a Unix epoch timestamp (seconds since 1970-01-01 UTC).

Sources

  • Common/SAIF.Common/Extensions/DateExtensions.cs