A DateTime extension method that query if '@this' is today. - CSharp System

CSharp examples for System:DateTime Day

Description

A DateTime extension method that query if '@this' is today.

Demo Code

// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods)
using System;/*w  w w .j a  va2s. c o  m*/

public class Main{
        /// <summary>
    ///     A DateTime extension method that query if '@this' is today.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>true if today, false if not.</returns>
    public static bool IsToday(this DateTime @this)
    {
        return @this.Date == DateTime.Today;
    }
}

Related Tutorials