计算两个日期和时间之间的总时间差,不包括假期和非工作时间 [英] Calculate total Time difference between two date and time excluding holidays and non working hours

查看:159
本文介绍了计算两个日期和时间之间的总时间差,不包括假期和非工作时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个场景,我想计算排除假期的两个日期和时间之间的时差(即星期六和星期日)。同时工作时间为9小时计算(即开始时间为12:00 PM,结束时间为晚上9:00),因此在此时间之后,不应计算
非工作时间。

I want a scenario where i want to calculate time difference between two date and time that exclude holiday(i.e. Saturday and Sunday). As well working hours par day as 9 hrs calculation(i.e. Start time is 12:00PM and End time is 9:00PM) so after this hours non-working hours should not be calculated in thatcalculation.

例如假设2018年3月14日晚上8点有一个请求,并且在第二天(即2018年3月15日)下午02:00批准。所以这些时间差将是3小时。我如何使用C#实现这一目标?

e.g. Suppose there is one request on 14th March 2018 8:00PM and it's approved on next Day(i.e. 15th March 2018) on 02:00PM. so these time difference will come as 3hrs. How i can achieve this using C#?

推荐答案

您在寻找逻辑还是方法?我觉得没有任何一种方法。你仍然可以使用Add,从TimeSpan减去
Are you looking for logic or a method? I feel there won't be any single method. Still you can create your own using Add, subtract from TimeSpan


这篇关于计算两个日期和时间之间的总时间差,不包括假期和非工作时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆