Skip to content

Add Business Hours Check Extension Method #184

@AhmedFaizanDev

Description

@AhmedFaizanDev

Description:
We could implement a new extension method IsWithinBusinessHours for the DateTime class. This will help check if a specific DateTime falls within a given range of business hours. The method should take startTime and endTime as TimeSpan parameters and return true if the DateTime is between them.

Example Method Signature:

bool IsWithinBusinessHours(this DateTime dateTime, TimeSpan startTime, TimeSpan endTime)

This feature would be handy for checking if a time is during standard working hours. It could be used in scheduling systems or for customer support hours.

Example Usage:

DateTime now = DateTime.Now;
bool isWithinBusinessHours = now.IsWithinBusinessHours(new TimeSpan(9, 0, 0), new TimeSpan(17, 0, 0));

if (isWithinBusinessHours)
{
    Console.WriteLine("The current time is within business hours.");
}
else
{
    Console.WriteLine("The current time is outside business hours.");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions