简体   繁体   中英

ASP.NET Core Web API calculate working hours

How to show working days as true working day and Saturday, Sunday as false working day of one month? In an ASP.NET Core Web API

public string DayName { get; set; }
public DateTime DateOfTheDay { get; set; }
public bool IsWorkingDay { get; set; }

DateTime has a DayOfWeek property you can use to figure it out. As for how to "show" it, that depends on how you are building your view.

public bool IsWorkingDay 
{
    get { return !(DateOfTheDay.DayOfWeek == DayOfWeek.Saturday || DateOfTheDay.DayOfWeek == DayOfWeek.Sunday); }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM