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

CSharp examples for System:DateTime Calculate

Description

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

Demo Code

// Copyright (c) 2015 ZZZ Projects. All rights reserved
using System;// www  .  j  a v  a2s  .com

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

Related Tutorials