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

CSharp examples for System:DateTime Calculate

Description

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

Demo Code

// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods)
using System;//from   www .  java2  s  .co m

public class Main{
        /// <summary>
    ///     A DateTime extension method that query if '@this' is morning.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>true if morning, false if not.</returns>
    public static bool IsMorning(this DateTime @this)
    {
        return @this.TimeOfDay < new DateTime(2000, 1, 1, 12, 0, 0).TimeOfDay;
    }
}

Related Tutorials