我需要 DSL 来计算时间
有谁知道用于时间计算的 DSL,它能够理解“该月最后一个工作日后的第二个工作日”等概念吗?
我不介意编写解析器,但我需要语言本身的帮助。
Does anyone know of a DSL for time calculations, something that would be able to understand concepts like "2nd business day after the last business day of the month"?
I don't mind writing the parser, but I need help with the language itself.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于 Java,Joda time 非常流畅!
For Java, Joda time is really sleek!
查看 Jay Muntz 的“动态假日日期计算器”。
这是一个不同的用例,但除非您对所有 XML 都感到厌烦,否则可以在您的情况下使用相同类型的表示语言。 我发现定义自定义日历很容易。
Have a look at the "Dynamic Holiday Date Calculator" by Jay Muntz.
It is a different use case, but unless you are turned off by everything XML, the same type of representation language could be used in your case. I found it easy to work with for defining custom calendars.
所有此类内容的规范来源是 Calendrical
Nachum Dershowitz 和 Ed Reingold 的计算。 首先,它是有史以来最受欢迎的 SP&E 论文; 然后它是一本书; 现在已经是第三版了。 曾经你可以下载 Lisp 代码,但该功能似乎从网页上消失了。 还有一个小程序,很容易重新实现; 我已经在 Icon 和 Lua 中完成了实现。
所以我建议你真正想要的是他们的库,然后如果你想要一个解析器,你就知道该怎么做。
The canonical source on all this kind of stuff is Calendrical
Calculations by Nachum Dershowitz and Ed Reingold. First it was the most-requested SP&E paper of all time; then it was a book; now it's in its third edition. At one time you could download Lisp code, but that feature seems to be gone from the web page. There is also an applet, and it is easy to reimplement; I have done implementations in Icon and in Lua.
So I'm suggesting what you really want is their library, and then if you want to have a parser for it, you know how to do that.
这可能不是您想要的,但您可能想看看 Chronic,一个 Ruby 库,用于执行以下操作:
http://chronic.rubyforge.org/
This may not be what you're looking for, but you might want to take a look at Chronic, a Ruby library for doing something like this:
http://chronic.rubyforge.org/