国庆节网络服务
我可以调用公共/政府网络服务来了解特定年份的国家法定节假日吗? (适用于美国和/或世界上任何国家。)
编辑:有人有一套计算美国假期的公式吗? (如果可以选择的话,C# 将是我选择的语言。)
Is there a public/government web service that I can call to find out what the national holidays are for a given year? (For the US and/or any country in the world.)
Edit: Does anybody have a set of formulas to calculate US holidays? (C# would be my language of choice if there is a choice.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我正在寻找类似的基于 PL/SQL 的东西。 我找到了jollyday(sourceforge)。 它是java,也许你可以将它与c# 中的ikvm 一起使用。 遗憾的是,我无法将 java api 加载到我的 oracle rdbms 中...所以...如果您遇到纯 C 或 PL/SQL 解决方案,请告诉我:-)
干杯
克里斯
I am looking for something similar PL/SQL based. I found jollyday (sourceforge). It is java maybe you can use it with ikvm from c#. Sadly I was not able to load the java api into my oracle rdbms ... so ... if you came across a pure C or PL/SQL solution, please let me know :-)
Cheers
Chris
有大量类似的信息确实应该由政府网络服务提供。 如果美国政府能够通过网络服务提供这样的信息,从长远来看,肯定会节省大量资金并减少错误。 哎呀,即使采用可下载、可解析的格式,也将是朝着正确方向迈出的一大步。
我在寻找一种方法来确保应用程序在工作日计算中跳过所有美国联邦假期时遇到了这个问题。 我找到的最好的 .gov 来源是:
运营状态OPM 的时间表
其中包含我们到 2020 年所需的数据,但我们必须将其输入到我们自己的表中。
There are tons of similar information that really should be provided by government web services. It would certainly save a lot of money and errors in the long run if the U.S. Government could provide information like this through web services. Heck, even having it in a downloadable, parseable format would be a big step in the right direction.
I ran across this question while looking for a way to ensure an application skipped all U.S. Federal holidays in working days calculations. The best .gov source I found is:
Operating Status Schedules from OPM
This has the data we need through 2020, but we'll have to type it into our own tables.
没有人会免费放弃这一点(世界上有哪个国家?说实话)。 最好的来源是 Copp Clark(我不隶属)。 他们提供按金融市场、货币等细分的所有国家/地区的所有假期。
No one gives that up for free (any country in the world? Get real). The best source is Copp Clark (I'm unaffiliated). They provide all holidays for all countries broken down by financial market, currency, etc.
可能需要进行一些解析,并且不是 100% 完成,但您可以使用 wikipedia。
Some parsing may be required, and it's not 100% complete, but you can use wikipedia.
对于计算美国假期的方法/组件,基本上只需计算出所有主要假期及其使用的“公式”即可。
对于那些永远不会改变的人来说,比如圣诞节,这很简单——12 月 25 日。
对于那些确实有所变化的国家,通常有一个公式 - 例如二月的第三个星期一是总统日。 您可以让该方法计算出给定年份的值。
这不适用于没有任何特定模式的假期(即,一些委员会每年决定日期),但对于所有主要假期,都有容易辨别的公式。
这实际上是测试驱动设计的一个很好的候选者。 您将知道特定年份的所有主要假期日期,因此您应该能够将该年份输入该方法并获得正确的答案。
For the method/assembly to figure out US Holidays, basically just figure out all the major holidays and the "formula" that they use.
For the ones that never change, like Christmas, it's easy - December 25th.
For the ones that do change somewhat, there's usually a formula - like the third Monday in February being Presidents Day. You can just have the method figure this out for a given year.
This won't work for holidays without any particular pattern (i.e., some committee decides what the date is every year) but for all the major ones there's easily discernible formulas.
This would actually be a great candidate for Test Driven Design. You will know all of the major holiday dates for a particular year, so you should be able to feed that year into the method and get the right answers.
您可以订阅在线日历。 例如,Google 提供美国节假日:
ICA
HTML
There are online calendars you can subscribe to. For example, Google provides US Holidays:
ICAL
HTML
http://www.holidaywebservice.com 上有一个网络服务,它将提供美国、共和国的假期日期爱尔兰、英格兰和苏格兰。 他们还出售 DLL 和源代码。
至于算法的细节,你可能比查看优秀的日历计算更糟糕本书(第三版),对于所有日历问题来说都是一本非常有趣的读物,并且包括其日历算法的示例 LISP 代码。
There's a web service at http://www.holidaywebservice.com which will provide dates of holidays for the USA, Republic of Ireland, England and Scotland. They also sell a DLL and source code.
As for details of algorithms, you could do worse than check out the excellent Calendrical Calculations book (third edition), which is a really fascinating read for all matters calendrical, and includes sample LISP code for their calendar algorithms.
您可以尝试https://kayaposoft.com/enrico/。 Enrico Service 是一项免费服务,为包括美国在内的多个国家/地区提供公共假期。 美国或德国等国家的公共假期是每个州单独规定的。 您可以使用 json 或soap 从 Enrico 获取公共假期。
You can try https://kayaposoft.com/enrico/. Enrico Service is a free service providing public holidays for several countries including US. Public holidays for the countries like US or Germany are provided separately for each state. You can use either json or soap to get public holidays from Enrico.