业务/假日日期处理 [英] Business/Holiday date handling
问题描述
我正在寻找一个与Perl模块类似的C#类/库 Date :: Manip
的营业日/节假日。使用Perl中的该模块,我可以为它传递一个日期,并确定是工作日(即周一至周五)还是假日。在配置文件中定义假期非常简单(请参见 Date :: Manip :: Holidays
)。您可以输入适用于每年的固定日期,例如:
I'm looking for a C# class/library that works similarly to the Perl module Date::Manip
as far as business/holiday dates. Using that module in Perl, I can pass it a date and find out whether it's a business day (ie, Mon-Fri) or a holiday. Holidays are very simple to define in a config file (see Date::Manip::Holidays
). You can enter a 'fixed' date that applies to every year like:
12/25 = Christmas
或每年的动态日期,例如:
or 'dynamic' dates for every year like:
last Monday in May = Memorial Day
或给定年份的固定日期,例如:
or 'fixed' dates for a given year like:
5/22/2010 = Bob's Wedding
您还可以传递日期并获取返回下一个/上一个工作日。
You can also pass in a date and get back the next/previous business day.
在C#世界中,有人知道吗?我发现有几件东西可以实现我所需的部分内容( http:// www .codeproject.com / KB / cs / busdatescalculation.aspx 和 http:// www.codeproject.com/KB/dotnet/HolidayCalculator.aspx ),然后我可以将它们分开并做出我需要的东西。但是,如果其他人已经做到了,为什么还要再做一次呢?
Does anyone know of anything like that in the C# world? I've found a couple of things that implement parts of what I need (http://www.codeproject.com/KB/cs/busdatescalculation.aspx and http://www.codeproject.com/KB/dotnet/HolidayCalculator.aspx) and I can pick them apart and make what I need. But if someone else has already done that, why do it again?
推荐答案
我找不到能完全满足我要求的东西想要,所以我使用了 http://www.codeproject.com/KB/dotnet/ HolidayCalculator.aspx 并对其进行了修改以满足我的需求。它满足了我的大部分需求,因此不需要太多调整。
I couldn't find anything that did exactly what I wanted so I used the code from http://www.codeproject.com/KB/dotnet/HolidayCalculator.aspx and modified it to fit my needs. It did most of what I needed so it didn't take much tweaking.
这篇关于业务/假日日期处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!